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 a47d5c2ff..8358a9793 100644 --- a/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java +++ b/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java @@ -235,7 +235,7 @@ public void onClientTick(MinecraftClient mc) if (Configs.Generic.MASS_CRAFT_RECIPE_BOOK.getBooleanValue() && recipe.lookupVanillaRecipe(mc.world) != null) { - InventoryUtils.dontUpdateRecipeBook = 10; + InventoryUtils.dontUpdateRecipeBook = 2; for (int i = 0; i < limit; ++i) { // todo 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 0ebc2e527..f509e4d47 100644 --- a/src/main/java/fi/dy/masa/itemscroller/mixin/MixinRecipeBookWidget.java +++ b/src/main/java/fi/dy/masa/itemscroller/mixin/MixinRecipeBookWidget.java @@ -1,16 +1,24 @@ package fi.dy.masa.itemscroller.mixin; import fi.dy.masa.itemscroller.util.InventoryUtils; +import net.minecraft.client.gui.screen.recipebook.RecipeBookGhostSlots; import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget; +import net.minecraft.recipe.RecipeEntry; import net.minecraft.screen.slot.Slot; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.util.List; + @Mixin(RecipeBookWidget.class) public class MixinRecipeBookWidget { + @Shadow @Final protected RecipeBookGhostSlots ghostSlots; + @Inject(method = "slotClicked", at = @At("HEAD"), cancellable = true) private void onSlotClicked(Slot slot, CallbackInfo ci) { @@ -29,13 +37,15 @@ private void onUpdate(CallbackInfo ci) } } - @Inject(method = "drawGhostSlots", at = @At("HEAD"), cancellable = true) - private void onDrawGhostSlots(CallbackInfo ci) - { - if (InventoryUtils.dontUpdateRecipeBook > 0) - { + // Seems to be (intended) bug from Mojang + @Inject( + method = "showGhostRecipe", + at = @At("HEAD"), + cancellable = true + ) + private void onShowGhostRecipe(RecipeEntry recipe, List slots, CallbackInfo ci) { + if (this.ghostSlots.getRecipe() == recipe) { ci.cancel(); } } - }