Added Haste Sigil array (not implemented). First attempt at making AreaDescriptor an Iterator<BlockPos>

This commit is contained in:
WayofTime 2016-02-02 18:16:55 -05:00
parent 271be45871
commit d9f58ceb1e
2 changed files with 71 additions and 1 deletions

View file

@ -2,12 +2,14 @@ package WayofTime.bloodmagic.api.ritual;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
public abstract class AreaDescriptor
public abstract class AreaDescriptor implements Iterator<BlockPos>
{
public List<BlockPos> getContainedPositions(BlockPos pos)
{
@ -27,6 +29,7 @@ public abstract class AreaDescriptor
{
private BlockPos minimumOffset;
private BlockPos maximumOffset; // Non-inclusive maximum offset.
private BlockPos currentPosition;
private ArrayList<BlockPos> blockPosCache;
private BlockPos cachedPosition;
@ -121,6 +124,45 @@ public abstract class AreaDescriptor
return x >= minimumOffset.getX() && x < maximumOffset.getX() && y >= minimumOffset.getY() && y < maximumOffset.getY() && z >= minimumOffset.getZ() && z < maximumOffset.getZ();
}
@Override
public void forEachRemaining(Consumer<? super BlockPos> action)
{
while (hasNext())
{
action.accept(next());
}
}
@Override
public boolean hasNext()
{
// TODO Auto-generated method stub
return false;
}
@Override
public BlockPos next()
{
if (currentPosition != null)
{
int nextX = currentPosition.getX() + 1 >= maximumOffset.getX() ? minimumOffset.getX() : currentPosition.getX() + 1;
int nextZ = nextX == minimumOffset.getX() ? currentPosition.getZ() : (currentPosition.getZ() + 1 >= maximumOffset.getZ() ? minimumOffset.getZ() : currentPosition.getZ() + 1);
int nextY = nextZ == minimumOffset.getZ() ? currentPosition.getY() : currentPosition.getY() + 1;
currentPosition = new BlockPos(nextX, nextY, nextZ);
} else
{
currentPosition = minimumOffset;
}
return cachedPosition.add(currentPosition);
}
@Override
public void remove()
{
}
}
public static class HemiSphere extends AreaDescriptor
@ -209,5 +251,33 @@ public abstract class AreaDescriptor
{
return blockPosCache.contains(pos);
}
@Override
public void forEachRemaining(Consumer<? super BlockPos> arg0)
{
// TODO Auto-generated method stub
}
@Override
public boolean hasNext()
{
// TODO Auto-generated method stub
return false;
}
@Override
public BlockPos next()
{
// TODO Auto-generated method stub
return null;
}
@Override
public void remove()
{
// TODO Auto-generated method stub
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB