2015-12-30 20:24:25 +00:00
|
|
|
package WayofTime.bloodmagic.api.ritual;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.BlockPos;
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
public class AreaDescriptor
|
|
|
|
{
|
2015-12-30 21:19:50 +00:00
|
|
|
public List<BlockPos> getContainedPositions(BlockPos pos)
|
2015-12-30 20:34:40 +00:00
|
|
|
{
|
2015-12-30 21:19:50 +00:00
|
|
|
return new ArrayList<BlockPos>();
|
2015-12-30 20:34:40 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 21:19:50 +00:00
|
|
|
public AxisAlignedBB getAABB(BlockPos pos)
|
2015-12-30 20:34:40 +00:00
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2015-12-30 21:19:50 +00:00
|
|
|
|
|
|
|
public static class Rectangle extends AreaDescriptor
|
|
|
|
{
|
|
|
|
private BlockPos minimumOffset;
|
|
|
|
private BlockPos maximumOffset;
|
|
|
|
|
2015-12-31 13:01:39 +00:00
|
|
|
private ArrayList<BlockPos> blockPosCache = new ArrayList<BlockPos>();
|
|
|
|
private BlockPos cachedPosition = new BlockPos(0, 0, 0);
|
|
|
|
|
2015-12-30 21:19:50 +00:00
|
|
|
public Rectangle(BlockPos minimumOffset, BlockPos maximumOffset)
|
|
|
|
{
|
|
|
|
setOffsets(minimumOffset, maximumOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<BlockPos> getContainedPositions(BlockPos pos)
|
|
|
|
{
|
2015-12-31 13:01:39 +00:00
|
|
|
if (!pos.equals(cachedPosition) || blockPosCache.isEmpty())
|
2015-12-30 21:19:50 +00:00
|
|
|
{
|
2015-12-31 13:01:39 +00:00
|
|
|
ArrayList<BlockPos> posList = new ArrayList<BlockPos>();
|
|
|
|
|
|
|
|
for (int i = minimumOffset.getX(); i <= maximumOffset.getX(); i++)
|
2015-12-30 21:19:50 +00:00
|
|
|
{
|
2015-12-31 13:01:39 +00:00
|
|
|
for (int j = minimumOffset.getY(); j <= maximumOffset.getY(); j++)
|
2015-12-30 21:19:50 +00:00
|
|
|
{
|
2015-12-31 13:01:39 +00:00
|
|
|
for (int k = minimumOffset.getZ(); k <= maximumOffset.getZ(); k++)
|
|
|
|
{
|
|
|
|
posList.add(pos.add(i, j, k));
|
|
|
|
}
|
2015-12-30 21:19:50 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-31 13:01:39 +00:00
|
|
|
|
|
|
|
blockPosCache = posList;
|
|
|
|
cachedPosition = pos;
|
2015-12-30 21:19:50 +00:00
|
|
|
}
|
|
|
|
|
2015-12-31 13:01:39 +00:00
|
|
|
|
|
|
|
return blockPosCache;
|
2015-12-30 21:19:50 +00:00
|
|
|
}
|
2015-12-31 13:01:39 +00:00
|
|
|
|
2015-12-30 21:19:50 +00:00
|
|
|
@Override
|
|
|
|
public AxisAlignedBB getAABB(BlockPos pos)
|
|
|
|
{
|
2015-12-31 15:05:38 +00:00
|
|
|
AxisAlignedBB tempAABB = new AxisAlignedBB(minimumOffset.getX(), minimumOffset.getY(), minimumOffset.getZ(), maximumOffset.getX() + 1, maximumOffset.getY() + 1, maximumOffset.getZ() + 1);
|
2015-12-30 21:19:50 +00:00
|
|
|
return tempAABB.offset(pos.getX(), pos.getY(), pos.getZ());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the offsets of the AreaDescriptor in a safe way that will make
|
|
|
|
* minimumOffset the lowest corner
|
|
|
|
*
|
|
|
|
* @param offset1
|
|
|
|
* @param offset2
|
|
|
|
*/
|
|
|
|
public void setOffsets(BlockPos offset1, BlockPos offset2)
|
|
|
|
{
|
|
|
|
this.minimumOffset = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ()));
|
|
|
|
this.maximumOffset = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ()));
|
2015-12-31 13:01:39 +00:00
|
|
|
blockPosCache = new ArrayList<BlockPos>();
|
2015-12-30 21:19:50 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-30 20:24:25 +00:00
|
|
|
}
|