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
@@ -90,7 +90,7 @@ public abstract class EntityMagicArrow extends Entity implements IProjectile, IE
this.setCaster(caster);
this.setLocationAndAngles(caster.posX, caster.getEntityBoundingBox().minY + (double)caster.getEyeHeight() - LAUNCH_Y_OFFSET,
this.setLocationAndAngles(caster.posX, caster.posY + (double)caster.getEyeHeight() - LAUNCH_Y_OFFSET,
caster.posZ, caster.rotationYaw, caster.rotationPitch);
this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
@@ -117,10 +117,10 @@ public abstract class EntityMagicArrow extends Entity implements IProjectile, IE
this.setCaster(caster);
this.posY = caster.getEntityBoundingBox().minY + (double)caster.getEyeHeight() - LAUNCH_Y_OFFSET;
this.posY = caster.posY + (double)caster.getEyeHeight() - LAUNCH_Y_OFFSET;
double dx = target.posX - caster.posX;
double dy = this.doGravity() ? target.getEntityBoundingBox().minY + (double)(target.height / 3.0f) - this.posY
: target.getEntityBoundingBox().minY + (double)(target.height / 2.0f) - this.posY;
double dy = this.doGravity() ? target.posY + (double)(target.height / 3.0f) - this.posY
: target.posY + (double)(target.height / 2.0f) - this.posY;
double dz = target.posZ - caster.posZ;
double horizontalDistance = (double)MathHelper.sqrt(dx * dx + dz * dz);
@@ -48,7 +48,7 @@ public abstract class EntityMagicProjectile extends EntityThrowable implements I
/** Sets the shooter of the projectile to the given caster, positions the projectile at the given caster's eyes and
* aims it in the direction they are looking with the given speed. */
public void aim(EntityLivingBase caster, float speed){
this.setPosition(caster.posX, caster.getEntityBoundingBox().minY + (double)caster.getEyeHeight() - LAUNCH_Y_OFFSET, caster.posZ);
this.setPosition(caster.posX, caster.posY + (double)caster.getEyeHeight() - LAUNCH_Y_OFFSET, caster.posZ);
// This is the standard set of parameters for this method, used by snowballs and ender pearls amongst others.
this.shoot(caster, caster.rotationPitch, caster.rotationYaw, 0.0f, speed, 1.0f);
this.thrower = caster;
@@ -66,10 +66,10 @@ public abstract class EntityMagicProjectile extends EntityThrowable implements I
// Mojang's 'fix' for the projectile-hitting-thrower bug actually made the problem worse, hence the following line.
this.ignoreEntity = thrower;
this.posY = caster.getEntityBoundingBox().minY + (double)caster.getEyeHeight() - LAUNCH_Y_OFFSET;
this.posY = caster.posY + (double)caster.getEyeHeight() - LAUNCH_Y_OFFSET;
double dx = target.posX - caster.posX;
double dy = !this.hasNoGravity() ? target.getEntityBoundingBox().minY + (double)(target.height / 3.0f) - this.posY
: target.getEntityBoundingBox().minY + (double)(target.height / 2.0f) - this.posY;
double dy = !this.hasNoGravity() ? target.posY + (double)(target.height / 3.0f) - this.posY
: target.posY + (double)(target.height / 2.0f) - this.posY;
double dz = target.posZ - caster.posZ;
double horizontalDistance = MathHelper.sqrt(dx * dx + dz * dz);
@@ -81,7 +81,7 @@ public class EntitySparkBomb extends EntityBomb {
}else{
ParticleBuilder.create(Type.LIGHTNING).pos(this.getPositionVector()).target(target).spawn(world);
ParticleBuilder.spawnShockParticles(world, target.posX, target.getEntityBoundingBox().minY + target.height/2, target.posZ);
ParticleBuilder.spawnShockParticles(world, target.posX, target.posY + target.height/2, target.posZ);
}
}
}