Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- classes.put("Llotr.common.world.genlayer.LOTRGenLayerWorld", (clazz, obf) -> {
- String descriptor = "[I";
- System.out.println("Hmm.?");
- // Changing BiomeImageData to int[]
- FieldNode fieldNode = field(clazz, "biomeImageData", "[B");
- fieldNode.desc = descriptor;
- // Tweaking constructor
- MethodNode construct = method(clazz, "<init>", "()V");
- construct.tryCatchBlocks.clear();
- construct.instructions.clear();
- // Calling super(0L)
- construct.instructions.add(new IntInsnNode(Opcodes.ALOAD, 0));
- construct.instructions.add(new InsnNode(Opcodes.LCONST_0));
- construct.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL,
- "lotr/common/world/genlayer/LOTRGenLayer","<init>", "(J)V", false));
- construct.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
- "lotr/common/world/genlayer/LOTRGenLayerWorld",
- "loadedBiomeImage", "()Z", false));
- LabelNode initMap = new LabelNode();
- construct.instructions.add(new JumpInsnNode(Opcodes.IFNE, initMap));
- construct.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
- "lotrta/common/util/LOTRTAAssetLoader",
- "loadMap", "()V", false));
- construct.instructions.add(new InsnNode(Opcodes.RETURN));
- construct.instructions.add(initMap);
- construct.instructions.add(new InsnNode(Opcodes.RETURN));
- // Fixing LOTRGenLayerWorld#getBiomeImageID by removing the "& 255" at the return type
- MethodNode drawMap = method(clazz, "getBiomeImageID", "(II)I");
- int index = -1;
- for (AbstractInsnNode insn : drawMap.instructions.toArray()) {
- if (insn.getOpcode() == Opcodes.SIPUSH
- || insn.getOpcode() == Opcodes.IAND) { // Removing "& 255"
- drawMap.instructions.remove(insn);
- } else if (insn.getOpcode() == Opcodes.GETSTATIC) { // Fixing type
- FieldInsnNode node = (FieldInsnNode) insn;
- if ("biomeImageData".equals(node.name)) {
- drawMap.instructions.set(insn,
- new FieldInsnNode(insn.getOpcode(), node.owner,
- "biomeImageData", descriptor));
- }
- } else if (insn.getOpcode() == Opcodes.BALOAD) { // Fixing type
- drawMap.instructions.set(insn, new InsnNode(Opcodes.IALOAD));
- }
- }
- // Fixing LOTRGenLayerWorld#loadedBiomeImage; Since it has to checked whether there is an array, I have to change it's type
- System.out.println("Why not work");
- MethodNode BoolNodes = method(clazz, "loadedBiomeImage", "()Z");
- for (AbstractInsnNode insn : BoolNodes.instructions.toArray()) {
- if (insn.getOpcode() == Opcodes.GETSTATIC) { // Fixing type
- FieldInsnNode node = (FieldInsnNode) insn;
- if ("biomeImageData".equals(node.name)) {
- BoolNodes.instructions.set(insn,
- new FieldInsnNode(insn.getOpcode(), node.owner,
- "biomeImageData", descriptor));
- }
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement