Auto-workbenches will rebalance only when necessary, instead of every tick.

Also, moved balancing before jammed check. Otherwise, jammed autoworkbenches that could unjam themselves by balancing wouldn't do this.
This commit is contained in:
immibis 2015-01-17 20:19:51 +13:00 committed by asiekierka
parent 6b3526e739
commit bd4b856106
1 changed files with 10 additions and 2 deletions

View File

@ -50,6 +50,9 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory
* Cleared whenever the input grid is changed. Not persisted. */
private boolean isJammed;
/** Set when any slot changes. Cleared when balanceSlots is called. */
private boolean needsBalancing;
private SimpleInventory resultInv = new SimpleInventory(1, "Auto Workbench", 64);
private IInventory inv = InventoryConcatenator.make().add(resultInv).add(craftMatrix);
@ -74,17 +77,20 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory
public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
super.setInventorySlotContents(p_70299_1_, p_70299_2_);
isJammed = false;
needsBalancing = true;
}
@Override
public void markDirty() {
super.markDirty();
isJammed = false;
needsBalancing = true;
}
@Override
public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) {
isJammed = false;
needsBalancing = true;
return super.decrStackSize(p_70298_1_, p_70298_2_);
}
}
@ -198,12 +204,13 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory
return;
}
if(needsBalancing)
balanceSlots();
if (isJammed) {
return;
}
balanceSlots();
if (craftSlot == null) {
craftSlot = new SlotCrafting(getInternalPlayer().get(), craftMatrix, craftResult, 0, 0, 0);
}
@ -246,6 +253,7 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory
}
}
}
needsBalancing = false;
}
/**