Tidy up entity geometry stuff:

- Add a getCentre method for entities to GeometryUtils
- Replace getPositionEyes(0) with getPositionEyes(1) since it's more efficient, and by definition they must be the same
- Remove all the silly getEntityBoundingBox().minY stuff, this bug has been fixed since 1.8! (which begs the question: if it was considered a bug, how on earth did it go unfixed for that long?)
- A few other small things
This commit is contained in:
Electroblob77
2020-07-04 13:34:11 +01:00
parent 3f19e89b91
commit 8ae6bc9102
67 changed files with 109 additions and 104 deletions
@@ -160,7 +160,7 @@ public abstract class SpellRay extends Spell {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
Vec3d origin = new Vec3d(caster.posX, caster.getEntityBoundingBox().minY + caster.getEyeHeight() - Y_OFFSET, caster.posZ);
Vec3d origin = new Vec3d(caster.posX, caster.posY + caster.getEyeHeight() - Y_OFFSET, caster.posZ);
if(!this.isContinuous && world.isRemote && !Wizardry.proxy.isFirstPerson(caster)){
origin = origin.add(look.scale(1.2));
}
@@ -175,16 +175,16 @@ public abstract class SpellRay extends Spell {
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
// IDEA: Add in an aiming error and trigger onMiss accordingly
Vec3d origin = new Vec3d(caster.posX, caster.getEntityBoundingBox().minY + caster.getEyeHeight() - Y_OFFSET, caster.posZ);
Vec3d origin = new Vec3d(caster.posX, caster.posY + caster.getEyeHeight() - Y_OFFSET, caster.posZ);
Vec3d targetPos = null;
if(!ignoreLivingEntities || !EntityUtils.isLiving(target)){
targetPos = new Vec3d(target.posX, target.getEntityBoundingBox().minY + target.height / 2, target.posZ);
targetPos = new Vec3d(target.posX, target.posY + target.height / 2, target.posZ);
}else{
int x = MathHelper.floor(target.posX);
int y = (int)target.getEntityBoundingBox().minY - 1; // -1 because we need the block under the target
int y = (int)target.posY - 1; // -1 because we need the block under the target
int z = MathHelper.floor(target.posZ);
BlockPos pos = new BlockPos(x, y, z);