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:
parent
2dc1b4ec05
commit
10eab71f32
1 changed files with 23 additions and 5 deletions
|
@ -3,6 +3,7 @@ package appeng.me.storage;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.NavigableMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
@ -164,12 +165,15 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
|
||||||
{
|
{
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
LinkedList<IAEItemStack> changes = new LinkedList<IAEItemStack>();
|
LinkedList<IAEItemStack> changes = new LinkedList<IAEItemStack>();
|
||||||
|
|
||||||
|
int high = 0;
|
||||||
list.resetStatus();
|
list.resetStatus();
|
||||||
for (ItemSlot is : adaptor)
|
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 newIS = is == null || is.isExtractable == false && mode == StorageFilter.EXTACTABLE_ONLY ? null : is.getItemStack();
|
||||||
ItemStack oldIS = old == null ? null : old.itemStack;
|
ItemStack oldIS = old == null ? null : old.itemStack;
|
||||||
|
|
||||||
|
@ -215,8 +219,22 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
|
||||||
changed = true;
|
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() )
|
if ( !changes.isEmpty() )
|
||||||
postDiffrence( changes );
|
postDiffrence( changes );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue