2014-05-04 02:21:33 +02:00
|
|
|
package appeng.util.inv;
|
|
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
|
|
|
import appeng.api.storage.data.IAEItemStack;
|
|
|
|
import appeng.api.storage.data.IItemList;
|
|
|
|
|
|
|
|
public class IMEAdaptorIterator implements Iterator<ItemSlot>
|
|
|
|
{
|
|
|
|
|
|
|
|
Iterator<IAEItemStack> stack;
|
|
|
|
ItemSlot slot = new ItemSlot();
|
|
|
|
int offset = 0;
|
2014-05-04 06:14:30 +02:00
|
|
|
boolean hasNext;
|
2014-05-04 02:21:33 +02:00
|
|
|
|
2014-05-04 06:14:30 +02:00
|
|
|
final IMEAdaptor parent;
|
|
|
|
final int containerSize;
|
|
|
|
|
|
|
|
public IMEAdaptorIterator(IMEAdaptor parent, IItemList<IAEItemStack> availableItems) {
|
2014-05-04 02:21:33 +02:00
|
|
|
stack = availableItems.iterator();
|
2014-05-04 06:14:30 +02:00
|
|
|
containerSize = parent.maxSlots;
|
|
|
|
this.parent = parent;
|
2014-05-04 02:21:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasNext()
|
|
|
|
{
|
2014-05-04 06:14:30 +02:00
|
|
|
hasNext = stack.hasNext();
|
|
|
|
return offset < containerSize || hasNext;
|
2014-05-04 02:21:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemSlot next()
|
|
|
|
{
|
|
|
|
slot.slot = offset++;
|
2014-05-04 06:14:30 +02:00
|
|
|
|
|
|
|
if ( parent.maxSlots < offset )
|
|
|
|
parent.maxSlots = offset;
|
|
|
|
|
|
|
|
if ( hasNext )
|
|
|
|
{
|
|
|
|
IAEItemStack item = stack.next();
|
|
|
|
slot.setAEItemStack( item );
|
|
|
|
return slot;
|
|
|
|
}
|
|
|
|
|
|
|
|
slot.setItemStack( null );
|
2014-05-04 02:21:33 +02:00
|
|
|
return slot;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void remove()
|
|
|
|
{
|
|
|
|
throw new RuntimeException( "Not Implemented!" );
|
|
|
|
}
|
|
|
|
}
|