Skip to content
This repository has been archived by the owner on Jul 1, 2018. It is now read-only.

Commit

Permalink
Fix issue with OpenPeripheral ASM
Browse files Browse the repository at this point in the history
Fixes #67
  • Loading branch information
SquidDev committed Sep 12, 2015
1 parent e01f823 commit 04d97fe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public ClassVisitor patch(String className, final ClassVisitor delegate) throws
) {
@Override
public void handle(InsnList nodes, MethodVisitor visitor) {
nodes.accept(visitor);
visitor.visitLdcInsn(IPeripheralEnvironments.ARG_NETWORK);
visitor.visitLdcInsn(Type.getType("Lorg/squiddev/cctweaks/api/network/INetworkAccess;"));
visitor.visitMethodInsn(INVOKEVIRTUAL,
Expand All @@ -50,6 +51,6 @@ public void handle(InsnList nodes, MethodVisitor visitor) {
false
);
}
}.onMethod("<clinit>").once().mustFind();
}.onMethod("<clinit>").onMethod("init").once().mustFind();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ClassVisitor patch(final String className, ClassVisitor delegate) throws
CLASS_NAME,
"org.squiddev.cctweaks.core.patch.op.AdapterPeripheral_Patch"
).patch(className, delegate),
new VarInsnNode(ALOAD, 0),
new VarInsnNode(ALOAD, -1),
new MethodInsnNode(
INVOKEINTERFACE,
"openperipheral/adapter/IMethodCall",
Expand All @@ -52,7 +52,7 @@ public ClassVisitor patch(final String className, ClassVisitor delegate) throws
public void handle(InsnList nodes, MethodVisitor visitor) {
visitor.visitLdcInsn(IPeripheralEnvironments.ARG_NETWORK);
visitor.visitVarInsn(ALOAD, 0);
visitor.visitFieldInsn(GETFIELD, CLASS_TYPE, "network", "Lorg/squiddev/cctweaks/core/network/NetworkAccessDelegate;");
visitor.visitFieldInsn(INVOKEVIRTUAL, CLASS_TYPE, "getNetworkAccess", "()Lorg/squiddev/cctweaks/core/network/NetworkAccessDelegate;");
visitor.visitMethodInsn(
INVOKEINTERFACE,
"openperipheral/adapter/IMethodCall",
Expand All @@ -61,6 +61,8 @@ public void handle(InsnList nodes, MethodVisitor visitor) {
true
);

nodes.accept(visitor);

DebugLogger.debug("Added additional environments into " + CLASS_NAME);
}
}.once().onMethod("call").mustFind();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private static void checkSlotId(IInventory inventory, int slot, String name) {
if (slot != ANY_SLOT) Preconditions.checkElementIndex(slot, inventory.getSizeInventory(), name + " slot id");
}

public static IInventory getInventory(INetworkAccess network, String name) {
private static IInventory getInventory(INetworkAccess network, String name) {
Object object = CCTweaksAPI.instance().peripheralHelpers().getTarget(network.getPeripheralsOnNetwork().get(name));
if (object != null && object instanceof IInventory) return InventoryUtils.getInventory((IInventory) object);
return null;
Expand Down

0 comments on commit 04d97fe

Please sign in to comment.