Created
March 7, 2016 18:46
-
-
Save Unh0lyTigg/24a50e34514035fd4e2f to your computer and use it in GitHub Desktop.
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
ClassNode node = createNode(basicClass); | |
boolean change = false; | |
for (MethodNode method : node.methods) { | |
if ("<init>".equals(method.name)) { | |
InsnList instructions = method.instructions; | |
AbstractInsnNode needle = instructions.getLast(); | |
do { | |
needle = needle.getPrevious(); | |
} while (needle.getOpcode() != RETURN); | |
MethodNode mn = new MethodNode(); | |
mn.visitVarInsn(ALOAD, 0); | |
mn.visitMethodInsn(INVOKESTATIC, "xyc/unh0lytigg/jsoncrops/hooks/JCHooks", "WorldOnLoad", "(Lnet/minecraft/world/World;)V", false); | |
instructions.insertBefore(needle, instructions); | |
change = true; | |
} | |
} | |
return change ? writeNode(node) : basicClass; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment