AE2 First Commit, the dawn of 1.7 hast arrived.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package appeng.util.iterators;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class ChainedIterator<T> implements Iterator<T>
|
||||
{
|
||||
|
||||
int offset = 0;
|
||||
T[] list;
|
||||
|
||||
public ChainedIterator(T... list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return offset < list.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next()
|
||||
{
|
||||
return list[offset++];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
throw new RuntimeException( "Not implemented." );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package appeng.util.iterators;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class NullIterator<T> implements Iterator<T>
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package appeng.util.iterators;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
|
||||
public class ProxyNodeIterator implements Iterator<IGridNode>
|
||||
{
|
||||
|
||||
Iterator<IGridHost> hosts;
|
||||
|
||||
public ProxyNodeIterator(Iterator<IGridHost> hosts) {
|
||||
this.hosts = hosts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return hosts.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode next()
|
||||
{
|
||||
IGridHost host = hosts.next();
|
||||
return host.getGridNode( ForgeDirection.UNKNOWN );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
throw new RuntimeException( "Not implemented." );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package appeng.util.iterators;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.util.inv.ItemSlot;
|
||||
|
||||
public class StackToSlotIterator implements Iterator<ItemSlot>
|
||||
{
|
||||
|
||||
int x = 0;
|
||||
final ItemSlot iss = new ItemSlot();
|
||||
final Iterator<ItemStack> is;
|
||||
|
||||
public StackToSlotIterator(Iterator<ItemStack> is) {
|
||||
this.is = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return is.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemSlot next()
|
||||
{
|
||||
iss.slot = x++;
|
||||
iss.itemStack = is.next();
|
||||
return iss;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
// uhh no.
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user