Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. classes.put("Llotr.common.world.genlayer.LOTRGenLayerWorld", (clazz, obf) -> {
  2. String descriptor = "[I";
  3. System.out.println("Hmm.?");
  4. // Changing BiomeImageData to int[]
  5.  
  6. FieldNode fieldNode = field(clazz, "biomeImageData", "[B");
  7. fieldNode.desc = descriptor;
  8.  
  9. // Tweaking constructor
  10.  
  11. MethodNode construct = method(clazz, "<init>", "()V");
  12. construct.tryCatchBlocks.clear();
  13. construct.instructions.clear();
  14. // Calling super(0L)
  15. construct.instructions.add(new IntInsnNode(Opcodes.ALOAD, 0));
  16. construct.instructions.add(new InsnNode(Opcodes.LCONST_0));
  17. construct.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL,
  18. "lotr/common/world/genlayer/LOTRGenLayer","<init>", "(J)V", false));
  19.  
  20. construct.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
  21. "lotr/common/world/genlayer/LOTRGenLayerWorld",
  22. "loadedBiomeImage", "()Z", false));
  23. LabelNode initMap = new LabelNode();
  24. construct.instructions.add(new JumpInsnNode(Opcodes.IFNE, initMap));
  25. construct.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
  26. "lotrta/common/util/LOTRTAAssetLoader",
  27. "loadMap", "()V", false));
  28. construct.instructions.add(new InsnNode(Opcodes.RETURN));
  29. construct.instructions.add(initMap);
  30. construct.instructions.add(new InsnNode(Opcodes.RETURN));
  31.  
  32. // Fixing LOTRGenLayerWorld#getBiomeImageID by removing the "& 255" at the return type
  33.  
  34. MethodNode drawMap = method(clazz, "getBiomeImageID", "(II)I");
  35. int index = -1;
  36. for (AbstractInsnNode insn : drawMap.instructions.toArray()) {
  37. if (insn.getOpcode() == Opcodes.SIPUSH
  38. || insn.getOpcode() == Opcodes.IAND) { // Removing "& 255"
  39. drawMap.instructions.remove(insn);
  40. } else if (insn.getOpcode() == Opcodes.GETSTATIC) { // Fixing type
  41. FieldInsnNode node = (FieldInsnNode) insn;
  42. if ("biomeImageData".equals(node.name)) {
  43. drawMap.instructions.set(insn,
  44. new FieldInsnNode(insn.getOpcode(), node.owner,
  45. "biomeImageData", descriptor));
  46. }
  47. } else if (insn.getOpcode() == Opcodes.BALOAD) { // Fixing type
  48. drawMap.instructions.set(insn, new InsnNode(Opcodes.IALOAD));
  49. }
  50. }
  51.  
  52. // Fixing LOTRGenLayerWorld#loadedBiomeImage; Since it has to checked whether there is an array, I have to change it's type
  53. System.out.println("Why not work");
  54. MethodNode BoolNodes = method(clazz, "loadedBiomeImage", "()Z");
  55. for (AbstractInsnNode insn : BoolNodes.instructions.toArray()) {
  56. if (insn.getOpcode() == Opcodes.GETSTATIC) { // Fixing type
  57. FieldInsnNode node = (FieldInsnNode) insn;
  58. if ("biomeImageData".equals(node.name)) {
  59. BoolNodes.instructions.set(insn,
  60. new FieldInsnNode(insn.getOpcode(), node.owner,
  61. "biomeImageData", descriptor));
  62. }
  63. }
  64. }
  65. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement