parent
e13d5097b3
commit
3c8c773e2f
1 changed files with 26 additions and 21 deletions
|
@ -3,8 +3,8 @@ 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.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -30,7 +30,8 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
|
|||
class CachedItemStack
|
||||
{
|
||||
|
||||
public CachedItemStack(ItemStack is) {
|
||||
public CachedItemStack(ItemStack is)
|
||||
{
|
||||
if ( is == null )
|
||||
{
|
||||
itemStack = null;
|
||||
|
@ -68,7 +69,8 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
|
|||
listeners.remove( l );
|
||||
}
|
||||
|
||||
public MEMonitorIInventory(InventoryAdaptor adaptor) {
|
||||
public MEMonitorIInventory(InventoryAdaptor adaptor)
|
||||
{
|
||||
this.adaptor = adaptor;
|
||||
memory = new TreeMap();
|
||||
}
|
||||
|
@ -165,15 +167,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 );
|
||||
high = Math.max( high, 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;
|
||||
|
||||
|
@ -219,22 +221,25 @@ 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;
|
||||
NavigableMap<Integer, CachedItemStack> end = memory.tailMap( high, false );
|
||||
if ( !end.isEmpty() )
|
||||
{
|
||||
for (CachedItemStack cis : end.values())
|
||||
{
|
||||
if ( cis != null )
|
||||
{
|
||||
IAEItemStack a = cis.aeStack.copy();
|
||||
a.setStackSize( -a.getStackSize() );
|
||||
changes.add( a );
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
end.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( !changes.isEmpty() )
|
||||
postDiffrence( changes );
|
||||
|
||||
|
|
Loading…
Reference in a new issue