-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/indiumbee' into indiumbee
- Loading branch information
Showing
7 changed files
with
157 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...java/com/dreammaster/coremod/transformers/recipenukers/AdvancedSolarPanelTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/com/dreammaster/coremod/transformers/recipenukers/GraviSuiteTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters