Crafting CPU Now properly updates when restarting a job.
Crafting CPU now uses considerably less bandwidth and only does updates when things change, much like the terminal.
This commit is contained in:
@@ -102,7 +102,7 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
|
|||||||
@Override
|
@Override
|
||||||
public void detectAndSendChanges()
|
public void detectAndSendChanges()
|
||||||
{
|
{
|
||||||
if ( Platform.isServer() )
|
if ( Platform.isServer() && !list.isEmpty() )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -117,13 +117,20 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
|
|||||||
c.appendItem( monitor.getItemStack( out, CraftingItemList.PENDING ) );
|
c.appendItem( monitor.getItemStack( out, CraftingItemList.PENDING ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.resetStatus();
|
||||||
|
|
||||||
for (Object g : this.crafters)
|
for (Object g : this.crafters)
|
||||||
{
|
{
|
||||||
if ( g instanceof EntityPlayer )
|
if ( g instanceof EntityPlayer )
|
||||||
{
|
{
|
||||||
NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g );
|
if ( !a.isEmpty() )
|
||||||
NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g );
|
NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g );
|
||||||
NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g );
|
|
||||||
|
if ( !b.isEmpty() )
|
||||||
|
NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g );
|
||||||
|
|
||||||
|
if ( !c.isEmpty() )
|
||||||
|
NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,11 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
protected void postChange(IAEItemStack diff, BaseActionSource src)
|
protected void postChange(IAEItemStack diff, BaseActionSource src)
|
||||||
{
|
{
|
||||||
Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = getListeners();
|
Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = getListeners();
|
||||||
|
|
||||||
|
// protect integrity
|
||||||
|
if ( i.hasNext() )
|
||||||
|
diff = diff.copy();
|
||||||
|
|
||||||
while (i.hasNext())
|
while (i.hasNext())
|
||||||
{
|
{
|
||||||
Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object> o = i.next();
|
Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object> o = i.next();
|
||||||
@@ -272,6 +277,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
if ( is != null && is.getStackSize() > 0 )
|
if ( is != null && is.getStackSize() > 0 )
|
||||||
{
|
{
|
||||||
waiting = false;
|
waiting = false;
|
||||||
|
postChange( (IAEItemStack) input, src );
|
||||||
|
|
||||||
if ( is.getStackSize() >= input.getStackSize() )
|
if ( is.getStackSize() >= input.getStackSize() )
|
||||||
{
|
{
|
||||||
@@ -400,6 +406,11 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
if ( myLastLink != null )
|
if ( myLastLink != null )
|
||||||
myLastLink.cancel();
|
myLastLink.cancel();
|
||||||
|
|
||||||
|
IItemList<IAEItemStack> list;
|
||||||
|
getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL );
|
||||||
|
for (IAEItemStack g : list)
|
||||||
|
postChange( g, machineSrc );
|
||||||
|
|
||||||
isComplete = true;
|
isComplete = true;
|
||||||
myLastLink = null;
|
myLastLink = null;
|
||||||
tasks.clear();
|
tasks.clear();
|
||||||
@@ -486,6 +497,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
|
|
||||||
if ( is != null && details.isValidItemForSlot( x, is, getWorld() ) )
|
if ( is != null && details.isValidItemForSlot( x, is, getWorld() ) )
|
||||||
{
|
{
|
||||||
|
postChange( input[x], machineSrc );
|
||||||
ic.setInventorySlotContents( x, is );
|
ic.setInventorySlotContents( x, is );
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
@@ -499,6 +511,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
|
|
||||||
if ( is != null )
|
if ( is != null )
|
||||||
{
|
{
|
||||||
|
postChange( input[x], machineSrc );
|
||||||
ic.setInventorySlotContents( x, is );
|
ic.setInventorySlotContents( x, is );
|
||||||
found = true;
|
found = true;
|
||||||
continue;
|
continue;
|
||||||
@@ -531,7 +544,10 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
remainingOperations--;
|
remainingOperations--;
|
||||||
|
|
||||||
for (IAEItemStack out : details.getCondencedOutputs())
|
for (IAEItemStack out : details.getCondencedOutputs())
|
||||||
|
{
|
||||||
|
postChange( out, machineSrc );
|
||||||
waitingFor.add( out.copy() );
|
waitingFor.add( out.copy() );
|
||||||
|
}
|
||||||
|
|
||||||
if ( details.isCraftable() )
|
if ( details.isCraftable() )
|
||||||
{
|
{
|
||||||
@@ -542,7 +558,11 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
{
|
{
|
||||||
ItemStack output = Platform.getContainerItem( ic.getStackInSlot( x ) );
|
ItemStack output = Platform.getContainerItem( ic.getStackInSlot( x ) );
|
||||||
if ( output != null )
|
if ( output != null )
|
||||||
waitingFor.add( AEItemStack.create( output ) );
|
{
|
||||||
|
IAEItemStack cItem = AEItemStack.create( output );
|
||||||
|
postChange( cItem, machineSrc );
|
||||||
|
waitingFor.add( AEItemStack.create( cItem ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -592,7 +612,10 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
is = inventory.extractItems( is.copy(), Actionable.MODULATE, machineSrc );
|
is = inventory.extractItems( is.copy(), Actionable.MODULATE, machineSrc );
|
||||||
|
|
||||||
if ( is != null )
|
if ( is != null )
|
||||||
|
{
|
||||||
|
postChange( is, machineSrc );
|
||||||
is = ii.injectItems( is, Actionable.MODULATE, machineSrc );
|
is = ii.injectItems( is, Actionable.MODULATE, machineSrc );
|
||||||
|
}
|
||||||
|
|
||||||
if ( is != null )
|
if ( is != null )
|
||||||
inventory.injectItems( is, Actionable.MODULATE, machineSrc );
|
inventory.injectItems( is, Actionable.MODULATE, machineSrc );
|
||||||
@@ -643,6 +666,11 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
submitLink( myLastLink );
|
submitLink( myLastLink );
|
||||||
submitLink( whatLink );
|
submitLink( whatLink );
|
||||||
|
|
||||||
|
IItemList<IAEItemStack> list;
|
||||||
|
getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL );
|
||||||
|
for (IAEItemStack ge : list)
|
||||||
|
postChange( ge, machineSrc );
|
||||||
|
|
||||||
return whatLink;
|
return whatLink;
|
||||||
}
|
}
|
||||||
catch (CraftBranchFailure e)
|
catch (CraftBranchFailure e)
|
||||||
|
|||||||
Reference in New Issue
Block a user