Example usage for org.objectweb.asm Opcodes IFEQ

List of usage examples for org.objectweb.asm Opcodes IFEQ

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes IFEQ.

Prototype

int IFEQ

To view the source code for org.objectweb.asm Opcodes IFEQ.

Click Source Link

Usage

From source file:vazkii.quark.base.asm.ClassTransformer.java

License:Creative Commons License

private static byte[] transformRender(byte[] basicClass) {
    log("Transforming Render");

    MethodSignature sig = new MethodSignature("renderEntityOnFire", "func_76977_a", "a",
            "(Lnet/minecraft/entity/Entity;DDDF)V");

    return transform(basicClass, Pair.of(sig, combine((AbstractInsnNode node) -> { // Filter
        return true;
    }, (MethodNode method, AbstractInsnNode node) -> { // Action
        InsnList newInstructions = new InsnList();

        newInstructions.add(new VarInsnNode(Opcodes.ALOAD, 1));
        newInstructions.add(new VarInsnNode(Opcodes.DLOAD, 2));
        newInstructions.add(new VarInsnNode(Opcodes.DLOAD, 4));
        newInstructions.add(new VarInsnNode(Opcodes.DLOAD, 6));
        newInstructions.add(new VarInsnNode(Opcodes.FLOAD, 8));
        newInstructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, ASM_HOOKS, "renderFire",
                "(Lnet/minecraft/entity/Entity;DDDF)Z"));
        LabelNode label = new LabelNode();
        newInstructions.add(new JumpInsnNode(Opcodes.IFEQ, label));
        newInstructions.add(new InsnNode(Opcodes.RETURN));
        newInstructions.add(label);//from   w w  w.  j  a  v a  2s  .c  o  m

        method.instructions.insertBefore(node, newInstructions);
        return true;
    })));
}