Fixes #2699: Do not trust the stackSize in case of internal changes.

An external inventory might change the stacksize of the slot we currently
are extracting from. Thus we have to cache the initial stackSize for a later
calculation of the extracted amount per slot.
As other inventories might NOT change the stacksize after a modification,
we can not use the stack reaching 0 as conditions to break.
This commit is contained in:
yueh 2016-12-14 11:25:49 +01:00
parent a2b20f1d67
commit a3c85b4a59
1 changed files with 3 additions and 2 deletions

View File

@ -117,7 +117,8 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
}
ItemStack extracted;
int remainingCurrentSlot = Math.min( remainingSize, stackInInventorySlot.stackSize );
int stackSizeCurrentSlot = stackInInventorySlot.stackSize;
int remainingCurrentSlot = Math.min( remainingSize, stackSizeCurrentSlot );
// We have to loop here because according to the docs, the handler shouldn't return a stack with size >
// maxSize, even if we request more. So even if it returns a valid stack, it might have more stuff.
@ -149,7 +150,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
}
while( extracted != null && remainingCurrentSlot > 0 );
remainingSize -= stackInInventorySlot.stackSize - remainingCurrentSlot;
remainingSize -= stackSizeCurrentSlot - remainingCurrentSlot;
// Done?
if( remainingSize <= 0 )