Revamped onChange Events to post lists of items making bulk operations much less cpu intensive.

This commit is contained in:
AlgorithmX2
2014-09-10 23:12:34 -05:00
parent 3f91868d5e
commit 5b79ad0b8c
12 changed files with 83 additions and 88 deletions
@@ -54,6 +54,7 @@ import appeng.tile.crafting.TileCraftingTile;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import cpw.mods.fml.common.FMLCommonHandler;
@@ -108,16 +109,18 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = getListeners();
ImmutableList<IAEItemStack> single = null;
// protect integrity
if ( i.hasNext() )
diff = diff.copy();
single = ImmutableList.of( diff.copy() );
while (i.hasNext())
{
Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object> o = i.next();
IMEMonitorHandlerReceiver<IAEItemStack> recv = o.getKey();
if ( recv.isValid( o.getValue() ) )
recv.postChange( null, diff, src );
recv.postChange( null, single, src );
else
i.remove();
}
@@ -494,8 +497,8 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
IItemList<IAEItemStack> list;
getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL );
for (IAEItemStack g : list)
postChange( g, machineSrc );
for (IAEItemStack is : list)
postChange( is, machineSrc );
isComplete = true;
myLastLink = null;