diff --git a/src/main/java/appeng/parts/automation/PartImportBus.java b/src/main/java/appeng/parts/automation/PartImportBus.java index a56b5851f..24c10513a 100644 --- a/src/main/java/appeng/parts/automation/PartImportBus.java +++ b/src/main/java/appeng/parts/automation/PartImportBus.java @@ -219,8 +219,9 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin { final int toSend = this.calculateMaximumAmountToImport( myAdaptor, whatToImport, inv, fzMode ); - if( toSend == 0 ){ - return false; + if( toSend == 0 ) + { + return true; } final ItemStack newItems; @@ -291,9 +292,14 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin itemAmountNotStorable = inv.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source ); } + if( simResult.isEmpty() ) + { + return 0; + } + if( itemAmountNotStorable != null ) { - if (simResult.getCount() == itemAmountNotStorable.getStackSize()) + if( simResult.getCount() == itemAmountNotStorable.getStackSize() ) { return 0; } diff --git a/src/main/java/appeng/parts/misc/ItemRepositoryAdapter.java b/src/main/java/appeng/parts/misc/ItemRepositoryAdapter.java index 1de85f50d..bcd7886fb 100644 --- a/src/main/java/appeng/parts/misc/ItemRepositoryAdapter.java +++ b/src/main/java/appeng/parts/misc/ItemRepositoryAdapter.java @@ -71,13 +71,24 @@ class ItemRepositoryAdapter implements IMEInventory, IBaseMonitor< if( type == Actionable.MODULATE ) { - try + if (this.cache.cachedAeStacks.length == 0) this.cache.update(); + boolean found = false; + for (IAEItemStack iaeItemStack : this.cache.cachedAeStacks) { - this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() ); + if( iaeItemStack == null ) + { + continue; + } + if( iaeItemStack.equals( iox ) ) + { + found = true; + iaeItemStack.incStackSize( iox.getStackSize() ); + } } - catch( GridAccessException ex ) + if (!found) { - // meh + this.cache.cachedAeStacks = Arrays.copyOf( this.cache.cachedAeStacks, this.cache.cachedAeStacks.length + 1 ); + this.cache.cachedAeStacks[this.cache.cachedAeStacks.length - 1] = iox.copy(); } } @@ -107,15 +118,27 @@ class ItemRepositoryAdapter implements IMEInventory, IBaseMonitor< if( !extracted.isEmpty() ) { + if (this.cache.cachedAeStacks.length == 0) this.cache.update(); + IAEItemStack iaeExtracted = AEItemStack.fromItemStack( extracted ); + if( mode == Actionable.MODULATE ) { - try + for ( int i = 0; i < this.cache.cachedAeStacks.length; i++ ) { - this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() ); - } - catch( GridAccessException ex ) - { - // meh + IAEItemStack iaeItemStack = this.cache.cachedAeStacks[i]; + if( iaeExtracted.equals( iaeItemStack ) ) + { + if( iaeExtracted.getStackSize() >= iaeItemStack.getStackSize() ) + { + iaeExtracted.decStackSize( iaeItemStack.getStackSize() ); + this.cache.cachedAeStacks[i] = null; + } + else + { + iaeItemStack.decStackSize( iaeExtracted.getStackSize() ); + break; + } + } } }