Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private byte[] transformCommandBroadcast(byte[] byteCode) {
- ClassNode classNode = new ClassNode();
- ClassReader classReader = new ClassReader(byteCode);
- classReader.accept(classNode, 0);
- for (MethodNode m : classNode.methods)
- if (m.name.equals("processCommand") || m.name.equals("func_71515_b")) {
- Iterator<AbstractInsnNode> nodes = m.instructions.iterator();
- int opCount = 0;
- while (nodes.hasNext()) {
- AbstractInsnNode node = nodes.next();
- if (node.getOpcode() == INVOKEVIRTUAL && opCount < 2)
- opCount++;
- else if (node.getOpcode() == INVOKEVIRTUAL && opCount == 2){
- InsnList instructions = new InsnList();
- instructions.add(new VarInsnNode(ALOAD, 1));
- instructions.add(new VarInsnNode(ALOAD, 3));
- instructions.add(new MethodInsnNode(INVOKESTATIC, "com/austinv11/collectiveframework/minecraft/hooks/CommonHooks", "onCommandBroadcast", "(Lnet/minecraft/command/ICommandSender;Lnet.minecraft.util.IChatComponent;)V", false));
- m.instructions.insert(node, instructions);
- break;
- }
- }
- }
- ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
- classNode.accept(writer);
- return writer.toByteArray();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement