fr1kin

SafeWalk fun

Sep 4th, 2016
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. AbstractInsnNode sneakFlagNode = findPattern("moveEntity", "sneakFlagNode",
  2.         method.instructions.getFirst(), isPlayerSneakingSig, "xxxxxx??x");
  3. if(sneakFlagNode != null &&
  4.         sneakFlagNode instanceof JumpInsnNode) {
  5.     // the original label to the jump
  6.     LabelNode jumpToLabel = ((JumpInsnNode) sneakFlagNode).label;
  7.     // the or statement jump if isSneaking returns false
  8.     LabelNode orJump = new LabelNode();
  9.  
  10.     InsnList insnList = new InsnList();
  11.     insnList.add(new JumpInsnNode(IFNE, orJump)); // if not equal, jump past the ForgeHaxHooks.isSafeWalkActivated
  12.     insnList.add(new FieldInsnNode(GETSTATIC,
  13.             NAMES.IS_SAFEWALK_ACTIVE.getParentClass().getRuntimeName(),
  14.             NAMES.IS_SAFEWALK_ACTIVE.getRuntimeName(),
  15.             NAMES.IS_SAFEWALK_ACTIVE.getTypeDescriptor()
  16.     ));// get the value of isSafeWalkActivated
  17.     insnList.add(new JumpInsnNode(IFEQ, jumpToLabel));
  18.     insnList.add(orJump);
  19.  
  20.     AbstractInsnNode previousNode = sneakFlagNode.getPrevious();
  21.     method.instructions.remove(sneakFlagNode); // delete IFEQ
  22.     method.instructions.insert(previousNode, insnList); // insert new instructions
  23.     isPatched &= true;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment