Storage bus can now update all the way down to zero items for External Storages.
This commit is contained in:
parent
e1c6b18399
commit
60d1ecc965
2 changed files with 23 additions and 5 deletions
|
@ -18,6 +18,7 @@ public class IMEAdaptor extends InventoryAdaptor
|
|||
|
||||
IMEInventory<IAEItemStack> target;
|
||||
BaseActionSource src;
|
||||
int maxSlots = 0;
|
||||
|
||||
public IMEAdaptor(IMEInventory<IAEItemStack> input, BaseActionSource src) {
|
||||
target = input;
|
||||
|
@ -32,7 +33,7 @@ public class IMEAdaptor extends InventoryAdaptor
|
|||
@Override
|
||||
public Iterator<ItemSlot> iterator()
|
||||
{
|
||||
return new IMEAdaptorIterator( getList() );
|
||||
return new IMEAdaptorIterator( this, getList() );
|
||||
}
|
||||
|
||||
public ItemStack doRemoveItemsFuzzy(int how_many, ItemStack Filter, IInventoryDestination destination, Actionable type, FuzzyMode fuzzyMode)
|
||||
|
|
|
@ -11,23 +11,40 @@ public class IMEAdaptorIterator implements Iterator<ItemSlot>
|
|||
Iterator<IAEItemStack> stack;
|
||||
ItemSlot slot = new ItemSlot();
|
||||
int offset = 0;
|
||||
boolean hasNext;
|
||||
|
||||
public IMEAdaptorIterator(IItemList<IAEItemStack> availableItems) {
|
||||
final IMEAdaptor parent;
|
||||
final int containerSize;
|
||||
|
||||
public IMEAdaptorIterator(IMEAdaptor parent, IItemList<IAEItemStack> availableItems) {
|
||||
stack = availableItems.iterator();
|
||||
containerSize = parent.maxSlots;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return stack.hasNext();
|
||||
hasNext = stack.hasNext();
|
||||
return offset < containerSize || hasNext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemSlot next()
|
||||
{
|
||||
slot.slot = offset++;
|
||||
|
||||
if ( parent.maxSlots < offset )
|
||||
parent.maxSlots = offset;
|
||||
|
||||
if ( hasNext )
|
||||
{
|
||||
IAEItemStack item = stack.next();
|
||||
slot.setAEItemStack( item );
|
||||
slot.slot = offset++;
|
||||
return slot;
|
||||
}
|
||||
|
||||
slot.setItemStack( null );
|
||||
return slot;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue