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)
|
||||
|
|
|
@ -19,6 +19,7 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
@ -285,9 +286,18 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
if (player.isSneaking() && !world.isRemote)
|
||||
RayTraceResult ray = this.getMovingObjectPositionFromPlayer(world, player, false);
|
||||
if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
cycleRitual(stack, player);
|
||||
return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
|
||||
}
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
cycleRitual(stack, player);
|
||||
}
|
||||
|
||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
||||
}
|
||||
|
@ -302,6 +312,12 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
{
|
||||
EntityPlayer player = (EntityPlayer) entityLiving;
|
||||
|
||||
RayTraceResult ray = this.getMovingObjectPositionFromPlayer(player.worldObj, player, false);
|
||||
if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!player.isSwingInProgress)
|
||||
{
|
||||
if (player.isSneaking())
|
||||
|
|
|
@ -94,7 +94,6 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
System.out.println("In onItemUse");
|
||||
EnumRitualReaderState state = this.getState(stack);
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof IMasterRitualStone)
|
||||
|
|
|
@ -46,7 +46,9 @@ public class RitualContainment extends Ritual
|
|||
double yDif = entity.posY - masterRitualStone.getBlockPos().getY() + 3;
|
||||
double zDif = entity.posZ - masterRitualStone.getBlockPos().getZ() + 0.5;
|
||||
|
||||
entity.setVelocity(-0.05 * xDif, -0.05 * yDif, -0.05 * zDif);
|
||||
entity.motionX = -0.05 * xDif;
|
||||
entity.motionY = -0.05 * yDif;
|
||||
entity.motionZ = -0.05 * zDif;
|
||||
entity.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,9 @@ public class RitualInterdiction extends Ritual
|
|||
double yDif = entity.posY - masterRitualStone.getBlockPos().getY() + 1;
|
||||
double zDif = entity.posZ - masterRitualStone.getBlockPos().getZ();
|
||||
|
||||
entity.setVelocity(0.1 * xDif, 0.1 * yDif, 0.1 * zDif);
|
||||
entity.motionX = 0.1 * xDif;
|
||||
entity.motionY = 0.1 * yDif;
|
||||
entity.motionZ = 0.1 * zDif;
|
||||
entity.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,19 +51,27 @@ public class RitualSpeed extends Ritual
|
|||
switch (direction)
|
||||
{
|
||||
case NORTH:
|
||||
entity.setVelocity(0, motionY, -speed);
|
||||
entity.motionX = 0;
|
||||
entity.motionY = motionY;
|
||||
entity.motionZ = -speed;
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
entity.setVelocity(0, motionY, speed);
|
||||
entity.motionX = 0;
|
||||
entity.motionY = motionY;
|
||||
entity.motionZ = speed;
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
entity.setVelocity(-speed, motionY, 0);
|
||||
entity.motionX = -speed;
|
||||
entity.motionY = motionY;
|
||||
entity.motionZ = 0;
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
entity.setVelocity(speed, motionY, 0);
|
||||
entity.motionX = speed;
|
||||
entity.motionY = motionY;
|
||||
entity.motionZ = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -90,7 +98,7 @@ public class RitualSpeed extends Ritual
|
|||
this.addRune(components, 0, 0, -2, EnumRuneType.DUSK);
|
||||
this.addRune(components, 1, 0, -1, EnumRuneType.AIR);
|
||||
this.addRune(components, -1, 0, -1, EnumRuneType.AIR);
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
this.addRune(components, 2, 0, i, EnumRuneType.AIR);
|
||||
this.addRune(components, -2, 0, i, EnumRuneType.AIR);
|
||||
|
|
|
@ -18,6 +18,7 @@ public class RitualWater extends Ritual
|
|||
{
|
||||
super("ritualWater", 0, 500, "ritual." + Constants.Mod.MODID + ".waterRitual");
|
||||
addBlockRange(WATER_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1));
|
||||
setMaximumVolumeAndDistanceOfRange(WATER_RANGE, 9, 3, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -323,7 +323,7 @@ public class TileMasterRitualStone extends TileEntity implements IMasterRitualSt
|
|||
@Override
|
||||
public void provideInformationOfRangeToPlayer(EntityPlayer player, String range)
|
||||
{
|
||||
if (this.currentRitual != null)
|
||||
if (this.currentRitual != null && this.currentRitual.getListOfRanges().contains(range))
|
||||
{
|
||||
ChatUtil.sendNoSpam(player, this.currentRitual.provideInformationOfRangeToPlayer(player, range));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue