Did more work on the Ritual Reader. Fixed issue with the Ritual Diviner cycling its direction when you right click on the MRS.
This commit is contained in:
parent
057a951732
commit
9fe525b74b
10 changed files with 148 additions and 16 deletions
|
@ -39,6 +39,10 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
|
||||
}
|
||||
|
||||
public abstract int getVolumeForOffsets(BlockPos offset1, BlockPos offset2);
|
||||
|
||||
public abstract boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit);
|
||||
|
||||
/**
|
||||
* This method changes the area descriptor so that its range matches the two
|
||||
* blocks that are selected. When implementing this method, assume that
|
||||
|
@ -219,6 +223,26 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
tag.setInteger(Constants.NBT.Y_COORD + "max", maximumOffset.getY());
|
||||
tag.setInteger(Constants.NBT.Z_COORD + "max", maximumOffset.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVolumeForOffsets(BlockPos offset1, BlockPos offset2)
|
||||
{
|
||||
BlockPos minPos = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ()));
|
||||
BlockPos maxPos = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ()));
|
||||
|
||||
maxPos = maxPos.add(1, 1, 1);
|
||||
|
||||
return (maxPos.getX() - minPos.getX()) * (maxPos.getY() - minPos.getY()) * (maxPos.getZ() - minPos.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit)
|
||||
{
|
||||
BlockPos minPos = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ()));
|
||||
BlockPos maxPos = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ()));
|
||||
|
||||
return minPos.getY() >= -verticalLimit && maxPos.getY() <= verticalLimit && minPos.getX() >= -horizontalLimit && maxPos.getX() <= horizontalLimit && minPos.getZ() >= -horizontalLimit && maxPos.getZ() <= horizontalLimit;
|
||||
}
|
||||
}
|
||||
|
||||
public static class HemiSphere extends AreaDescriptor
|
||||
|
@ -348,6 +372,20 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Cross extends AreaDescriptor
|
||||
|
@ -441,5 +479,19 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,9 @@ public abstract class Ritual
|
|||
private final String unlocalizedName;
|
||||
|
||||
protected final Map<String, AreaDescriptor> modableRangeMap = new HashMap<String, AreaDescriptor>();
|
||||
protected final Map<String, Integer> volumeRangeMap = new HashMap<String, Integer>();
|
||||
protected final Map<String, Integer> horizontalRangeMap = new HashMap<String, Integer>();
|
||||
protected final Map<String, Integer> verticalRangeMap = new HashMap<String, Integer>();
|
||||
|
||||
/**
|
||||
* @param name
|
||||
|
@ -216,7 +219,7 @@ public abstract class Ritual
|
|||
public boolean setBlockRangeByBounds(String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2)
|
||||
{
|
||||
AreaDescriptor descriptor = this.getBlockRange(range);
|
||||
if (canBlockRangeBeModified(descriptor, master, offset1, offset2))
|
||||
if (canBlockRangeBeModified(range, descriptor, master, offset1, offset2))
|
||||
{
|
||||
descriptor.modifyAreaByBlockPositions(offset1, offset2);
|
||||
return true;
|
||||
|
@ -225,14 +228,40 @@ public abstract class Ritual
|
|||
return false;
|
||||
}
|
||||
|
||||
protected boolean canBlockRangeBeModified(AreaDescriptor descriptor, IMasterRitualStone master, BlockPos offset1, BlockPos offset2)
|
||||
protected boolean canBlockRangeBeModified(String range, AreaDescriptor descriptor, IMasterRitualStone master, BlockPos offset1, BlockPos offset2)
|
||||
{
|
||||
return true;
|
||||
int maxVolume = volumeRangeMap.get(range);
|
||||
int maxVertical = verticalRangeMap.get(range);
|
||||
int maxHorizontal = horizontalRangeMap.get(range);
|
||||
|
||||
return (maxVolume <= 0 || descriptor.getVolumeForOffsets(offset1, offset2) <= maxVolume) && descriptor.isWithinRange(offset1, offset2, maxVertical, maxHorizontal);
|
||||
}
|
||||
|
||||
protected void setMaximumVolumeAndDistanceOfRange(String range, int volume, int horizontalRadius, int verticalRadius)
|
||||
{
|
||||
volumeRangeMap.put(range, volume);
|
||||
horizontalRangeMap.put(range, horizontalRadius);
|
||||
verticalRangeMap.put(range, verticalRadius);
|
||||
}
|
||||
|
||||
public ITextComponent getErrorForBlockRangeOnFail(EntityPlayer player, String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2)
|
||||
{
|
||||
return new TextComponentTranslation("ritual.BloodMagic.blockRange.tooBig");
|
||||
AreaDescriptor descriptor = this.getBlockRange(range);
|
||||
if (descriptor == null)
|
||||
{
|
||||
return new TextComponentTranslation("ritual.BloodMagic.blockRange.tooBig", "?");
|
||||
}
|
||||
int maxVolume = volumeRangeMap.get(range);
|
||||
int maxVertical = verticalRangeMap.get(range);
|
||||
int maxHorizontal = horizontalRangeMap.get(range);
|
||||
|
||||
if (maxVolume > 0 && descriptor.getVolumeForOffsets(offset1, offset2) > maxVolume)
|
||||
{
|
||||
return new TextComponentTranslation("ritual.BloodMagic.blockRange.tooBig", maxVolume);
|
||||
} else
|
||||
{
|
||||
return new TextComponentTranslation("ritual.BloodMagic.blockRange.tooFar", maxVertical, maxHorizontal);
|
||||
}
|
||||
}
|
||||
|
||||
public ITextComponent provideInformationOfRitualToPlayer(EntityPlayer player)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue