Fix a bug where IInventories that change size may appear to contain items that were present in removed portion of the inventory.

This commit is contained in:
AlgorithmX2 2014-09-15 14:28:23 -05:00
parent 2dc1b4ec05
commit 10eab71f32

View file

@ -3,6 +3,7 @@ package appeng.me.storage;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.NavigableMap;
import java.util.Map.Entry;
import java.util.TreeMap;
@ -164,12 +165,15 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
{
boolean changed = false;
LinkedList<IAEItemStack> changes = new LinkedList<IAEItemStack>();
LinkedList<IAEItemStack> changes = new LinkedList<IAEItemStack>();
int high = 0;
list.resetStatus();
for (ItemSlot is : adaptor)
{
CachedItemStack old = memory.get( is.slot );
CachedItemStack old = memory.get( is.slot );
high = Math.max( high, is.slot );
ItemStack newIS = is == null || is.isExtractable == false && mode == StorageFilter.EXTACTABLE_ONLY ? null : is.getItemStack();
ItemStack oldIS = old == null ? null : old.itemStack;
@ -215,8 +219,22 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
changed = true;
}
}
}
}
// detect dropped items; should fix non IISided Inventory Changes.
NavigableMap<Integer,CachedItemStack> end = memory.tailMap( high, false );
if ( ! end.isEmpty() )
{
for ( CachedItemStack cis : end.values() )
{
IAEItemStack a = cis.aeStack.copy();
a.setStackSize( - a.getStackSize() );
changes.add( a );
changed = true;
}
end.clear();
}
if ( !changes.isEmpty() )
postDiffrence( changes );