Search in sources :

Example 46 with MethodNode

use of org.objectweb.asm.tree.MethodNode in project Random-Things by lumien231.

the class ClassTransformer method patchEntityLivingBase.

private byte[] patchEntityLivingBase(byte[] basicClass) {
    ClassNode classNode = new ClassNode();
    ClassReader classReader = new ClassReader(basicClass);
    classReader.accept(classNode, 0);
    logger.log(Level.DEBUG, "Found EntityLivingBase Class: " + classNode.name);
    MethodNode updatePotionEffects = null;
    MethodNode travel = null;
    for (MethodNode mn : classNode.methods) {
        if (mn.name.equals(MCPNames.method("func_70679_bo"))) {
            updatePotionEffects = mn;
        } else if (mn.name.equals(MCPNames.method("func_191986_a"))) {
            travel = mn;
        }
    }
    if (updatePotionEffects != null) {
        logger.log(Level.DEBUG, "- Found updatePotionEffects (1/2)");
        for (int i = 0; i < updatePotionEffects.instructions.size(); i++) {
            AbstractInsnNode ain = updatePotionEffects.instructions.get(i);
            if (ain instanceof FieldInsnNode) {
                FieldInsnNode fin = (FieldInsnNode) ain;
                if (fin.name.equals(MCPNames.field("field_70180_af"))) {
                    AbstractInsnNode aload = updatePotionEffects.instructions.get(i - 1);
                    InsnList toInsert = new InsnList();
                    LabelNode l1 = new LabelNode(new Label());
                    toInsert.add(new VarInsnNode(ALOAD, 0));
                    toInsert.add(new MethodInsnNode(INVOKESTATIC, asmHandler, "shouldRenderPotionParticles", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false));
                    toInsert.add(new JumpInsnNode(IFGT, l1));
                    toInsert.add(new InsnNode(RETURN));
                    toInsert.add(l1);
                    updatePotionEffects.instructions.insertBefore(aload, toInsert);
                    break;
                }
            }
        }
    }
    if (travel != null) {
        logger.log(Level.DEBUG, "- Found travel (2/2)");
        for (int i = 0; i < travel.instructions.size(); i++) {
            AbstractInsnNode ain = travel.instructions.get(i);
            if (ain instanceof LdcInsnNode) {
                LdcInsnNode lin = (LdcInsnNode) ain;
                if (lin.cst.equals(new Float("0.91"))) {
                    AbstractInsnNode next = travel.instructions.get(i + 1);
                    if (next.getOpcode() == Opcodes.FMUL) {
                        InsnList toInsert = new InsnList();
                        toInsert.add(new VarInsnNode(ALOAD, 0));
                        toInsert.add(new VarInsnNode(ALOAD, 0));
                        toInsert.add(new FieldInsnNode(GETFIELD, "net/minecraft/entity/EntityLivingBase", MCPNames.field("field_70170_p"), "Lnet/minecraft/world/World;"));
                        toInsert.add(new VarInsnNode(ALOAD, 5));
                        toInsert.add(new MethodInsnNode(INVOKEVIRTUAL, "net/minecraft/world/World", MCPNames.method("func_180495_p"), "(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/state/IBlockState;", false));
                        toInsert.add(new MethodInsnNode(INVOKEINTERFACE, "net/minecraft/block/state/IBlockState", MCPNames.method("func_177230_c"), "()Lnet/minecraft/block/Block;", true));
                        toInsert.add(new MethodInsnNode(INVOKESTATIC, asmHandler, "slipFix", "(FLnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/block/Block;)F", false));
                        travel.instructions.insert(next, toInsert);
                        i += 6;
                    }
                }
            }
        }
    }
    CustomClassWriter writer = new CustomClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
    classNode.accept(writer);
    return writer.toByteArray();
}
Also used : LabelNode(org.objectweb.asm.tree.LabelNode) ClassNode(org.objectweb.asm.tree.ClassNode) Label(org.objectweb.asm.Label) FieldInsnNode(org.objectweb.asm.tree.FieldInsnNode) AbstractInsnNode(org.objectweb.asm.tree.AbstractInsnNode) InsnList(org.objectweb.asm.tree.InsnList) FieldInsnNode(org.objectweb.asm.tree.FieldInsnNode) VarInsnNode(org.objectweb.asm.tree.VarInsnNode) MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) TypeInsnNode(org.objectweb.asm.tree.TypeInsnNode) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode) LdcInsnNode(org.objectweb.asm.tree.LdcInsnNode) AbstractInsnNode(org.objectweb.asm.tree.AbstractInsnNode) InsnNode(org.objectweb.asm.tree.InsnNode) LdcInsnNode(org.objectweb.asm.tree.LdcInsnNode) MethodNode(org.objectweb.asm.tree.MethodNode) MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) ClassReader(org.objectweb.asm.ClassReader) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode) VarInsnNode(org.objectweb.asm.tree.VarInsnNode)

Example 47 with MethodNode

use of org.objectweb.asm.tree.MethodNode in project Random-Things by lumien231.

the class ClassTransformer method patchEntitySlime.

private byte[] patchEntitySlime(byte[] basicClass) {
    ClassNode classNode = new ClassNode();
    ClassReader classReader = new ClassReader(basicClass);
    classReader.accept(classNode, 0);
    logger.log(Level.DEBUG, "Found EntitySlime Class: " + classNode.name);
    MethodNode getCanSpawnHere = null;
    for (MethodNode mn : classNode.methods) {
        if (mn.name.equals(MCPNames.method("func_70601_bi"))) {
            getCanSpawnHere = mn;
            break;
        }
    }
    if (getCanSpawnHere != null) {
        logger.log(Level.DEBUG, " - Found getCanSpawnHere");
        for (int i = 0; i < getCanSpawnHere.instructions.size(); i++) {
            AbstractInsnNode ain = getCanSpawnHere.instructions.get(i);
            if (ain instanceof FieldInsnNode) {
                FieldInsnNode fin = (FieldInsnNode) ain;
                if (fin.name.equals("PEACEFUL")) {
                    logger.log(Level.DEBUG, " - Found Insertion Point");
                    AbstractInsnNode skip = getCanSpawnHere.instructions.get(i + 1);
                    LabelNode l0 = new LabelNode(new Label());
                    InsnList toInsert = new InsnList();
                    toInsert.add(new VarInsnNode(ALOAD, 0));
                    toInsert.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/entity/monster/EntitySlime", MCPNames.field("field_70170_p"), "Lnet/minecraft/world/World;"));
                    toInsert.add(new VarInsnNode(ALOAD, 2));
                    toInsert.add(new MethodInsnNode(INVOKESTATIC, asmHandler, "overrideSlimeChunk", "(Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/Chunk;)I", false));
                    toInsert.add(new InsnNode(DUP));
                    toInsert.add(new JumpInsnNode(IFLT, l0));
                    toInsert.add(new InsnNode(IRETURN));
                    toInsert.add(l0);
                    toInsert.add(new InsnNode(POP));
                    getCanSpawnHere.instructions.insert(skip, toInsert);
                }
            }
        }
    }
    CustomClassWriter writer = new CustomClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
    classNode.accept(writer);
    return writer.toByteArray();
}
Also used : LabelNode(org.objectweb.asm.tree.LabelNode) ClassNode(org.objectweb.asm.tree.ClassNode) Label(org.objectweb.asm.Label) FieldInsnNode(org.objectweb.asm.tree.FieldInsnNode) AbstractInsnNode(org.objectweb.asm.tree.AbstractInsnNode) InsnList(org.objectweb.asm.tree.InsnList) FieldInsnNode(org.objectweb.asm.tree.FieldInsnNode) VarInsnNode(org.objectweb.asm.tree.VarInsnNode) MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) TypeInsnNode(org.objectweb.asm.tree.TypeInsnNode) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode) LdcInsnNode(org.objectweb.asm.tree.LdcInsnNode) AbstractInsnNode(org.objectweb.asm.tree.AbstractInsnNode) InsnNode(org.objectweb.asm.tree.InsnNode) MethodNode(org.objectweb.asm.tree.MethodNode) MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) ClassReader(org.objectweb.asm.ClassReader) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode) VarInsnNode(org.objectweb.asm.tree.VarInsnNode)

Example 48 with MethodNode

use of org.objectweb.asm.tree.MethodNode in project Random-Things by lumien231.

the class ClassTransformer method patchRenderItem.

private byte[] patchRenderItem(byte[] basicClass) {
    ClassNode classNode = new ClassNode();
    ClassReader classReader = new ClassReader(basicClass);
    classReader.accept(classNode, 0);
    logger.log(Level.DEBUG, "Found RenderItem Class: " + classNode.name);
    MethodNode renderEffect = null;
    MethodNode renderItem = null;
    MethodNode renderQuads = null;
    for (MethodNode mn : classNode.methods) {
        if (mn.name.equals(MCPNames.method("func_191966_a"))) {
            renderEffect = mn;
        } else if (mn.name.equals(MCPNames.method("func_180454_a")) && mn.desc.equals("(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/renderer/block/model/IBakedModel;)V")) {
            renderItem = mn;
        } else if (mn.name.equals(MCPNames.method("func_191970_a"))) {
            renderQuads = mn;
        }
    }
    if (renderEffect != null) {
        logger.log(Level.DEBUG, "- Found renderEffect (1/3)");
        renderEffect.instructions.insert(new MethodInsnNode(INVOKESTATIC, asmHandler, "preEnchantment", "()V", false));
        for (int i = 0; i < renderEffect.instructions.size(); i++) {
            AbstractInsnNode ain = renderEffect.instructions.get(i);
            if (ain instanceof LdcInsnNode) {
                LdcInsnNode lin = (LdcInsnNode) ain;
                if (lin.cst.equals(new Integer(-8372020))) {
                    logger.log(Level.DEBUG, "- Found Texture Binding");
                    renderEffect.instructions.insert(lin, new MethodInsnNode(INVOKESTATIC, asmHandler, "enchantmentColorHook", "(I)I", false));
                }
            } else if (ain.getOpcode() == RETURN) {
                renderEffect.instructions.insertBefore(ain, new MethodInsnNode(INVOKESTATIC, asmHandler, "postEnchantment", "()V", false));
                i++;
            }
        }
    }
    if (renderItem != null) {
        boolean found = false;
        logger.log(Level.DEBUG, "- Found renderItem (2/3) (" + renderItem.desc + ")");
        for (int i = 0; i < renderItem.instructions.size(); i++) {
            AbstractInsnNode ain = renderItem.instructions.get(i);
            if (ain instanceof MethodInsnNode) {
                MethodInsnNode min = (MethodInsnNode) ain;
                if (!found) {
                    if (min.name.equals(MCPNames.method("func_191966_a"))) {
                        logger.log(Level.DEBUG, "- Found renderEffect calling");
                        InsnList toInsert = new InsnList();
                        toInsert.add(new VarInsnNode(ALOAD, 1));
                        toInsert.add(new FieldInsnNode(PUTSTATIC, asmHandler, "currentlyRendering", "Lnet/minecraft/item/ItemStack;"));
                        renderItem.instructions.insertBefore(min, toInsert);
                        toInsert = new InsnList();
                        toInsert.add(new InsnNode(ACONST_NULL));
                        toInsert.add(new FieldInsnNode(PUTSTATIC, asmHandler, "currentlyRendering", "Lnet/minecraft/item/ItemStack;"));
                        renderItem.instructions.insert(min, toInsert);
                        found = true;
                    }
                }
                if (min.name.equals(MCPNames.method("func_179022_a"))) {
                    LabelNode l1 = new LabelNode(new Label());
                    LabelNode l2 = new LabelNode(new Label());
                    logger.log(Level.DEBUG, "- Inserting TE Item Renderer");
                    InsnList insertBefore = new InsnList();
                    insertBefore.add(new FieldInsnNode(GETSTATIC, "lumien/randomthings/client/RandomThingsTEItemRenderer", "instance", "Llumien/randomthings/client/RandomThingsTEItemRenderer;"));
                    insertBefore.add(new VarInsnNode(ALOAD, 1));
                    insertBefore.add(new MethodInsnNode(INVOKEVIRTUAL, "lumien/randomthings/client/RandomThingsTEItemRenderer", "renderByItem", "(Lnet/minecraft/item/ItemStack;)Z", false));
                    insertBefore.add(new JumpInsnNode(IFEQ, l2));
                    insertBefore.add(new InsnNode(POP));
                    insertBefore.add(new InsnNode(POP));
                    insertBefore.add(new JumpInsnNode(GOTO, l1));
                    insertBefore.add(l2);
                    InsnList insertAfter = new InsnList();
                    insertAfter.add(l1);
                    renderItem.instructions.insertBefore(min, insertBefore);
                    renderItem.instructions.insert(min, insertAfter);
                    i += 8;
                }
            }
        }
    }
    if (renderQuads != null) {
        logger.log(Level.DEBUG, "- Found renderQuads (3/3) (" + renderQuads.desc + ")");
        String luminousHandler = "lumien/randomthings/handler/LuminousHandler";
        InsnList startInsrt = new InsnList();
        startInsrt.add(new VarInsnNode(ALOAD, 4));
        startInsrt.add(new VarInsnNode(ALOAD, 1));
        startInsrt.add(new MethodInsnNode(INVOKESTATIC, luminousHandler, "luminousHookStart", "(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/renderer/BufferBuilder;)V", false));
        renderQuads.instructions.insert(startInsrt);
        for (int i = 0; i < renderQuads.instructions.size(); i++) {
            AbstractInsnNode ain = renderQuads.instructions.get(i);
            if (ain instanceof MethodInsnNode) {
                MethodInsnNode min = (MethodInsnNode) ain;
                if (min.name.equals("renderQuadColor")) {
                    InsnList toInsert = new InsnList();
                    toInsert.add(new VarInsnNode(ALOAD, 8));
                    toInsert.add(new MethodInsnNode(INVOKEVIRTUAL, "net/minecraft/client/renderer/block/model/BakedQuad", MCPNames.method("func_178211_c"), "()I", false));
                    toInsert.add(new MethodInsnNode(INVOKESTATIC, luminousHandler, "luminousHookPre", "(I)V", false));
                    toInsert.add(new InsnNode(POP));
                    toInsert.add(new VarInsnNode(ALOAD, 4));
                    toInsert.add(new VarInsnNode(ILOAD, 9));
                    toInsert.add(new MethodInsnNode(INVOKESTATIC, asmHandler, "getColorFromItemStack", "(Lnet/minecraft/item/ItemStack;I)I", false));
                    renderQuads.instructions.insertBefore(min, toInsert);
                    i += 7;
                    renderQuads.instructions.insert(min, new MethodInsnNode(INVOKESTATIC, luminousHandler, "luminousHookPost", "()V", false));
                }
            } else if (ain.getOpcode() == RETURN) {
                renderQuads.instructions.insertBefore(ain, new MethodInsnNode(INVOKESTATIC, luminousHandler, "luminousHookEnd", "()V", false));
                i++;
            }
        }
    }
    CustomClassWriter writer = new CustomClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
    classNode.accept(writer);
    return writer.toByteArray();
}
Also used : LabelNode(org.objectweb.asm.tree.LabelNode) ClassNode(org.objectweb.asm.tree.ClassNode) Label(org.objectweb.asm.Label) FieldInsnNode(org.objectweb.asm.tree.FieldInsnNode) AbstractInsnNode(org.objectweb.asm.tree.AbstractInsnNode) InsnList(org.objectweb.asm.tree.InsnList) FieldInsnNode(org.objectweb.asm.tree.FieldInsnNode) VarInsnNode(org.objectweb.asm.tree.VarInsnNode) MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) TypeInsnNode(org.objectweb.asm.tree.TypeInsnNode) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode) LdcInsnNode(org.objectweb.asm.tree.LdcInsnNode) AbstractInsnNode(org.objectweb.asm.tree.AbstractInsnNode) InsnNode(org.objectweb.asm.tree.InsnNode) LdcInsnNode(org.objectweb.asm.tree.LdcInsnNode) MethodNode(org.objectweb.asm.tree.MethodNode) MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) ClassReader(org.objectweb.asm.ClassReader) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode) VarInsnNode(org.objectweb.asm.tree.VarInsnNode)

Example 49 with MethodNode

use of org.objectweb.asm.tree.MethodNode in project Random-Things by lumien231.

the class ClassTransformer method patchBlock.

private byte[] patchBlock(byte[] basicClass) {
    ClassNode classNode = new ClassNode();
    ClassReader classReader = new ClassReader(basicClass);
    classReader.accept(classNode, 0);
    logger.log(Level.DEBUG, "Found Block Class: " + classNode.name);
    MethodNode addCollisionBoxesToList = null;
    for (MethodNode mn : classNode.methods) {
        if (mn.name.equals(MCPNames.method("func_185477_a")) && mn.desc.equals("(Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/AxisAlignedBB;Ljava/util/List;Lnet/minecraft/entity/Entity;Z)V")) {
            addCollisionBoxesToList = mn;
        }
    }
    if (addCollisionBoxesToList != null) {
        logger.log(Level.DEBUG, "- Found addCollisionBoxesToList (1/1)");
        InsnList toInsert = new InsnList();
        LabelNode l1 = new LabelNode(new Label());
        toInsert.add(new VarInsnNode(ALOAD, 1));
        toInsert.add(new VarInsnNode(ALOAD, 2));
        toInsert.add(new VarInsnNode(ALOAD, 3));
        toInsert.add(new VarInsnNode(ALOAD, 4));
        toInsert.add(new VarInsnNode(ALOAD, 5));
        toInsert.add(new VarInsnNode(ALOAD, 6));
        toInsert.add(new MethodInsnNode(INVOKESTATIC, asmHandler, "addCollisionBoxesToList", "(Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/AxisAlignedBB;Ljava/util/List;Lnet/minecraft/entity/Entity;)Z", false));
        toInsert.add(new JumpInsnNode(IFEQ, l1));
        toInsert.add(new InsnNode(RETURN));
        toInsert.add(l1);
        addCollisionBoxesToList.instructions.insert(toInsert);
    }
    CustomClassWriter writer = new CustomClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
    classNode.accept(writer);
    return writer.toByteArray();
}
Also used : LabelNode(org.objectweb.asm.tree.LabelNode) ClassNode(org.objectweb.asm.tree.ClassNode) FieldInsnNode(org.objectweb.asm.tree.FieldInsnNode) VarInsnNode(org.objectweb.asm.tree.VarInsnNode) MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) TypeInsnNode(org.objectweb.asm.tree.TypeInsnNode) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode) LdcInsnNode(org.objectweb.asm.tree.LdcInsnNode) AbstractInsnNode(org.objectweb.asm.tree.AbstractInsnNode) InsnNode(org.objectweb.asm.tree.InsnNode) MethodNode(org.objectweb.asm.tree.MethodNode) MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) Label(org.objectweb.asm.Label) ClassReader(org.objectweb.asm.ClassReader) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode) InsnList(org.objectweb.asm.tree.InsnList) VarInsnNode(org.objectweb.asm.tree.VarInsnNode)

Example 50 with MethodNode

use of org.objectweb.asm.tree.MethodNode in project Random-Things by lumien231.

the class ClassTransformer method patchLayerArmorBase.

private byte[] patchLayerArmorBase(byte[] basicClass) {
    ClassNode classNode = new ClassNode();
    ClassReader classReader = new ClassReader(basicClass);
    classReader.accept(classNode, 0);
    logger.log(Level.DEBUG, "Found LayerArmorBase Class: " + classNode.name);
    // Where the effect is rendered
    MethodNode renderEnchantedGlint = null;
    // Getting ItemStack from here
    MethodNode renderArmorLayer = null;
    for (MethodNode mn : classNode.methods) {
        if (mn.name.equals(MCPNames.method("func_188364_a"))) {
            renderEnchantedGlint = mn;
        } else if (mn.name.equals(MCPNames.method("func_188361_a"))) {
            renderArmorLayer = mn;
        }
    }
    if (renderEnchantedGlint != null) {
        logger.log(Level.DEBUG, "- Found renderEnchantedGlint (Effect Rendering 1/2)");
        renderEnchantedGlint.instructions.insert(new MethodInsnNode(INVOKESTATIC, asmHandler, "preEnchantment", "()V", false));
        for (int i = 0; i < renderEnchantedGlint.instructions.size(); i++) {
            AbstractInsnNode ain = renderEnchantedGlint.instructions.get(i);
            if (ain instanceof MethodInsnNode) {
                MethodInsnNode min = (MethodInsnNode) ain;
                if (min.owner.equals("net/minecraft/client/renderer/GlStateManager") && min.name.equals(MCPNames.method("func_179131_c"))) {
                    renderEnchantedGlint.instructions.insert(min, new MethodInsnNode(INVOKESTATIC, asmHandler, "armorEnchantmentHook", "()V", false));
                }
            } else if (ain.getOpcode() == RETURN) {
                renderEnchantedGlint.instructions.insertBefore(ain, new MethodInsnNode(INVOKESTATIC, asmHandler, "postEnchantment", "()V", false));
                i++;
            }
        }
    }
    int renderCounter = 0;
    if (renderArmorLayer != null) {
        logger.log(Level.DEBUG, "- Found renderArmorLayer (ItemStack Information & Armor Coloring 2/2)");
        for (int i = 0; i < renderArmorLayer.instructions.size(); i++) {
            AbstractInsnNode ain = renderArmorLayer.instructions.get(i);
            if (ain instanceof MethodInsnNode) {
                MethodInsnNode min = (MethodInsnNode) ain;
                if (min.name.equals(MCPNames.method("func_188364_a"))) {
                    logger.log(Level.DEBUG, "- Set currentlyRendering");
                    InsnList toInsert = new InsnList();
                    toInsert.add(new VarInsnNode(ALOAD, 10));
                    toInsert.add(new FieldInsnNode(PUTSTATIC, asmHandler, "currentlyRendering", "Lnet/minecraft/item/ItemStack;"));
                    renderArmorLayer.instructions.insertBefore(min, toInsert);
                    toInsert = new InsnList();
                    toInsert.add(new InsnNode(ACONST_NULL));
                    toInsert.add(new FieldInsnNode(PUTSTATIC, asmHandler, "currentlyRendering", "Lnet/minecraft/item/ItemStack;"));
                    renderArmorLayer.instructions.insert(min, toInsert);
                    i += 2;
                }
                if (min.name.equals(MCPNames.method("func_78088_a"))) {
                    if (renderCounter == 1) {
                        logger.log(Level.DEBUG, "- Found render");
                        InsnList toInsert = new InsnList();
                        toInsert.add(new VarInsnNode(ALOAD, 10));
                        toInsert.add(new MethodInsnNode(INVOKESTATIC, asmHandler, "armorColorHook", "(Lnet/minecraft/item/ItemStack;)V", false));
                        renderArmorLayer.instructions.insertBefore(min, toInsert);
                    }
                    renderCounter++;
                }
            }
        }
    }
    CustomClassWriter writer = new CustomClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
    classNode.accept(writer);
    return writer.toByteArray();
}
Also used : ClassNode(org.objectweb.asm.tree.ClassNode) FieldInsnNode(org.objectweb.asm.tree.FieldInsnNode) VarInsnNode(org.objectweb.asm.tree.VarInsnNode) MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) TypeInsnNode(org.objectweb.asm.tree.TypeInsnNode) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode) LdcInsnNode(org.objectweb.asm.tree.LdcInsnNode) AbstractInsnNode(org.objectweb.asm.tree.AbstractInsnNode) InsnNode(org.objectweb.asm.tree.InsnNode) MethodNode(org.objectweb.asm.tree.MethodNode) MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) ClassReader(org.objectweb.asm.ClassReader) FieldInsnNode(org.objectweb.asm.tree.FieldInsnNode) AbstractInsnNode(org.objectweb.asm.tree.AbstractInsnNode) InsnList(org.objectweb.asm.tree.InsnList) VarInsnNode(org.objectweb.asm.tree.VarInsnNode)

