diff --git a/src/main/java/appeng/parts/misc/ItemHandlerAdapter.java b/src/main/java/appeng/parts/misc/ItemHandlerAdapter.java index ff75b6c34..4769445c2 100644 --- a/src/main/java/appeng/parts/misc/ItemHandlerAdapter.java +++ b/src/main/java/appeng/parts/misc/ItemHandlerAdapter.java @@ -73,7 +73,6 @@ class ItemHandlerAdapter implements IMEInventory, IBaseMonitor, IBaseMonitor countPre ) + else if( countPos < countPre ) { injectedList.add( Pair.of( i, countPos - countPre ) ); } @@ -107,20 +106,27 @@ class ItemHandlerAdapter implements IMEInventory, IBaseMonitor pair : injectedList ) + if( this.cache.cachedAeStacks.length == 0 ) { - if (pair.getKey() >= this.cache.cachedAeStacks.length) + this.cache.update(); + } + else + { + for( Pair pair : injectedList ) { - this.cache.update(); - break; - } - if( this.cache.cachedAeStacks[pair.getKey()] == null ) - { - this.cache.cachedAeStacks[pair.getKey()] = iox.copy().setStackSize( pair.getValue() ); - } - else - { - this.cache.cachedAeStacks[pair.getKey()].incStackSize( pair.getValue() ); + if( pair.getKey() >= this.cache.cachedAeStacks.length ) + { + this.cache.update(); + break; + } + if( this.cache.cachedAeStacks[pair.getKey()] == null ) + { + this.cache.cachedAeStacks[pair.getKey()] = iox.copy().setStackSize( pair.getValue() ); + } + else + { + this.cache.cachedAeStacks[pair.getKey()].incStackSize( pair.getValue() ); + } } } @@ -206,20 +212,21 @@ class ItemHandlerAdapter implements IMEInventory, IBaseMonitor pair : extractedList ) + if( this.cache.cachedAeStacks.length == 0 ) { - if (pair.getKey() >= this.cache.cachedAeStacks.length) + this.cache.update(); + } + else + { + for( Pair pair : extractedList ) { - this.cache.update(); - break; - } - if( this.cache.cachedAeStacks[pair.getKey()] != null ) - { - this.cache.cachedAeStacks[pair.getKey()].decStackSize( pair.getValue() ); - if( this.cache.cachedAeStacks[pair.getKey()].getStackSize() == 0 ) + if( this.cache.cachedAeStacks[pair.getKey()] != null ) { - this.cache.cachedAeStacks[pair.getKey()] = null; + this.cache.cachedAeStacks[pair.getKey()].decStackSize( pair.getValue() ); + if( this.cache.cachedAeStacks[pair.getKey()].getStackSize() == 0 ) + { + this.cache.cachedAeStacks[pair.getKey()] = null; + } } } }