Added better method for creating a range for a ritual.

This commit is contained in:
WayofTime 2015-12-30 16:19:50 -05:00
parent e48eedb874
commit 8b582bc0c4
3 changed files with 68 additions and 39 deletions

View file

@ -8,14 +8,63 @@ import net.minecraft.util.BlockPos;
public class AreaDescriptor
{
public List<BlockPos> getContainedPositions()
public List<BlockPos> getContainedPositions(BlockPos pos)
{
return new ArrayList();
return new ArrayList<BlockPos>();
}
public AxisAlignedBB getAABB()
public AxisAlignedBB getAABB(BlockPos pos)
{
return null;
}
public static class Rectangle extends AreaDescriptor
{
private BlockPos minimumOffset;
private BlockPos maximumOffset;
public Rectangle(BlockPos minimumOffset, BlockPos maximumOffset)
{
setOffsets(minimumOffset, maximumOffset);
}
@Override
public List<BlockPos> getContainedPositions(BlockPos pos)
{
ArrayList<BlockPos> posList = new ArrayList<BlockPos>();
for (int i = minimumOffset.getX(); i <= maximumOffset.getX(); i++)
{
for (int j = minimumOffset.getY(); j <= maximumOffset.getY(); j++)
{
for (int k = minimumOffset.getZ(); k <= maximumOffset.getZ(); k++)
{
posList.add(pos.add(i, j, k));
}
}
}
return posList;
}
@Override
public AxisAlignedBB getAABB(BlockPos pos)
{
AxisAlignedBB tempAABB = new AxisAlignedBB(minimumOffset, maximumOffset);
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()));
}
}
}

View file

@ -31,7 +31,7 @@ public abstract class Ritual
private final RitualRenderer renderer;
private final String unlocalizedName;
private final Map<String, BlockPos[]> modableRangeMap = new HashMap<String, BlockPos[]>();
private final Map<String, AreaDescriptor> modableRangeMap = new HashMap<String, AreaDescriptor>();
/**
* @param name
@ -106,30 +106,26 @@ public abstract class Ritual
return 20;
}
public void addBlockRange(String range, BlockPos[] defaultRange)
public void addBlockRange(String range, AreaDescriptor defaultRange)
{
modableRangeMap.put(range, defaultRange);
}
/**
* Used to grab the range of a ritual for a given effect. The order of the
* blockPos array is: bottom corner, top corner.
* Used to grab the range of a ritual for a given effect.
*
* @param range
* - Range that needs to be pulled.
* @return - The range of the ritual effect. Array must be of size 2 and
* have non-null values, with the first BlockPos having the lower
* offset values and the second BlockPos having the higher offset
* values
* @return -
*/
public BlockPos[] getBlockRange(String range)
public AreaDescriptor getBlockRange(String range)
{
if (modableRangeMap.containsKey(range))
{
return modableRangeMap.get(range);
}
return new BlockPos[] { new BlockPos(0, 0, 0), new BlockPos(0, 0, 0) };
return null;
}
/**