Skip to content

Commit

Permalink
Forge:1.10.2: Fix a crash on newer IC2 versions caused by a change in…
Browse files Browse the repository at this point in the history
… TileEntityAdvMiner
  • Loading branch information
joserobjr committed Nov 25, 2016
1 parent a52815c commit f77f751
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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)
{
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f77f751

Please sign in to comment.