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
+10 -4
View File
@@ -2,6 +2,7 @@ package appeng.me.storage;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.TreeMap;
@@ -163,6 +164,8 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
{
boolean changed = false;
LinkedList<IAEItemStack> changes = new LinkedList<IAEItemStack>();
list.resetStatus();
for (ItemSlot is : adaptor)
{
@@ -178,12 +181,12 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
if ( old != null && old.aeStack != null )
{
old.aeStack.setStackSize( -old.aeStack.getStackSize() );
postDiffrence( old.aeStack );
changes.add( old.aeStack );
}
if ( cis != null && cis.aeStack != null )
{
postDiffrence( cis.aeStack );
changes.add( cis.aeStack );
list.add( cis.aeStack );
}
@@ -208,12 +211,15 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
IAEItemStack a = stack.copy();
a.setStackSize( diff );
postDiffrence( a );
changes.add( a );
changed = true;
}
}
}
if ( !changes.isEmpty() )
postDiffrence( changes );
return changed ? TickRateModulation.URGENT : TickRateModulation.SLOWER;
}
@@ -228,7 +234,7 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
return !Platform.isSameItemPrecise( a, b );
}
private void postDiffrence(IAEItemStack a)
private void postDiffrence(Iterable<IAEItemStack> a)
{
// AELog.info( a.getItemStack().getUnlocalizedName() + " @ " + a.getStackSize() );
if ( a != null )