diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/CraftingTweaks.java b/common/src/main/java/net/blay09/mods/craftingtweaks/CraftingTweaks.java index fde3e62..17a083f 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/CraftingTweaks.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/CraftingTweaks.java @@ -17,12 +17,16 @@ import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.crafting.ShapedRecipe; import net.minecraft.world.item.crafting.ShapelessRecipe; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CraftingTweaks { public static final String MOD_ID = "craftingtweaks"; public static boolean debugMode; + public static final Logger logger = LoggerFactory.getLogger(CraftingTweaks.class); + public static boolean isServerSideInstalled = true; public static void initialize() { diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/api/impl/DefaultGridRefillHandler.java b/common/src/main/java/net/blay09/mods/craftingtweaks/api/impl/DefaultGridRefillHandler.java index 88c0381..0a0783e 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/api/impl/DefaultGridRefillHandler.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/api/impl/DefaultGridRefillHandler.java @@ -1,5 +1,6 @@ package net.blay09.mods.craftingtweaks.api.impl; +import net.blay09.mods.craftingtweaks.CraftingTweaks; import net.blay09.mods.craftingtweaks.api.CraftingGrid; import net.blay09.mods.craftingtweaks.api.CraftingTweaksAPI; import net.blay09.mods.craftingtweaks.api.GridRefillHandler; @@ -33,6 +34,7 @@ public void refillRecipe(CraftingGrid grid, Player player, AbstractContainerMenu return; } + int operations = 0; outer: do { final var ingredientTokens = operation.getIngredientTokens(); @@ -63,7 +65,12 @@ public void refillRecipe(CraftingGrid grid, Player player, AbstractContainerMenu final var itemStack = ingredientToken.consume(); craftMatrix.setItem(slot, itemStack.copyWithCount(itemStack.getCount() + slotStack.getCount())); }); - if (!stack) { + operations++; + if (operations > 64) { + CraftingTweaks.logger.warn("Something went wrong trying to refill recipe. Too many iterations. Recipe: {}", recipeHolder.id().location()); + break; + } + if (!stack || matrixDiff.isEmpty()) { break; } } while (operation.prepare().canCraft());