diff --git a/src/main/java/refinedstorage/apiimpl/autocrafting/ProcessingCraftingTask.java b/src/main/java/refinedstorage/apiimpl/autocrafting/ProcessingCraftingTask.java index 62f8b1809..0d002e7cb 100755 --- a/src/main/java/refinedstorage/apiimpl/autocrafting/ProcessingCraftingTask.java +++ b/src/main/java/refinedstorage/apiimpl/autocrafting/ProcessingCraftingTask.java @@ -90,14 +90,16 @@ public class ProcessingCraftingTask implements ICraftingTask { return true; } - public void onInserted(ItemStack inserted) { + public boolean onInserted(ItemStack item) { for (int i = 0; i < pattern.getOutputs().length; ++i) { - if (!satisfied[i] && RefinedStorageUtils.compareStackNoQuantity(inserted, pattern.getOutputs()[i])) { + if (!satisfied[i] && RefinedStorageUtils.compareStackNoQuantity(item, pattern.getOutputs()[i])) { satisfied[i] = true; - return; + return true; } } + + return false; } @Override diff --git a/src/main/java/refinedstorage/tile/controller/TileController.java b/src/main/java/refinedstorage/tile/controller/TileController.java index 5b25f58f3..46bc026f9 100755 --- a/src/main/java/refinedstorage/tile/controller/TileController.java +++ b/src/main/java/refinedstorage/tile/controller/TileController.java @@ -168,19 +168,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR craftingTasksToAddAsLast.clear(); - if (!craftingTasks.empty()) { - markDirty(); - - ICraftingTask top = craftingTasks.peek(); - - ICraftingPatternContainer container = top.getPattern().getContainer(worldObj); - - if (container != null && (ticks % container.getSpeed()) == 0 && top.update(worldObj, this)) { - top.onDone(this); - - craftingTasks.pop(); - } - } + updateTopCraftingTask(true); } wirelessGridHandler.update(); @@ -219,6 +207,22 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR super.update(); } + private void updateTopCraftingTask(boolean withSpeed) { + if (!craftingTasks.empty()) { + markDirty(); + + ICraftingTask top = craftingTasks.peek(); + + ICraftingPatternContainer container = top.getPattern().getContainer(worldObj); + + if (container != null && (!withSpeed || (ticks % container.getSpeed()) == 0) && top.update(worldObj, this)) { + top.onDone(this); + + craftingTasks.pop(); + } + } + } + public void disconnectAll() { for (INetworkNode node : nodes) { if (node.isConnected()) { @@ -507,11 +511,9 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR if (!simulate && inserted > 0) { for (int i = 0; i < inserted; ++i) { - if (!craftingTasks.empty()) { - ICraftingTask top = craftingTasks.peek(); - - if (top instanceof ProcessingCraftingTask) { - ((ProcessingCraftingTask) top).onInserted(stack); + if (!craftingTasks.empty() && craftingTasks.peek() instanceof ProcessingCraftingTask) { + if (((ProcessingCraftingTask) craftingTasks.peek()).onInserted(stack)) { + updateTopCraftingTask(false); } } }