diff --git a/helpers/DualityInterface.java b/helpers/DualityInterface.java index 5e1e0135e..9d9fd44d3 100644 --- a/helpers/DualityInterface.java +++ b/helpers/DualityInterface.java @@ -830,6 +830,18 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt public void notifyNeightbors() { + if ( gridProxy.isActive() ) + { + try + { + gridProxy.getTick().wakeDevice( gridProxy.getNode() ); + } + catch (GridAccessException e) + { + // :P + } + } + TileEntity te = iHost.getTileEntity(); if ( te != null && te.getWorldObj() != null ) { diff --git a/me/cluster/implementations/CraftingCPUCluster.java b/me/cluster/implementations/CraftingCPUCluster.java index ddd34e78f..cf7dd0d22 100644 --- a/me/cluster/implementations/CraftingCPUCluster.java +++ b/me/cluster/implementations/CraftingCPUCluster.java @@ -269,7 +269,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU public IAEStack injectItems(IAEStack input, Actionable type, BaseActionSource src) { - if ( input instanceof IAEItemStack && type == Actionable.SIMULATE && false )// causes crafting to lock up? + if ( input instanceof IAEItemStack && type == Actionable.SIMULATE )// causes crafting to lock up? { IAEItemStack what = (IAEItemStack) input.copy(); IAEItemStack is = waitingFor.findPrecise( what ); @@ -281,7 +281,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU if ( finalOutput.equals( what ) ) { if ( myLastLink != null ) - return ((CraftingLink) myLastLink).injectItems( (IAEItemStack) what, type ); + return ((CraftingLink) myLastLink).injectItems( (IAEItemStack) what.copy(), type ); return what; // ignore it. } @@ -289,17 +289,23 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU return null; } + IAEItemStack leftOver = what.copy(); + leftOver.decStackSize( is.getStackSize() ); + + IAEItemStack used = what.copy(); + used.setStackSize( is.getStackSize() ); + if ( finalOutput.equals( what ) ) { if ( myLastLink != null ) - return ((CraftingLink) myLastLink).injectItems( (IAEItemStack) what, type ); + { + leftOver.add( ((CraftingLink) myLastLink).injectItems( (IAEItemStack) used.copy(), type ) ); + return leftOver; + } return what; // ignore it. } - IAEItemStack leftOver = what.copy(); - leftOver.decStackSize( is.getStackSize() ); - return leftOver; } } @@ -345,12 +351,18 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU is.setStackSize( 0 ); - if ( finalOutput.equals( input ) ) + if ( finalOutput.equals( insert ) ) { - finalOutput.decStackSize( input.getStackSize() ); + finalOutput.decStackSize( insert.getStackSize() ); if ( finalOutput.getStackSize() <= 0 ) completeJob(); + if ( myLastLink != null ) + { + what.add( ((CraftingLink) myLastLink).injectItems( (IAEItemStack) insert.copy(), type ) ); + return what; + } + if ( myLastLink != null ) return ((CraftingLink) myLastLink).injectItems( (IAEItemStack) input, type ); @@ -450,6 +462,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU public void updateCraftingLogic(IGrid grid, IEnergyGrid eg, CraftingGridCache cc) { + if ( !getCore().isActive() ) + return; + if ( myLastLink != null ) { if ( myLastLink.isCanceled() ) @@ -475,10 +490,15 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU int remainingOperations = accelerator + 1 + 90; boolean didsomething = false; - for (Entry e : tasks.entrySet()) + Iterator> i = tasks.entrySet().iterator(); + while (i.hasNext()) { + Entry e = i.next(); if ( e.getValue().value <= 0 ) + { + i.remove(); continue; + } ICraftingPatternDetails details = e.getKey(); if ( canCraft( details, details.getCondencedInputs() ) ) diff --git a/parts/automation/PartExportBus.java b/parts/automation/PartExportBus.java index e2c8e8555..cf519087f 100644 --- a/parts/automation/PartExportBus.java +++ b/parts/automation/PartExportBus.java @@ -276,7 +276,7 @@ public class PartExportBus extends PartSharedItemBus implements IGridTickable, I try { - if ( proxy.isActive() ) + if ( d != null && proxy.isActive() ) { IEnergyGrid energy = proxy.getEnergy();