From 8c8ece2737a83e281542717f5205d2ca7ad0db64 Mon Sep 17 00:00:00 2001 From: LlamaLad7 Date: Fri, 8 Mar 2024 09:25:55 +0000 Subject: [PATCH] Fix: Check the staticness of the original call not the current one. (#132) --- .../asm/mixin/injection/invoke/util/InvokeUtil.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/spongepowered/asm/mixin/injection/invoke/util/InvokeUtil.java b/src/main/java/org/spongepowered/asm/mixin/injection/invoke/util/InvokeUtil.java index 0a6bb2b3d..8e874ed60 100644 --- a/src/main/java/org/spongepowered/asm/mixin/injection/invoke/util/InvokeUtil.java +++ b/src/main/java/org/spongepowered/asm/mixin/injection/invoke/util/InvokeUtil.java @@ -38,10 +38,11 @@ public static Type[] getOriginalArgs(InjectionNode node) { } public static Type[] getCurrentArgs(InjectionNode node) { - MethodInsnNode methodNode = (MethodInsnNode) node.getCurrentTarget(); - Type[] currentArgs = Type.getArgumentTypes(methodNode.desc); - if (node.isReplaced() && node.hasDecoration(RedirectInjector.Meta.KEY) && methodNode.getOpcode() != Opcodes.INVOKESTATIC) { - // A non-static redirect handler method will have an extra arg at the start that we don't care about. + MethodInsnNode original = (MethodInsnNode) node.getOriginalTarget(); + MethodInsnNode current = (MethodInsnNode) node.getCurrentTarget(); + Type[] currentArgs = Type.getArgumentTypes(current.desc); + if (node.isReplaced() && node.hasDecoration(RedirectInjector.Meta.KEY) && original.getOpcode() != Opcodes.INVOKESTATIC) { + // A redirect on a non-static target method will have an extra arg at the start that we don't care about. return Arrays.copyOfRange(currentArgs, 1, currentArgs.length); } return currentArgs;