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:
WayofTime 2016-04-11 08:26:41 -04:00
parent 057a951732
commit 9fe525b74b
10 changed files with 148 additions and 16 deletions

View file

@ -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;
}
}
}

View file

@ -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)

View file

@ -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())

View file

@ -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)

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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);

View file

@ -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

View file

@ -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));
}

View file

@ -369,7 +369,8 @@ tooltip.BloodMagic.experienceTome.exp=Exp: %0.3f
tooltip.BloodMagic.experienceTome.expLevel=Level: %d
# Ritual
ritual.BloodMagic.blockRange.tooBig=The block range given is either too big or too far away from the MRS!
ritual.BloodMagic.blockRange.tooBig=The block range given is too big! Needs to be at most %s blocks.
ritual.BloodMagic.blockRange.tooFar=The block range given is too far! Needs to be within a vertical range of %s blocks and a horizontal range of %s blocks.
ritual.BloodMagic.blockRange.inactive=The ritual stone is currently inactive, and cannot have its range modified.
ritual.BloodMagic.blockRange.noRange=The range was not properly chosen.
ritual.BloodMagic.blockRange.firstBlock=First block for new range stored.
@ -405,7 +406,29 @@ ritual.BloodMagic.pumpRitual=Hymn of Siphoning
ritual.BloodMagic.altarBuilderRitual=The Assembly of the High Altar
ritual.BloodMagic.portalRitual=The Gate of the Fold
ritual.BloodMagic.waterRitual.info=Generates a source of water from the master ritual stone.
ritual.BloodMagic.lavaRitual.info=Generates a source of lava from the master ritual stone.
ritual.BloodMagic.greenGroveRitual.info=Grows crops within its area.
ritual.BloodMagic.jumpRitual.info=Causes entities to leap up into the air.
ritual.BloodMagic.wellOfSufferingRitual.info=Attacks mobs within its damage zone and puts the LP into a nearby blood altar.
ritual.BloodMagic.featheredKnifeRitual.info=Drains health from players in its area and puts the LP into a nearby blood altar.
ritual.BloodMagic.regenerationRitual.info=Casts regeneration on entities within its range if they are missing health.
ritual.BloodMagic.harvestRitual.info=Harvests plants within its range, dropping the results on the ground.
ritual.BloodMagic.magneticRitual.info=Pulls up ores from the ground and puts them into its placement range.
ritual.BloodMagic.crushingRitual.info=Breaks blocks within its crushing range and places the items into the linked chest.
ritual.BloodMagic.fullStomachRitual.info=Takes food from the linked chest and fills the player's saturation with it.
ritual.BloodMagic.interdictionRitual.info=Pushes all mobs within its area away from the master ritual stone.
ritual.BloodMagic.containmentRitual.info=Pulls all mobs within its area towards the master ritual stone.
ritual.BloodMagic.speedRitual.info=Launches players within its range in the direction of the ritual.
ritual.BloodMagic.suppressionRitual.info=
ritual.BloodMagic.expulsionRitual.info=
ritual.BloodMagic.zephyrRitual.info=
ritual.BloodMagic.upgradeRemoveRitual.info=
ritual.BloodMagic.armourEvolveRitual.info=
ritual.BloodMagic.animalGrowthRitual.info=
ritual.BloodMagic.forsakenSoulRitual.info=
ritual.BloodMagic.wellOfSufferingRitual.altar.info=(Altar) This range defines the area that the ritual searches for the blood altar. Changing this will either expand or limit the range to a certain region.
ritual.BloodMagic.wellOfSufferingRitual.damage.info=(Damage) This defines where the ritual will damage a mob. All mobs inside of this range (except for players) will receive damage over time.
# Chat