From 240cd685018a15fe000ad4905a275c4d14ff4347 Mon Sep 17 00:00:00 2001 From: hohserg1 Date: Sun, 17 Nov 2024 16:49:55 +0300 Subject: [PATCH] fix infinity loop issue #12 --- src/main/java/yalter/mousetweaks/Main.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/yalter/mousetweaks/Main.java b/src/main/java/yalter/mousetweaks/Main.java index 84b31b7..f71bda5 100644 --- a/src/main/java/yalter/mousetweaks/Main.java +++ b/src/main/java/yalter/mousetweaks/Main.java @@ -251,7 +251,11 @@ private static void handleWheel(Slot selectedSlot) { return; } + int attemptsLeft = 100; + do { + attemptsLeft--; + Slot applicableSlot = findWheelApplicableSlot(slots, selectedSlot, pushItems); if (applicableSlot == null) break; @@ -320,7 +324,7 @@ private static void handleWheel(Slot selectedSlot) { handler.clickSlot(slotFrom, MouseButton.LEFT, false); } } - } while (numItemsToMove > 0); + } while (numItemsToMove > 0 && attemptsLeft > 0); } // Returns true if the other inventory is above the selected slot inventory.