Skip to content

Commit

Permalink
Merge branch 'master' into uev-materials
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master authored Sep 4, 2024
2 parents 21eb1fc + 16725e3 commit 8f28769
Show file tree
Hide file tree
Showing 20 changed files with 220 additions and 84 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {
compileOnly("com.github.GTNewHorizons:amunra:0.6.0:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:Galacticraft:3.2.4-GTNH:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:ForestryMC:4.9.10:dev") { transitive = false }
compileOnlyApi("com.github.GTNewHorizons:Mobs-Info:0.4.5-GTNH:dev")
compileOnlyApi("com.github.GTNewHorizons:Mobs-Info:0.4.6-GTNH:dev")

runtimeOnlyNonPublishable rfg.deobf("curse.maven:biomes-o-plenty-220318:2499612")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:WailaHarvestability:1.2.1-GTNH:dev")
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.26'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.27'
}


Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import org.objectweb.asm.tree.ClassNode;

import com.dreammaster.coremod.transformers.ItemFocusWardingTransformer;
import com.dreammaster.coremod.transformers.recipenukers.AdvancedSolarPanelTransformer;
import com.dreammaster.coremod.transformers.recipenukers.BibliocraftTransformer;
import com.dreammaster.coremod.transformers.recipenukers.GraviSuiteTransformer;
import com.dreammaster.coremod.transformers.recipenukers.TravellersGearTransformer;

public class DreamClassTransformer implements IClassTransformer {
Expand All @@ -21,9 +23,11 @@ public class DreamClassTransformer implements IClassTransformer {

public DreamClassTransformer() {
// register your transformers here
registerTransformer(new AdvancedSolarPanelTransformer());
registerTransformer(new BibliocraftTransformer());
registerTransformer(new TravellersGearTransformer());
registerTransformer(new GraviSuiteTransformer());
registerTransformer(new ItemFocusWardingTransformer());
registerTransformer(new TravellersGearTransformer());
}

private void registerTransformer(IDreamTransformer transformer) {
Expand All @@ -46,7 +50,8 @@ public byte[] transform(String name, String transformedName, byte[] basicClass)
final ClassNode classNode = new ClassNode();
classReader.accept(classNode, 0);
final ClassWriter classWriter = new ClassWriter(0);
transformer.transform(classNode).accept(classWriter);
transformer.transform(classNode);
classNode.accept(classWriter);
return classWriter.toByteArray();
}

Expand Down
18 changes: 10 additions & 8 deletions src/main/java/com/dreammaster/coremod/IDreamTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.LdcInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
Expand All @@ -17,9 +16,9 @@ public interface IDreamTransformer {
String[] targetedClasses();

/**
* Returns the transformed ClassNode
* Performs transformations to the ClassNode
*/
ClassNode transform(ClassNode classNode);
void transform(ClassNode classNode);

// =================================================

Expand Down Expand Up @@ -50,13 +49,16 @@ default boolean checkLdcInsnNode(AbstractInsnNode insnNode, Object obj) {
/**
* Method to empty the methodNode and replace its body with just a RETURN Opcode
*/
default void emptyTheMethodNode(MethodNode methodNode) {
final InsnList insnList = new InsnList();
insnList.add(new InsnNode(Opcodes.RETURN));
methodNode.instructions = insnList;
methodNode.localVariables.clear();
default void emptyMethodNode(MethodNode methodNode) {
if (!methodNode.desc.equals("()V")) {
throw new IllegalArgumentException("emptyMethodNode can only be used for ()V methods");
}
methodNode.instructions.clear();
methodNode.instructions.add(new InsnNode(Opcodes.RETURN));
methodNode.maxStack = 0;
methodNode.maxLocals = 0;
methodNode.localVariables = null;
methodNode.tryCatchBlocks = null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public String[] targetedClasses() {
}

@Override
public ClassNode transform(ClassNode classNode) {
public void transform(ClassNode classNode) {
if (DreamCoreMod.patchItemFocusWarding) {
DreamCoreMod.logger.info("Transforming ItemFocusWarding");
for (final MethodNode methodNode : classNode.methods) {
Expand Down Expand Up @@ -73,7 +73,6 @@ public ClassNode transform(ClassNode classNode) {
mv.visitMaxs(1, 2);
mv.visitEnd();
}
return classNode;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.dreammaster.coremod.transformers.recipenukers;

import java.util.ListIterator;

import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;

import com.dreammaster.coremod.DreamCoreMod;
import com.dreammaster.coremod.IDreamTransformer;

public class AdvancedSolarPanelTransformer implements IDreamTransformer {

@Override
public String[] targetedClasses() {
return new String[] { "advsolar.common.AdvancedSolarPanel" };
}

@Override
public void transform(ClassNode classNode) {
for (MethodNode mn : classNode.methods) {
if (mn.name.equals("afterModsLoaded")
&& mn.desc.equals("(Lcpw/mods/fml/common/event/FMLPostInitializationEvent;)V")) {
// changes afterModsLoaded method to :
// public void afterModsLoaded(FMLPostInitializationEvent event) {
// MTAPI.manager = MTRecipeManager.instance;
// }
mn.instructions.clear();
mn.instructions.add(
new FieldInsnNode(
Opcodes.GETSTATIC,
"advsolar/utils/MTRecipeManager",
"instance",
"Ladvsolar/utils/MTRecipeManager;"));
mn.instructions.add(
new FieldInsnNode(
Opcodes.PUTSTATIC,
"advsolar/api/MTAPI",
"manager",
"Ladvsolar/api/IMTRecipeManager;"));
mn.instructions.add(new InsnNode(Opcodes.RETURN));
DreamCoreMod.logger.info("Taking a sledgehammer to {}.{}{}", classNode.name, mn.name, mn.desc);
} else if (mn.name.equals("preInit")
&& mn.desc.equals("(Lcpw/mods/fml/common/event/FMLPreInitializationEvent;)V")) {
// deletes the 4 lines of Recipes.compressor.addRecipe.....
final ListIterator<AbstractInsnNode> it = mn.instructions.iterator();
boolean isDeleting = false;
int ordinal = 0;
while (it.hasNext()) {
final AbstractInsnNode insnNode = it.next();
if (isCompressorFieldNode(insnNode)) {
isDeleting = true;
}
if (isDeleting) {
it.remove();
}
if (isAddRecipeMethodNode(insnNode)) {
ordinal++;
if (ordinal == 4) break;
}
}
DreamCoreMod.logger.info("Taking a sledgehammer to {}.{}{}", classNode.name, mn.name, mn.desc);
}
}
}

private static boolean isCompressorFieldNode(AbstractInsnNode node) {
return node instanceof FieldInsnNode && node.getOpcode() == Opcodes.GETSTATIC
&& ((FieldInsnNode) node).owner.equals("ic2/api/recipe/Recipes")
&& ((FieldInsnNode) node).name.equals("compressor")
&& ((FieldInsnNode) node).desc.equals("Lic2/api/recipe/IMachineRecipeManager;");
}

private static boolean isAddRecipeMethodNode(AbstractInsnNode node) {
return node instanceof MethodInsnNode && node.getOpcode() == Opcodes.INVOKEINTERFACE
&& ((MethodInsnNode) node).owner.equals("ic2/api/recipe/IMachineRecipeManager")
&& ((MethodInsnNode) node).name.equals("addRecipe")
&& ((MethodInsnNode) node).desc.equals(
"(Lic2/api/recipe/IRecipeInput;Lnet/minecraft/nbt/NBTTagCompound;[Lnet/minecraft/item/ItemStack;)V");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ public String[] targetedClasses() {
}

@Override
public ClassNode transform(ClassNode classNode) {
for (final MethodNode methodNode : classNode.methods) {
if ("addRecipies".equals(methodNode.name) || "initRecipes".equals(methodNode.name)) {
DreamCoreMod.logger
.info("Taking a sledgehammer to {}.{}{}", classNode.name, methodNode.name, methodNode.desc);
emptyTheMethodNode(methodNode);
public void transform(ClassNode classNode) {
for (final MethodNode mn : classNode.methods) {
if (("addRecipies".equals(mn.name) || "initRecipes".equals(mn.name)) && "()V".equals(mn.desc)) {
DreamCoreMod.logger.info("Taking a sledgehammer to {}.{}{}", classNode.name, mn.name, mn.desc);
emptyMethodNode(mn);
}
}
return classNode;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.dreammaster.coremod.transformers.recipenukers;

import java.util.ListIterator;

import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TypeInsnNode;

import com.dreammaster.coremod.DreamCoreMod;
import com.dreammaster.coremod.IDreamTransformer;

public class GraviSuiteTransformer implements IDreamTransformer {

@Override
public String[] targetedClasses() {
return new String[] { "gravisuite.GraviSuite" };
}

@Override
public void transform(ClassNode classNode) {
for (MethodNode mn : classNode.methods) {
if (mn.name.equals("afterModsLoaded")
&& mn.desc.equals("(Lcpw/mods/fml/common/event/FMLPostInitializationEvent;)V")) {
final ListIterator<AbstractInsnNode> it = mn.instructions.iterator();
boolean delete = false;
while (it.hasNext()) {
final AbstractInsnNode insnNode = it.next();
if (!delete && insnNode instanceof TypeInsnNode
&& insnNode.getOpcode() == Opcodes.NEW
&& ((TypeInsnNode) insnNode).desc.equals("net/minecraft/item/ItemStack")) {
delete = true;
}
if (delete) {
it.remove();
}
}
mn.instructions.add(new InsnNode(Opcodes.RETURN));
DreamCoreMod.logger.info("Taking a sledgehammer to {}.{}{}", classNode.name, mn.name, mn.desc);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public String[] targetedClasses() {
}

@Override
public ClassNode transform(ClassNode classNode) {
public void transform(ClassNode classNode) {
for (MethodNode methodNode : classNode.methods) {
if (checkMethodNode(methodNode, "init", "(Lcpw/mods/fml/common/event/FMLInitializationEvent;)V")) {
/*
Expand All @@ -45,14 +45,13 @@ public ClassNode transform(ClassNode classNode) {
classNode.name,
methodNode.name,
methodNode.desc);
return classNode;
return;
} else if (addItemCallsCount == 5) {
iterator.remove();
}
}
}
}
return classNode;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ public void run() {
GTOreDictUnificator.get(OrePrefixes.gearGt, Materials.TungstenSteel, 16L),
GTUtility.getIntegratedCircuit(2))
.itemOutputs(ItemList.OilDrill4.get(1L)).fluidInputs(Materials.SolderingAlloy.getMolten(1440))
.duration(20 * SECONDS).eut(7860).addTo(assemblerRecipes);
.duration(20 * SECONDS).eut(TierEU.RECIPE_IV).addTo(assemblerRecipes);

GTValues.RA.stdBuilder()
.itemInputs(
Expand Down Expand Up @@ -2299,7 +2299,7 @@ public void run() {
ItemList.IV_Coil.get(8L),
GTOreDictUnificator.get(OrePrefixes.wireGt02, Materials.SuperconductorIV, 16L))
.itemOutputs(ItemList.Electromagnet_Iron.get(1)).fluidInputs(Materials.Cobalt.getMolten(1152))
.duration(30 * SECONDS).eut(TierEU.IV).addTo(assemblerRecipes);
.duration(30 * SECONDS).eut(TierEU.RECIPE_IV).addTo(assemblerRecipes);

// Ultimate Time Anomaly
GTValues.RA.stdBuilder()
Expand Down Expand Up @@ -9161,7 +9161,7 @@ private void makeSolderingAlloyRecipes() {
GTUtility.getIntegratedCircuit(2))
.itemOutputs(GTModHandler.getModItem(AdvancedSolarPanel.ID, "BlockAdvSolarPanel", 1L, 3))
.fluidInputs(tMat.getMolten(1152L * tMultiplier / 2L)).duration(1 * MINUTES + 10 * SECONDS)
.eut(7860).addTo(assemblerRecipes);
.eut(TierEU.RECIPE_IV).addTo(assemblerRecipes);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static void spaceRecipes() {
.itemInputs(com.dreammaster.item.ItemList.StargateCrystalDust.getIS().splitStack(64))
.itemOutputs(GTModHandler.getModItem(SGCraft.ID, "sgCoreCrystal", 1L)).outputChances(10000)
.fluidInputs(Materials.Silver.getPlasma(8000L)).requiresCleanRoom().requiresLowGravity()
.duration(3 * MINUTES).eut(131000).addTo(autoclaveRecipes);
.duration(3 * MINUTES).eut(TierEU.RECIPE_ZPM).addTo(autoclaveRecipes);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public void run() {
ItemList.Circuit_Wafer_PIC.get(1L),
GTOreDictUnificator.get(OrePrefixes.dust, Materials.IndiumGalliumPhosphide, 2))
.itemOutputs(ItemList.Circuit_Wafer_HPIC.get(1L)).fluidInputs(Materials.VanadiumGallium.getMolten(288L))
.requiresCleanRoom().duration(60 * SECONDS).eut(7860).addTo(UniversalChemical);
.requiresCleanRoom().duration(60 * SECONDS).eut(TierEU.RECIPE_IV).addTo(UniversalChemical);

GTValues.RA.stdBuilder()
.itemInputs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public class CircuitAssemblerRecipes implements Runnable {
CustomItemList.SchematicsTier8.get(1L), };

// Rocket Circuits
public final int[] EUperRecipe = new int[] { 480, // t2 = HV
1920, // t3 = EV
7680, // t4 = IV
30720, // t5 = LuV (Gated behind Assline)
30720, // t6 = LuV
130870, // t7 = ZPM
520400, // t8 = UV
public final long[] EUperRecipe = new long[] { TierEU.RECIPE_HV, // t2 = HV
TierEU.RECIPE_EV, // t3 = EV
TierEU.RECIPE_IV, // t4 = IV
TierEU.RECIPE_LuV, // t5 = LuV (Gated behind Assline)
TierEU.RECIPE_LuV, // t6 = LuV
TierEU.RECIPE_ZPM, // t7 = ZPM
TierEU.RECIPE_UV, // t8 = UV
};

public final ItemStack[] ExtraChips = new ItemStack[] { CustomItemList.SchematicsMoonBuggy.get(1L),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public void run() {
.eut(TierEU.RECIPE_EV).addTo(cutterRecipes);

GTValues.RA.stdBuilder().itemInputs(ItemList.Circuit_Wafer_HPIC.get(1L))
.itemOutputs(ItemList.Circuit_Chip_HPIC.get(2L)).requiresCleanRoom().duration(45 * SECONDS).eut(7860)
.addTo(cutterRecipes);
.itemOutputs(ItemList.Circuit_Chip_HPIC.get(2L)).requiresCleanRoom().duration(45 * SECONDS)
.eut(TierEU.RECIPE_IV).addTo(cutterRecipes);

GTValues.RA.stdBuilder().itemInputs(ItemList.Circuit_Wafer_UHPIC.get(1L))
.itemOutputs(ItemList.Circuit_Chip_UHPIC.get(2L)).requiresCleanRoom().duration(45 * SECONDS)
Expand All @@ -83,12 +83,12 @@ public void run() {
.eut(TierEU.RECIPE_ZPM).addTo(cutterRecipes);

GTValues.RA.stdBuilder().itemInputs(ItemList.Circuit_Wafer_PPIC.get(1L))
.itemOutputs(ItemList.Circuit_Chip_PPIC.get(2L)).requiresCleanRoom().duration(45 * SECONDS).eut(500000)
.addTo(cutterRecipes);
.itemOutputs(ItemList.Circuit_Chip_PPIC.get(2L)).requiresCleanRoom().duration(45 * SECONDS)
.eut(TierEU.RECIPE_UV).addTo(cutterRecipes);

GTValues.RA.stdBuilder().itemInputs(ItemList.Circuit_Wafer_QPIC.get(1L))
.itemOutputs(ItemList.Circuit_Chip_QPIC.get(2L)).requiresCleanRoom().duration(45 * SECONDS).eut(2000000)
.addTo(cutterRecipes);
.itemOutputs(ItemList.Circuit_Chip_QPIC.get(2L)).requiresCleanRoom().duration(45 * SECONDS)
.eut(TierEU.RECIPE_UHV).addTo(cutterRecipes);

GTValues.RA.stdBuilder().itemInputs(ItemList.Circuit_Wafer_NanoCPU.get(1L))
.itemOutputs(ItemList.Circuit_Chip_NanoCPU.get(8L)).requiresCleanRoom().duration(45 * SECONDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void run() {
new ItemStack(Loaders.advancedRadiationProtectionPlate, 4, 0),
1,
50 * 20,
(int) TierEU.ZPM,
(int) TierEU.RECIPE_ZPM,
null,
null);

Expand Down
Loading

0 comments on commit 8f28769

Please sign in to comment.