Package org.objectweb.asm.tree

Examples of org.objectweb.asm.tree.VarInsnNode


     
      if (m.name.equals(names.get("netServerHandler_handleUpdateSign_func")) && m.desc.equals(names.get("netServerHandler_handleUpdateSign_desc"))) {
        System.out.println("Found target method in NetServerHandler: " + m.name + m.desc);
       
        InsnList insns = new InsnList();
        insns.add(new VarInsnNode(Opcodes.ALOAD, 0));
        insns.add(new VarInsnNode(Opcodes.ALOAD, 1));
        insns.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "keepcalm/mods/events/ForgeEventHelper", "onSignChange", "(L" + names.get("netServerHandler_javaName") + ";L" + names.get("packet130UpdateSign_javaName") + ";)L" + names.get("packet130UpdateSign_javaName") + ";" ));
        LabelNode endIf = new LabelNode(new Label());
        insns.add(new VarInsnNode(Opcodes.ASTORE, 1));
        insns.add(new VarInsnNode(Opcodes.ALOAD, 1));
        insns.add(new JumpInsnNode(Opcodes.IFNONNULL, endIf));
        insns.add(new InsnNode(Opcodes.RETURN));
        insns.add(endIf);
       
        m.instructions.insert(insns);
View Full Code Here


              // insert!
              i++;
              System.out.println("Found second IFNE node from the end, inserting code...");
              InsnList insns = new InsnList();
             
              insns.add(new VarInsnNode(Opcodes.ALOAD, 0));
              insns.add(new VarInsnNode(Opcodes.ALOAD, 1));
              insns.add(new VarInsnNode(Opcodes.ILOAD, 2));
              insns.add(new VarInsnNode(Opcodes.ILOAD, 3));
              insns.add(new VarInsnNode(Opcodes.ILOAD, 4));
              insns.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "keepcalm/mods/events/ForgeEventHelper",
                  "onPressurePlateInteract", "(L" + names.get("blockPressurePlate_javaName") + ";L" + names.get("world_javaName") + ";III)Z"));
              LabelNode endIf = new LabelNode(new Label());
              insns.add(new JumpInsnNode(Opcodes.IFEQ, endIf));
              insns.add(new InsnNode(Opcodes.RETURN));
View Full Code Here

        System.out.println("Found target method: " + m.name + m.desc + "!");
       
       
        InsnList toAdd = new InsnList();
       
        toAdd.add(new VarInsnNode(Opcodes.ALOAD, 0));
        toAdd.add(new VarInsnNode(Opcodes.ALOAD, 1));
        toAdd.add(new VarInsnNode(Opcodes.ILOAD, 2));
        toAdd.add(new VarInsnNode(Opcodes.ILOAD, 3));
        toAdd.add(new VarInsnNode(Opcodes.ILOAD, 4));///
        toAdd.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
            "keepcalm/mods/events/ForgeEventHelper", "onBlockFlow",
            "(L" + names.get("block_javaName") + ";L" + names.get("world_javaName") + ";III)Z"));
        LabelNode endIf = new LabelNode(new Label());
        toAdd.add(new JumpInsnNode(Opcodes.IFEQ, endIf));
View Full Code Here

       
        InsnList toAdd = new InsnList();
       
        LabelNode lmmnode = new LabelNode(new Label());
       
        toAdd.add(new VarInsnNode(Opcodes.ALOAD, 1));
        toAdd.add(new VarInsnNode(Opcodes.ILOAD, 2));
        toAdd.add(new VarInsnNode(Opcodes.ILOAD, 3));
        toAdd.add(new VarInsnNode(Opcodes.ILOAD, 4));
        toAdd.add(new VarInsnNode(Opcodes.ILOAD, 5));
        toAdd.add(new VarInsnNode(Opcodes.ILOAD, 6));
        toAdd.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "keepcalm/mods/events/ForgeEventHelper", "onBlockBreak", "(L" + names.get("world_javaName") + ";IIIII)V"));
        toAdd.add(lmmnode);
        // insert at the beginning
        m.instructions.insert(toAdd);
        System.out.println("Inserted instructions!");
View Full Code Here

            InsnList toAdd = new InsnList();

            // mark end of our code
            LabelNode lmmnode = new LabelNode(new Label());
            // we want 1, 2, 3, 4, 8 - world, x, y, z, ItemStack
            toAdd.add(new VarInsnNode(Opcodes.ALOAD, 1));
            toAdd.add(new VarInsnNode(Opcodes.ILOAD, 2));
            toAdd.add(new VarInsnNode(Opcodes.ILOAD, 3));
            toAdd.add(new VarInsnNode(Opcodes.ILOAD, 4));
            toAdd.add(new VarInsnNode(Opcodes.ALOAD, 8));
            toAdd.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "keepcalm/mods/events/ForgeEventHelper", "onDispenseItem",
                "(L" + names.get("world_javaName") + ";IIIL" + names.get("itemStack_javaName") + ";)Z"));

            LabelNode endLabel = new LabelNode(new Label());
            toAdd.add(new JumpInsnNode(Opcodes.IFEQ, endLabel)); // if the return value of ^ is true
View Full Code Here

            toInject.add(new FieldInsnNode(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"));
            toInject.add(new VarInsnNode(Opcodes.ALOAD, 1));
            toInject.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/Object;)V"));*/
            LabelNode lmmnode = new LabelNode(new Label());
            // this
            toInject.add(new VarInsnNode(Opcodes.ALOAD, 0));
            // entityplayer
            toInject.add(new VarInsnNode(Opcodes.ALOAD, 1));
            // world
            toInject.add(new VarInsnNode(Opcodes.ALOAD, 2));
            // x y z direction
            toInject.add(new VarInsnNode(Opcodes.ILOAD, 3));
            toInject.add(new VarInsnNode(Opcodes.ILOAD, 4));
            toInject.add(new VarInsnNode(Opcodes.ILOAD, 5));
            toInject.add(new VarInsnNode(Opcodes.ILOAD, 6));
            toInject.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "keepcalm/mods/events/ForgeEventHelper", "onItemUse", String.format("(L%s;L%s;L%s;IIII)V", new Object[] {names.get("itemStack_javaName"), names.get("entityPlayer_javaName"), names.get("world_javaName")})));
            toInject.add(lmmnode);
            m.instructions.insertBefore(m.instructions.get(index), toInject);
            //System.out.println("Used desc: " + String.format("(L%s;L%s;L%s;IIII)V", new Object[] {names.get("itemStackJavaName"), names.get("entityPlayerJavaName"), names.get("worldJavaName")}));
            System.out.println("Finished patching ItemStack! - Inserted before " + index + ", toInject: " + toInject);
View Full Code Here

            LabelNode lmmnode = new LabelNode(new Label());

            InsnList toInject = new InsnList();

            // load 'this'
            toInject.add(new VarInsnNode(Opcodes.ALOAD, 0));
            // call the helper method
            System.out.println("Using desc: " + "(L" + names.get("itemInWorldManager_javaName") + ";)V");
            toInject.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "keepcalm/mods/events/ForgeEventHelper",
                "onBlockDamage", "(L" + names.get("itemInWorldManager_javaName") + ";)Z"));
            LabelNode endIf = new LabelNode(new Label());
View Full Code Here

     
      if (m.name.equals(names.get("netServerHandler_handleFlying_func")) && m.desc.equals(names.get("netServerHandler_handleFlying_desc"))) {
        System.out.println("Found target method: " + m.name + m.desc + "! Inserting code...");
       
        InsnList toInsert = new InsnList();
        toInsert.add(new VarInsnNode(Opcodes.ALOAD, 1));
        toInsert.add(new VarInsnNode(Opcodes.ALOAD, 0));
        toInsert.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "keepcalm/mods/events/ForgeEventHelper", "onPlayerMove",
            "(L" + names.get("packet10Flying_javaName") + ";L" + names.get("netServerHandler_javaName") + ";)Z"));
        LabelNode endIf = new LabelNode(new Label());
        toInsert.add(new JumpInsnNode(Opcodes.IFEQ, endIf));
        toInsert.add(new InsnNode(Opcodes.RETURN));
View Full Code Here

            InsnList toAdd = new InsnList();
           
            // to mark the end of the code
            LabelNode lmmnode = new LabelNode(new Label());
            // load this
            toAdd.add(new VarInsnNode(Opcodes.ALOAD, 0));
            // new fleece colour
            toAdd.add(new VarInsnNode(Opcodes.ILOAD, 1));
            // old fleece colour
            toAdd.add(new VarInsnNode(Opcodes.ILOAD, 2));
            toAdd.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "keepcalm/mods/events/ForgeEventHelper", "onSheepDye", "(L" + names.get("entitySheep_javaName") + ";II)Z"));
            LabelNode endIf = new LabelNode(new Label());
            toAdd.add(new JumpInsnNode(Opcodes.IFEQ, endIf));
            toAdd.add(new InsnNode(Opcodes.RETURN));
            toAdd.add(endIf);
View Full Code Here

            System.out.println("Found insertion point! inserting code!");
            i++;
           
            InsnList insns = new InsnList();
           
            insns.add(new VarInsnNode(Opcodes.ALOAD, 0));
            insns.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "keepcalm/mods/events/ForgeEventHelper", "onCreeperExplode", "(L" + names.get("entityCreeper_javaName") + ";)Z"));
            LabelNode endIf = new LabelNode(new Label());
            insns.add(new JumpInsnNode(Opcodes.IFEQ, endIf));
            //insns.add(new VarInsnNode(Opcodes.ALOAD, 0));
            //insns.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, names.get("entityCreeper_javaName"), names.get("entityCreeper_setDead_func"), names.get("entityCreeper_setDead_desc")));
View Full Code Here

TOP

Related Classes of org.objectweb.asm.tree.VarInsnNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.