From f77f7513778ee406a7cfeece1ab630e905cf72b6 Mon Sep 17 00:00:00 2001 From: joserobjr Date: Fri, 25 Nov 2016 19:10:11 -0300 Subject: [PATCH] Forge:1.10.2: Fix a crash on newer IC2 versions caused by a change in TileEntityAdvMiner --- .../TileEntityMinerTransformer.java | 15 +++++++-------- .../base/protection/industrialcraft/ICHooks.java | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Forge/Base/src/main/java/br/com/gamemods/minecity/forge/base/core/transformer/mod/industrialcraft/TileEntityMinerTransformer.java b/Forge/Base/src/main/java/br/com/gamemods/minecity/forge/base/core/transformer/mod/industrialcraft/TileEntityMinerTransformer.java index 0b5cb2a6..5380540c 100644 --- a/Forge/Base/src/main/java/br/com/gamemods/minecity/forge/base/core/transformer/mod/industrialcraft/TileEntityMinerTransformer.java +++ b/Forge/Base/src/main/java/br/com/gamemods/minecity/forge/base/core/transformer/mod/industrialcraft/TileEntityMinerTransformer.java @@ -1,6 +1,7 @@ package br.com.gamemods.minecity.forge.base.core.transformer.mod.industrialcraft; import br.com.gamemods.minecity.forge.base.core.MethodPatcher; +import br.com.gamemods.minecity.forge.base.core.ModEnv; import br.com.gamemods.minecity.forge.base.core.Referenced; import br.com.gamemods.minecity.forge.base.core.transformer.BasicTransformer; import org.objectweb.asm.ClassReader; @@ -27,9 +28,10 @@ public TileEntityMinerTransformer() @Override protected void patch(String name, ClassNode node, ClassReader reader) { - String icHookds = "br.com.gamemods.minecity.forge.base.protection.industrialcraft.ICHooks".replace('.','/'); + String hooks = ModEnv.hookClass.replace('.','/'); + String icHooks = "br.com.gamemods.minecity.forge.base.protection.industrialcraft.ICHooks".replace('.','/'); String tile = "br.com.gamemods.minecity.forge.base.accessors.block.ITileEntity".replace('.','/'); - String icPos = "ic2.core.util.Ic2BlockPos".replace('.','/'); + String point = "br.com.gamemods.minecity.api.shape.Point".replace('.','/'); for(MethodNode method : node.methods) { @@ -43,20 +45,17 @@ protected void patch(String name, ClassNode node, ClassReader reader) list.add(new VarInsnNode(ILOAD, 1)); list.add(new VarInsnNode(ILOAD, 2)); list.add(new VarInsnNode(ILOAD, 3)); + list.add(new MethodInsnNode(INVOKESTATIC, hooks, "toPoint", "(III)L"+point+";", false)); } // 1.10.2 else { list.add(new VarInsnNode(ALOAD, 0)); list.add(new VarInsnNode(ALOAD, 1)); - list.add(new MethodInsnNode(INVOKEVIRTUAL, icPos, "getX", "()I", false)); - list.add(new VarInsnNode(ALOAD, 1)); - list.add(new MethodInsnNode(INVOKEVIRTUAL, icPos, "getY", "()I", false)); - list.add(new VarInsnNode(ALOAD, 1)); - list.add(new MethodInsnNode(INVOKEVIRTUAL, icPos, "getZ", "()I", false)); + list.add(new MethodInsnNode(INVOKESTATIC, hooks, "toPoint", "(Ljava/lang/Object;)L"+point+";", false)); } list.add(new MethodInsnNode(INVOKESTATIC, - icHookds, "onMinerModify", "(L"+tile+";III)Z", false + icHooks, "onMinerModify", "(L"+tile+";L"+point+";)Z", false )); LabelNode labelNode = new LabelNode(); list.add(new JumpInsnNode(IFEQ, labelNode)); diff --git a/Forge/Base/src/main/java/br/com/gamemods/minecity/forge/base/protection/industrialcraft/ICHooks.java b/Forge/Base/src/main/java/br/com/gamemods/minecity/forge/base/protection/industrialcraft/ICHooks.java index b50a20c3..cbfa944f 100644 --- a/Forge/Base/src/main/java/br/com/gamemods/minecity/forge/base/protection/industrialcraft/ICHooks.java +++ b/Forge/Base/src/main/java/br/com/gamemods/minecity/forge/base/protection/industrialcraft/ICHooks.java @@ -181,10 +181,10 @@ public static ITileEntity onTileAccessOther(ITileEntity accessed, ITileEntity fr } @Referenced(at = TileEntityMinerTransformer.class) - public static boolean onMinerModify(ITileEntity tile, int x, int y, int z) + public static boolean onMinerModify(ITileEntity tile, Point p) { return !ModHooks.onBlockAccessOther - ((World) tile.getIWorld(), x, y, z, + ((World) tile.getIWorld(), p.x, p.y, p.z, tile.getPosX(), tile.getPosY(), tile.getPosZ(), PermissionFlag.MODIFY ).isPresent();