diff --git a/me/storage/MEMonitorIInventory.java b/me/storage/MEMonitorIInventory.java index 92c68fbb..981738eb 100644 --- a/me/storage/MEMonitorIInventory.java +++ b/me/storage/MEMonitorIInventory.java @@ -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, 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, 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, IMEMonit { boolean changed = false; - LinkedList changes = new LinkedList(); - + LinkedList changes = new LinkedList(); + 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, IMEMonit changed = true; } } - } - + } + // detect dropped items; should fix non IISided Inventory Changes. - NavigableMap 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 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 );