private MethodNode generateIsBlockingWithShield() { MethodNode mv = new MethodNode(ACC_PUBLIC, "isBlockingWithShield", "()Z", null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn( INVOKESTATIC, UTILITY_CLASS, "canBlockWithShield", "(L" + entityPlayerClassName + ";)Z"); Label l1 = new Label(); mv.visitJumpInsn(IFEQ, l1); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, entityPlayerClassName, "isShielding", "Z"); mv.visitJumpInsn(IFEQ, l1); mv.visitInsn(ICONST_1); Label l2 = new Label(); mv.visitJumpInsn(GOTO, l2); mv.visitLabel(l1); mv.visitFrame(F_SAME, 0, null, 0, null); mv.visitInsn(ICONST_0); mv.visitLabel(l2); mv.visitFrame(F_SAME1, 0, null, 1, new Object[] {INTEGER}); mv.visitInsn(IRETURN); Label l3 = new Label(); mv.visitLabel(l3); mv.visitLocalVariable("this", "L" + entityPlayerClassName + ";", null, l0, l3, 0); mv.visitMaxs(1, 1); mv.visitEnd(); return mv; }
private MethodNode generateSwingOffhand() { MethodNode mv = new MethodNode(ACC_PUBLIC, "swingOffItem", SIMPLEST_METHOD_DESC, null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, entityPlayerClassName, "isOffHandSwingInProgress", "Z"); Label l1 = new Label(); mv.visitJumpInsn(IFEQ, l1); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, entityPlayerClassName, "offHandSwingProgressInt", "I"); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKEVIRTUAL, entityPlayerClassName, getArmSwingEndMethodName, "()I"); mv.visitInsn(ICONST_2); mv.visitInsn(IDIV); mv.visitJumpInsn(IF_ICMPGE, l1); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, entityPlayerClassName, "offHandSwingProgressInt", "I"); Label l2 = new Label(); mv.visitJumpInsn(IFGE, l2); mv.visitLabel(l1); mv.visitFrame(F_SAME, 0, null, 0, null); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(ICONST_M1); mv.visitFieldInsn(PUTFIELD, entityPlayerClassName, "offHandSwingProgressInt", "I"); Label l3 = new Label(); mv.visitLabel(l3); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(ICONST_1); mv.visitFieldInsn(PUTFIELD, entityPlayerClassName, "isOffHandSwingInProgress", "Z"); mv.visitLabel(l2); mv.visitFrame(F_SAME, 0, null, 0, null); mv.visitInsn(RETURN); Label l4 = new Label(); mv.visitLabel(l4); mv.visitLocalVariable("this", "L" + entityPlayerClassName + ";", null, l0, l4, 0); mv.visitMaxs(3, 1); mv.visitEnd(); return mv; }
private MethodNode generateGetOffSwingMethod() { MethodNode mv = new MethodNode(ACC_PUBLIC, "getOffSwingProgress", "(F)F", null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, entityPlayerClassName, "offHandSwingProgress", "F"); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, entityPlayerClassName, "prevOffHandSwingProgress", "F"); mv.visitInsn(FSUB); mv.visitVarInsn(FSTORE, 2); Label l1 = new Label(); mv.visitLabel(l1); mv.visitVarInsn(FLOAD, 2); mv.visitInsn(FCONST_0); mv.visitInsn(FCMPG); Label l2 = new Label(); mv.visitJumpInsn(IFGE, l2); Label l3 = new Label(); mv.visitLabel(l3); mv.visitVarInsn(FLOAD, 2); mv.visitInsn(FCONST_1); mv.visitInsn(FADD); mv.visitVarInsn(FSTORE, 2); mv.visitLabel(l2); mv.visitFrame(F_APPEND, 1, new Object[] {FLOAT}, 0, null); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, entityPlayerClassName, "prevOffHandSwingProgress", "F"); mv.visitVarInsn(FLOAD, 2); mv.visitVarInsn(FLOAD, 1); mv.visitInsn(FMUL); mv.visitInsn(FADD); mv.visitInsn(FRETURN); Label l4 = new Label(); mv.visitLabel(l4); mv.visitLocalVariable("this", "L" + entityPlayerClassName + ";", null, l0, l4, 0); mv.visitLocalVariable("frame", "F", null, l0, l4, 1); mv.visitLocalVariable("diff", "F", null, l1, l4, 2); mv.visitMaxs(3, 3); mv.visitEnd(); return mv; }
private MethodNode generateUpdateSwingArm() { MethodNode mv = new MethodNode( ACC_PROTECTED, playerUpdateArmSwingMethodName, SIMPLEST_METHOD_DESC, null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn( INVOKESPECIAL, entityLivingClassName, playerUpdateArmSwingMethodName, SIMPLEST_METHOD_DESC); Label l1 = new Label(); mv.visitLabel(l1); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, entityPlayerClassName, "offHandSwingProgress", "F"); mv.visitFieldInsn(PUTFIELD, entityPlayerClassName, "prevOffHandSwingProgress", "F"); Label l2 = new Label(); mv.visitLabel(l2); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKEVIRTUAL, entityPlayerClassName, getArmSwingEndMethodName, "()I"); mv.visitVarInsn(ISTORE, 1); Label l3 = new Label(); mv.visitLabel(l3); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, entityPlayerClassName, "isOffHandSwingInProgress", "Z"); Label l4 = new Label(); mv.visitJumpInsn(IFEQ, l4); Label l5 = new Label(); mv.visitLabel(l5); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(DUP); mv.visitFieldInsn(GETFIELD, entityPlayerClassName, "offHandSwingProgressInt", "I"); mv.visitInsn(ICONST_1); mv.visitInsn(IADD); mv.visitFieldInsn(PUTFIELD, entityPlayerClassName, "offHandSwingProgressInt", "I"); Label l6 = new Label(); mv.visitLabel(l6); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, entityPlayerClassName, "offHandSwingProgressInt", "I"); mv.visitVarInsn(ILOAD, 1); Label l7 = new Label(); mv.visitJumpInsn(IF_ICMPLT, l7); Label l8 = new Label(); mv.visitLabel(l8); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(ICONST_0); mv.visitFieldInsn(PUTFIELD, entityPlayerClassName, "offHandSwingProgressInt", "I"); Label l9 = new Label(); mv.visitLabel(l9); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(ICONST_0); mv.visitFieldInsn(PUTFIELD, entityPlayerClassName, "isOffHandSwingInProgress", "Z"); mv.visitJumpInsn(GOTO, l7); mv.visitLabel(l4); mv.visitFrame(F_APPEND, 1, new Object[] {INTEGER}, 0, null); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(ICONST_0); mv.visitFieldInsn(PUTFIELD, entityPlayerClassName, "offHandSwingProgressInt", "I"); mv.visitLabel(l7); mv.visitFrame(F_SAME, 0, null, 0, null); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, entityPlayerClassName, "offHandSwingProgressInt", "I"); mv.visitInsn(I2F); mv.visitVarInsn(ILOAD, 1); mv.visitInsn(I2F); mv.visitInsn(FDIV); mv.visitFieldInsn(PUTFIELD, entityPlayerClassName, "offHandSwingProgress", "F"); Label l10 = new Label(); mv.visitLabel(l10); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, entityPlayerClassName, "specialActionTimer", "I"); Label l11 = new Label(); mv.visitJumpInsn(IFLE, l11); Label l12 = new Label(); mv.visitLabel(l12); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(ICONST_0); mv.visitFieldInsn(PUTFIELD, entityPlayerClassName, "isOffHandSwingInProgress", "Z"); Label l13 = new Label(); mv.visitLabel(l13); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(ICONST_0); mv.visitFieldInsn(PUTFIELD, entityPlayerClassName, swingProgressBooleanField, "Z"); Label l14 = new Label(); mv.visitLabel(l14); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(FCONST_0); mv.visitFieldInsn(PUTFIELD, entityPlayerClassName, "offHandSwingProgress", "F"); Label l15 = new Label(); mv.visitLabel(l15); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(ICONST_0); mv.visitFieldInsn(PUTFIELD, entityPlayerClassName, "offHandSwingProgressInt", "I"); Label l16 = new Label(); mv.visitLabel(l16); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(FCONST_0); mv.visitFieldInsn(PUTFIELD, entityPlayerClassName, swingProgressFloatField, "F"); Label l17 = new Label(); mv.visitLabel(l17); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(ICONST_0); mv.visitFieldInsn(PUTFIELD, entityPlayerClassName, swingProgressIntField, "I"); mv.visitLabel(l11); mv.visitFrame(F_SAME, 0, null, 0, null); mv.visitInsn(RETURN); Label l18 = new Label(); mv.visitLabel(l18); mv.visitLocalVariable("this", "L" + entityPlayerClassName + ";", null, l0, l18, 0); mv.visitLocalVariable("var1", "I", null, l3, l18, 1); mv.visitMaxs(3, 2); mv.visitEnd(); return mv; }