diff --git a/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java b/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java index 2475571da..a47d5c2ff 100644 --- a/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java +++ b/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java @@ -194,6 +194,9 @@ private static void debugPrintInv(RecipeInputInventory inv) @Override public void onClientTick(MinecraftClient mc) { + if (InventoryUtils.dontUpdateRecipeBook > 0) { + --InventoryUtils.dontUpdateRecipeBook; + } if (this.functionalityEnabled() == false || mc.player == null) { return; @@ -232,7 +235,7 @@ public void onClientTick(MinecraftClient mc) if (Configs.Generic.MASS_CRAFT_RECIPE_BOOK.getBooleanValue() && recipe.lookupVanillaRecipe(mc.world) != null) { - InventoryUtils.dontUpdateRecipeBook = true; + InventoryUtils.dontUpdateRecipeBook = 10; for (int i = 0; i < limit; ++i) { // todo @@ -273,7 +276,6 @@ public void onClientTick(MinecraftClient mc) InventoryUtils.shiftClickSlot(gui, outputSlot.id); recipeBookClicks = true; } - InventoryUtils.dontUpdateRecipeBook = false; } else if (Configs.Generic.MASS_CRAFT_SWAPS.getBooleanValue()) { diff --git a/src/main/java/fi/dy/masa/itemscroller/mixin/MixinRecipeBookWidget.java b/src/main/java/fi/dy/masa/itemscroller/mixin/MixinRecipeBookWidget.java index 2f8a33d0c..d4ef82175 100644 --- a/src/main/java/fi/dy/masa/itemscroller/mixin/MixinRecipeBookWidget.java +++ b/src/main/java/fi/dy/masa/itemscroller/mixin/MixinRecipeBookWidget.java @@ -14,7 +14,16 @@ public class MixinRecipeBookWidget @Inject(method = "slotClicked", at = @At("HEAD"), cancellable = true) private void onSlotClicked(Slot slot, CallbackInfo ci) { - if (InventoryUtils.dontUpdateRecipeBook) + if (InventoryUtils.dontUpdateRecipeBook > 0) + { + ci.cancel(); + } + } + + @Inject(method = "update", at = @At("HEAD"), cancellable = true) + private void onUpdate(CallbackInfo ci) + { + if (InventoryUtils.dontUpdateRecipeBook > 0) { ci.cancel(); } diff --git a/src/main/java/fi/dy/masa/itemscroller/util/InventoryUtils.java b/src/main/java/fi/dy/masa/itemscroller/util/InventoryUtils.java index 799454a32..8b7906c11 100644 --- a/src/main/java/fi/dy/masa/itemscroller/util/InventoryUtils.java +++ b/src/main/java/fi/dy/masa/itemscroller/util/InventoryUtils.java @@ -64,7 +64,7 @@ public class InventoryUtils { private static final Set DRAGGED_SLOTS = new HashSet<>(); private static final int SERVER_SYNC_MAGIC = 45510; - public static boolean dontUpdateRecipeBook; + public static int dontUpdateRecipeBook; private static WeakReference sourceSlotCandidate = null; private static WeakReference sourceSlot = null;