Skip to content

Commit

Permalink
Forcibly disable all update for recipebooks during recipe book crafting
Browse files Browse the repository at this point in the history
  • Loading branch information
wendavid552 committed Aug 15, 2024
1 parent d03cfe1 commit bdec4bb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class InventoryUtils
{
private static final Set<Integer> DRAGGED_SLOTS = new HashSet<>();
private static final int SERVER_SYNC_MAGIC = 45510;
public static boolean dontUpdateRecipeBook;
public static int dontUpdateRecipeBook;

private static WeakReference<Slot> sourceSlotCandidate = null;
private static WeakReference<Slot> sourceSlot = null;
Expand Down

0 comments on commit bdec4bb

Please sign in to comment.