From 6b3526e739d7d80c8deb7ef0c295fe359ff8cd3d Mon Sep 17 00:00:00 2001 From: immibis Date: Sat, 17 Jan 2015 20:15:38 +1300 Subject: [PATCH] Auto-workbenches that cannot craft will not retry crafting again until any input slot changes. Conflicts: common/buildcraft/factory/TileAutoWorkbench.java --- .../buildcraft/factory/TileAutoWorkbench.java | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/common/buildcraft/factory/TileAutoWorkbench.java b/common/buildcraft/factory/TileAutoWorkbench.java index 38ab6177..5fc407ec 100644 --- a/common/buildcraft/factory/TileAutoWorkbench.java +++ b/common/buildcraft/factory/TileAutoWorkbench.java @@ -21,9 +21,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.WorldServer; - import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.BuildCraftFactory; import buildcraft.api.core.IInvSlot; import buildcraft.core.TileBuildCraft; import buildcraft.core.inventory.InvUtils; @@ -45,7 +45,11 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory public InventoryCrafting craftMatrix = new LocalInventoryCrafting(); public boolean useLast; public int progress; - + + /** Set when nothing can be crafted unless the input grid is changed. + * Cleared whenever the input grid is changed. Not persisted. */ + private boolean isJammed; + private SimpleInventory resultInv = new SimpleInventory(1, "Auto Workbench", 64); private IInventory inv = InventoryConcatenator.make().add(resultInv).add(craftMatrix); @@ -65,6 +69,24 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory } }, 3, 3); } + + @Override + public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { + super.setInventorySlotContents(p_70299_1_, p_70299_2_); + isJammed = false; + } + + @Override + public void markDirty() { + super.markDirty(); + isJammed = false; + } + + @Override + public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { + isJammed = false; + return super.decrStackSize(p_70298_1_, p_70298_2_); + } } public WeakReference getInternalPlayer() { @@ -175,6 +197,10 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory if (worldObj.isRemote) { return; } + + if (isJammed) { + return; + } balanceSlots(); @@ -229,10 +255,12 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory IRecipe recipe = findRecipe(); if (recipe == null) { progress = 0; + isJammed = true; return; } if (!useLast && isLast()) { progress = 0; + isJammed = true; return; } progress += UPDATE_TIME; @@ -243,6 +271,7 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory useLast = false; ItemStack result = recipe.getCraftingResult(craftMatrix); if (result == null) { + isJammed = true; return; } result = result.copy(); @@ -322,4 +351,4 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory public boolean hasCustomInventoryName() { return false; } -} \ No newline at end of file +}