Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Unh0lyTigg/24a50e34514035fd4e2f to your computer and use it in GitHub Desktop.
Save Unh0lyTigg/24a50e34514035fd4e2f to your computer and use it in GitHub Desktop.
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