From d4eca3c068c2f0e880b9593121d5135b6fbd102d Mon Sep 17 00:00:00 2001 From: Jonathing Date: Thu, 10 Oct 2024 23:49:25 -0400 Subject: [PATCH] Fix findFirstInstructionBefore ignoring the start index (#50) --- src/main/java/net/minecraftforge/coremod/api/ASMAPI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/minecraftforge/coremod/api/ASMAPI.java b/src/main/java/net/minecraftforge/coremod/api/ASMAPI.java index 6456ef2..668f6ef 100644 --- a/src/main/java/net/minecraftforge/coremod/api/ASMAPI.java +++ b/src/main/java/net/minecraftforge/coremod/api/ASMAPI.java @@ -157,7 +157,7 @@ public static AbstractInsnNode findFirstInstructionAfter(MethodNode method, int * @return the found instruction node or null if none matched before the given startIndex */ public static AbstractInsnNode findFirstInstructionBefore(MethodNode method, int opCode, int startIndex) { - for (int i = Math.max(method.instructions.size() - 1, startIndex); i >= 0; i--) { + for (int i = Math.min(method.instructions.size() - 1, startIndex); i >= 0; i--) { AbstractInsnNode ain = method.instructions.get(i); if (ain.getOpcode() == opCode) { return ain;