Aggregations

MethodNode (org.objectweb.asm.tree.MethodNode)322 ClassNode (org.objectweb.asm.tree.ClassNode)123 Test (org.junit.Test)94 AbstractInsnNode (org.objectweb.asm.tree.AbstractInsnNode)59 ClassReader (org.objectweb.asm.ClassReader)57 InsnList (org.objectweb.asm.tree.InsnList)49 MethodInsnNode (org.objectweb.asm.tree.MethodInsnNode)47 Label (org.objectweb.asm.Label)44 VarInsnNode (org.objectweb.asm.tree.VarInsnNode)41 InsnNode (org.objectweb.asm.tree.InsnNode)34 ClassWriter (org.objectweb.asm.ClassWriter)26 FieldNode (org.objectweb.asm.tree.FieldNode)26 JumpInsnNode (org.objectweb.asm.tree.JumpInsnNode)26 ArrayList (java.util.ArrayList)24 FieldInsnNode (org.objectweb.asm.tree.FieldInsnNode)24 LdcInsnNode (org.objectweb.asm.tree.LdcInsnNode)21 LabelNode (org.objectweb.asm.tree.LabelNode)19 TypeInsnNode (org.objectweb.asm.tree.TypeInsnNode)19 List (java.util.List)17 Type (org.objectweb.asm.Type)17