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
@@ -281,7 +281,7 @@ public final class WizardryEventHandler {
.target(attacker).spawn(world); .target(attacker).spawn(world);
ParticleBuilder.spawnShockParticles(world, attacker.posX, ParticleBuilder.spawnShockParticles(world, attacker.posX,
attacker.getEntityBoundingBox().minY + attacker.height / 2, attacker.posZ); attacker.posY + attacker.height / 2, attacker.posZ);
} }
DamageSafetyChecker.attackEntitySafely(attacker, MagicDamage.causeDirectMagicDamage(event.getEntityLiving(), DamageSafetyChecker.attackEntitySafely(attacker, MagicDamage.causeDirectMagicDamage(event.getEntityLiving(),
@@ -3,6 +3,7 @@ package electroblob.wizardry.client.animation;
import electroblob.wizardry.data.WizardData; import electroblob.wizardry.data.WizardData;
import electroblob.wizardry.item.SpellActions; import electroblob.wizardry.item.SpellActions;
import electroblob.wizardry.spell.Grapple; import electroblob.wizardry.spell.Grapple;
import electroblob.wizardry.util.GeometryUtils;
import electroblob.wizardry.util.InventoryUtils; import electroblob.wizardry.util.InventoryUtils;
import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelBiped;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
@@ -100,7 +101,7 @@ public abstract class ActionAnimation extends Animation {
if(hit.entityHit instanceof EntityLivingBase){ if(hit.entityHit instanceof EntityLivingBase){
// If the target is an entity, we need to use the entity's centre rather than the original hit position // If the target is an entity, we need to use the entity's centre rather than the original hit position
// because the entity will have moved! // because the entity will have moved!
target = new Vec3d(hit.entityHit.posX, hit.entityHit.getEntityBoundingBox().minY + hit.entityHit.height/2, hit.entityHit.posZ); target = GeometryUtils.getCentre(hit.entityHit);
} }
EnumHandSide side = InventoryUtils.getSideForHand(player, player.getActiveHand()); EnumHandSide side = InventoryUtils.getSideForHand(player, player.getActiveHand());
@@ -95,7 +95,7 @@ public abstract class ParticleTargeted extends ParticleWizardry {
if(this.target != null){ if(this.target != null){
this.targetX = this.target.prevPosX + (this.target.posX - this.target.prevPosX) * partialTicks; this.targetX = this.target.prevPosX + (this.target.posX - this.target.prevPosX) * partialTicks;
double correction = this.target.getEntityBoundingBox().minY - this.target.posY; double correction = this.target.posY - this.target.posY;
this.targetY = this.target.prevPosY + (this.target.posY - this.target.prevPosY) * partialTicks this.targetY = this.target.prevPosY + (this.target.posY - this.target.prevPosY) * partialTicks
+ target.height/2 + correction; + target.height/2 + correction;
this.targetZ = this.target.prevPosZ + (this.target.posZ - this.target.prevPosZ) * partialTicks; this.targetZ = this.target.prevPosZ + (this.target.posZ - this.target.prevPosZ) * partialTicks;
@@ -206,7 +206,7 @@ public abstract class ParticleWizardry extends Particle {
this.entity = entity; this.entity = entity;
// Set these to the correct values // Set these to the correct values
if(entity != null){ if(entity != null){
this.setPosition(this.entity.posX + relativeX, this.entity.getEntityBoundingBox().minY this.setPosition(this.entity.posX + relativeX, this.entity.posY
+ relativeY, this.entity.posZ + relativeZ); + relativeY, this.entity.posZ + relativeZ);
this.prevPosX = this.posX; this.prevPosX = this.posX;
this.prevPosY = this.posY; this.prevPosY = this.posY;
@@ -82,7 +82,7 @@ public class RenderFireRing extends Render<EntityFireRing> {
float f2 = 0.5F; float f2 = 0.5F;
float f3 = 0.0F; float f3 = 0.0F;
float f4 = 0.2f; float f4 = 0.2f;
float f5 = (float)(entity.posY - entity.getEntityBoundingBox().minY); float f5 = (float)(entity.posY - entity.posY);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
float f61 = 0.0F; float f61 = 0.0F;
int i = 0; int i = 0;
@@ -129,7 +129,7 @@ public class RenderFireRing extends Render<EntityFireRing> {
float f2 = 0.5F; float f2 = 0.5F;
float f3 = 0.0F; float f3 = 0.0F;
float f4 = 0.2f; float f4 = 0.2f;
float f5 = (float)(entity.posY - entity.getEntityBoundingBox().minY); float f5 = (float)(entity.posY - entity.posY);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
float f61 = 0.0F; float f61 = 0.0F;
int i = 0; int i = 0;
@@ -121,7 +121,7 @@ public class EntityHammer extends EntityMagicConstruct {
ParticleBuilder.create(Type.LIGHTNING).pos(posX, posY + height - 0.1, posZ) .target(target).spawn(world); ParticleBuilder.create(Type.LIGHTNING).pos(posX, posY + height - 0.1, posZ) .target(target).spawn(world);
ParticleBuilder.spawnShockParticles(world, target.posX, ParticleBuilder.spawnShockParticles(world, target.posX,
target.getEntityBoundingBox().minY + target.height, target.posZ); target.posY + target.height, target.posZ);
} }
target.playSound(WizardrySounds.ENTITY_HAMMER_ATTACK, 1.0F, rand.nextFloat() * 0.4F + 1.5F); target.playSound(WizardrySounds.ENTITY_HAMMER_ATTACK, 1.0F, rand.nextFloat() * 0.4F + 1.5F);
@@ -81,7 +81,7 @@ public class EntityLightningSigil extends EntityScaledConstruct {
.pos(0, target.height/2, 0).target(secondaryTarget).spawn(world); .pos(0, target.height/2, 0).target(secondaryTarget).spawn(world);
ParticleBuilder.spawnShockParticles(world, secondaryTarget.posX, ParticleBuilder.spawnShockParticles(world, secondaryTarget.posX,
secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height / 2, secondaryTarget.posY + secondaryTarget.height / 2,
secondaryTarget.posZ); secondaryTarget.posZ);
} }
@@ -53,7 +53,7 @@ public class EntityStormcloud extends EntityScaledConstruct {
}else{ }else{
ParticleBuilder.create(Type.LIGHTNING).pos(target.posX, posY + height/2, target.posZ) ParticleBuilder.create(Type.LIGHTNING).pos(target.posX, posY + height/2, target.posZ)
.target(target).scale(2).spawn(world); .target(target).scale(2).spawn(world);
ParticleBuilder.spawnShockParticles(world, target.posX, target.getEntityBoundingBox().minY + target.height, target.posZ); ParticleBuilder.spawnShockParticles(world, target.posX, target.posY + target.height, target.posZ);
} }
target.playSound(WizardrySounds.ENTITY_STORMCLOUD_THUNDER, 1, 1.6f); target.playSound(WizardrySounds.ENTITY_STORMCLOUD_THUNDER, 1, 1.6f);
@@ -117,7 +117,7 @@ public class EntityAIAttackSpell<T extends EntityLiving & ISpellCaster> extends
// Only executed server side. // Only executed server side.
double distanceSq = this.attacker.getDistanceSq(this.target.posX, this.target.getEntityBoundingBox().minY, double distanceSq = this.attacker.getDistanceSq(this.target.posX, this.target.posY,
this.target.posZ); this.target.posZ);
boolean targetIsVisible = this.attacker.getEntitySenses().canSee(this.target); boolean targetIsVisible = this.attacker.getEntitySenses().canSee(this.target);
@@ -44,7 +44,7 @@ public class EntityDecoy extends EntitySummonedCreature {
if(world.isRemote){ if(world.isRemote){
for(int i = 0; i < 20; i++){ for(int i = 0; i < 20; i++){
ParticleBuilder.create(Type.DUST) ParticleBuilder.create(Type.DUST)
.pos(this.posX + (this.rand.nextDouble() - 0.5) * this.width, this.getEntityBoundingBox().minY .pos(this.posX + (this.rand.nextDouble() - 0.5) * this.width, this.posY
+ this.rand.nextDouble() * this.height, this.posZ + (this.rand.nextDouble() - 0.5) * this.width) + this.rand.nextDouble() * this.height, this.posZ + (this.rand.nextDouble() - 0.5) * this.width)
.time(40) .time(40)
.clr(0.2f, 1.0f, 0.8f) .clr(0.2f, 1.0f, 0.8f)
@@ -90,7 +90,7 @@ public abstract class EntityMagicArrow extends Entity implements IProjectile, IE
this.setCaster(caster); 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); caster.posZ, caster.rotationYaw, caster.rotationPitch);
this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); 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.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 dx = target.posX - caster.posX;
double dy = this.doGravity() ? target.getEntityBoundingBox().minY + (double)(target.height / 3.0f) - this.posY double dy = this.doGravity() ? target.posY + (double)(target.height / 3.0f) - this.posY
: target.getEntityBoundingBox().minY + (double)(target.height / 2.0f) - this.posY; : target.posY + (double)(target.height / 2.0f) - this.posY;
double dz = target.posZ - caster.posZ; double dz = target.posZ - caster.posZ;
double horizontalDistance = (double)MathHelper.sqrt(dx * dx + dz * dz); 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 /** 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. */ * aims it in the direction they are looking with the given speed. */
public void aim(EntityLivingBase caster, float 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 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.shoot(caster, caster.rotationPitch, caster.rotationYaw, 0.0f, speed, 1.0f);
this.thrower = caster; 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. // Mojang's 'fix' for the projectile-hitting-thrower bug actually made the problem worse, hence the following line.
this.ignoreEntity = thrower; 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 dx = target.posX - caster.posX;
double dy = !this.hasNoGravity() ? target.getEntityBoundingBox().minY + (double)(target.height / 3.0f) - this.posY double dy = !this.hasNoGravity() ? target.posY + (double)(target.height / 3.0f) - this.posY
: target.getEntityBoundingBox().minY + (double)(target.height / 2.0f) - this.posY; : target.posY + (double)(target.height / 2.0f) - this.posY;
double dz = target.posZ - caster.posZ; double dz = target.posZ - caster.posZ;
double horizontalDistance = MathHelper.sqrt(dx * dx + dz * dz); double horizontalDistance = MathHelper.sqrt(dx * dx + dz * dz);
@@ -81,7 +81,7 @@ public class EntitySparkBomb extends EntityBomb {
}else{ }else{
ParticleBuilder.create(Type.LIGHTNING).pos(this.getPositionVector()).target(target).spawn(world); 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);
} }
} }
} }
@@ -609,7 +609,7 @@ public class ItemArtefact extends Item {
.pos(0, event.getEntity().height/2, 0).target(target).spawn(player.world); .pos(0, event.getEntity().height/2, 0).target(target).spawn(player.world);
ParticleBuilder.spawnShockParticles(player.world, target.posX, ParticleBuilder.spawnShockParticles(player.world, target.posX,
target.getEntityBoundingBox().minY + target.height/2, target.posZ); target.posY + target.height/2, target.posZ);
} }
DamageSafetyChecker.attackEntitySafely(target, MagicDamage.causeDirectMagicDamage(player, DamageSafetyChecker.attackEntitySafely(target, MagicDamage.causeDirectMagicDamage(player,
@@ -693,7 +693,7 @@ public class ItemArtefact extends Item {
.pos(0, event.getEntity().height/2, 0).target(target).spawn(world); .pos(0, event.getEntity().height/2, 0).target(target).spawn(world);
ParticleBuilder.spawnShockParticles(world, target.posX, ParticleBuilder.spawnShockParticles(world, target.posX,
target.getEntityBoundingBox().minY + target.height/2, target.posZ); target.posY + target.height/2, target.posZ);
} }
DamageSafetyChecker.attackEntitySafely(target, MagicDamage.causeDirectMagicDamage(player, DamageSafetyChecker.attackEntitySafely(target, MagicDamage.causeDirectMagicDamage(player,
@@ -210,7 +210,7 @@ public class ItemLightningHammer extends Item implements IConjuredItem {
if(hit.world.isRemote){ if(hit.world.isRemote){
ParticleBuilder.create(Type.LIGHTNING).pos(hit.getPositionVector().add(0, hit.height / 2, 0)) ParticleBuilder.create(Type.LIGHTNING).pos(hit.getPositionVector().add(0, hit.height / 2, 0))
.target(target).spawn(hit.world); .target(target).spawn(hit.world);
ParticleBuilder.spawnShockParticles(hit.world, target.posX, target.getEntityBoundingBox().minY + target.height / 2, target.posZ); ParticleBuilder.spawnShockParticles(hit.world, target.posX, target.posY + target.height / 2, target.posZ);
} }
//target.playSound(WizardrySounds.SPELL_SPARK, 1, 1.5f + 0.4f * world.rand.nextFloat()); //target.playSound(WizardrySounds.SPELL_SPARK, 1, 1.5f + 0.4f * world.rand.nextFloat());
@@ -59,7 +59,7 @@ public class ItemPurifyingElixir extends Item {
for(int i = 0; i < 20; i++){ for(int i = 0; i < 20; i++){
double x = entity.posX + world.rand.nextDouble() * 2 - 1; double x = entity.posX + world.rand.nextDouble() * 2 - 1;
double y = entity.getEntityBoundingBox().minY + entity.getEyeHeight() - 0.5 + world.rand.nextDouble(); double y = entity.posY + entity.getEyeHeight() - 0.5 + world.rand.nextDouble();
double z = entity.posZ + world.rand.nextDouble() * 2 - 1; double z = entity.posZ + world.rand.nextDouble() * 2 - 1;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.14, 0).clr(0x0f001b) ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.14, 0).clr(0x0f001b)
.time(20 + world.rand.nextInt(12)).spawn(world); .time(20 + world.rand.nextInt(12)).spawn(world);
@@ -847,7 +847,7 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
if(player.world.isRemote){ if(player.world.isRemote){
Vec3d origin = new Vec3d(player.posX, player.getEntityBoundingBox().minY + player.getEyeHeight(), player.posZ); Vec3d origin = player.getPositionEyes(1);
Vec3d hit = origin.add(player.getLookVec().scale(player.getDistance(event.getTarget()))); Vec3d hit = origin.add(player.getLookVec().scale(player.getDistance(event.getTarget())));
// Generate two perpendicular vectors in the plane perpendicular to the look vec // Generate two perpendicular vectors in the plane perpendicular to the look vec
Vec3d vec1 = player.getLookVec().rotatePitch(90); Vec3d vec1 = player.getLookVec().rotatePitch(90);
@@ -190,7 +190,7 @@ public abstract class Forfeit {
add(Tier.APPRENTICE, Element.FIRE, create("fireball", (w, p) -> { add(Tier.APPRENTICE, Element.FIRE, create("fireball", (w, p) -> {
if(!w.isRemote){ if(!w.isRemote){
EntityMagicFireball fireball = new EntityMagicFireball(w); EntityMagicFireball fireball = new EntityMagicFireball(w);
Vec3d vec = p.getPositionEyes(0).add(p.getLookVec().scale(6)); Vec3d vec = p.getPositionEyes(1).add(p.getLookVec().scale(6));
fireball.setPosition(vec.x, vec.y, vec.z); fireball.setPosition(vec.x, vec.y, vec.z);
fireball.shoot(p.posX, p.posY + p.getEyeHeight(), p.posZ, 1.5f, 1); fireball.shoot(p.posX, p.posY + p.getEyeHeight(), p.posZ, 1.5f, 1);
w.spawnEntity(fireball); w.spawnEntity(fireball);
@@ -53,7 +53,7 @@ public interface ICustomPotionParticles extends ISyncedPotion {
double x = event.getEntityLiving().posX double x = event.getEntityLiving().posX
+ (event.getEntityLiving().world.rand.nextDouble() - 0.5) * event.getEntityLiving().width; + (event.getEntityLiving().world.rand.nextDouble() - 0.5) * event.getEntityLiving().width;
double y = event.getEntityLiving().getEntityBoundingBox().minY double y = event.getEntityLiving().posY
+ event.getEntityLiving().world.rand.nextDouble() * event.getEntityLiving().height; + event.getEntityLiving().world.rand.nextDouble() * event.getEntityLiving().height;
double z = event.getEntityLiving().posZ double z = event.getEntityLiving().posZ
+ (event.getEntityLiving().world.rand.nextDouble() - 0.5) * event.getEntityLiving().width; + (event.getEntityLiving().world.rand.nextDouble() - 0.5) * event.getEntityLiving().width;
@@ -54,7 +54,7 @@ public class PotionContainment extends PotionMagicEffect {
if(target.getEntityBoundingBox().minX < origin.x - maxDistance) x = origin.x - maxDistance + target.width/2; if(target.getEntityBoundingBox().minX < origin.x - maxDistance) x = origin.x - maxDistance + target.width/2;
if(target.getEntityBoundingBox().maxY > origin.y + maxDistance) y = origin.y + maxDistance - target.height; if(target.getEntityBoundingBox().maxY > origin.y + maxDistance) y = origin.y + maxDistance - target.height;
if(target.getEntityBoundingBox().minY < origin.y - maxDistance) y = origin.y - maxDistance; if(target.posY < origin.y - maxDistance) y = origin.y - maxDistance;
if(target.getEntityBoundingBox().maxZ > origin.z + maxDistance) z = origin.z + maxDistance - target.width/2; if(target.getEntityBoundingBox().maxZ > origin.z + maxDistance) z = origin.z + maxDistance - target.width/2;
if(target.getEntityBoundingBox().minZ < origin.z - maxDistance) z = origin.z - maxDistance + target.width/2; if(target.getEntityBoundingBox().minZ < origin.z - maxDistance) z = origin.z - maxDistance + target.width/2;
@@ -67,7 +67,7 @@ public class PotionContainment extends PotionMagicEffect {
// for(int i = 0; i < 20; i++){ // for(int i = 0; i < 20; i++){
// ParticleBuilder.create(ParticleBuilder.Type.DUST).pos( // ParticleBuilder.create(ParticleBuilder.Type.DUST).pos(
// x, // x,
// target.getEntityBoundingBox().minY + target.height * target.world.rand.nextFloat(), // target.posY + target.height * target.world.rand.nextFloat(),
// target.posZ + target.width * (target.world.rand.nextFloat() - 0.5f)) // target.posZ + target.width * (target.world.rand.nextFloat() - 0.5f))
// .face(EnumFacing.EAST).clr(0.8f, 0.9f, 1).spawn(target.world); // .face(EnumFacing.EAST).clr(0.8f, 0.9f, 1).spawn(target.world);
// } // }
@@ -87,7 +87,7 @@ public class PotionContainment extends PotionMagicEffect {
// for(int i = 0; i < 20; i++){ // for(int i = 0; i < 20; i++){
// ParticleBuilder.create(ParticleBuilder.Type.DUST).pos( // ParticleBuilder.create(ParticleBuilder.Type.DUST).pos(
// target.posX + target.width * (target.world.rand.nextFloat() - 0.5f), // target.posX + target.width * (target.world.rand.nextFloat() - 0.5f),
// target.getEntityBoundingBox().minY + target.height * target.world.rand.nextFloat(), // target.posY + target.height * target.world.rand.nextFloat(),
// z) // z)
// .face(EnumFacing.SOUTH).clr(0.8f, 0.9f, 1).spawn(target.world); // .face(EnumFacing.SOUTH).clr(0.8f, 0.9f, 1).spawn(target.world);
// } // }
@@ -31,7 +31,7 @@ public class Arc extends SpellRay {
// Rather neatly, the entity can be set here and if it's null nothing will happen. // Rather neatly, the entity can be set here and if it's null nothing will happen.
ParticleBuilder.create(Type.LIGHTNING).entity(caster) ParticleBuilder.create(Type.LIGHTNING).entity(caster)
.pos(caster != null ? origin.subtract(caster.getPositionVector()) : origin).target(target).spawn(world); .pos(caster != null ? origin.subtract(caster.getPositionVector()) : origin).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);
} }
// This is a lot neater than it was, thanks to the damage type system. // This is a lot neater than it was, thanks to the damage type system.
@@ -109,7 +109,7 @@ public class ArcaneJammer extends SpellRay {
if(event.getWorld().isRemote){ if(event.getWorld().isRemote){
Vec3d centre = event.getCaster().getPositionEyes(0).add(event.getCaster().getLookVec()); Vec3d centre = event.getCaster().getPositionEyes(1).add(event.getCaster().getLookVec());
for(int i = 0; i < 5; i++){ for(int i = 0; i < 5; i++){
double x = centre.x + 0.5f * (event.getWorld().rand.nextFloat() - 0.5f); double x = centre.x + 0.5f * (event.getWorld().rand.nextFloat() - 0.5f);
@@ -68,13 +68,13 @@ public class Banish extends SpellRay {
int x = MathHelper.floor(entity.posX + MathHelper.sin(angle) * radius); int x = MathHelper.floor(entity.posX + MathHelper.sin(angle) * radius);
int z = MathHelper.floor(entity.posZ - MathHelper.cos(angle) * radius); int z = MathHelper.floor(entity.posZ - MathHelper.cos(angle) * radius);
Integer y = BlockUtils.getNearestFloor(world, Integer y = BlockUtils.getNearestFloor(world,
new BlockPos(x, (int)entity.getEntityBoundingBox().minY, z), (int)radius); new BlockPos(x, (int)entity.posY, z), (int)radius);
if(world.isRemote){ if(world.isRemote){
for(int i=0; i<10; i++){ for(int i=0; i<10; i++){
double dx1 = entity.posX; double dx1 = entity.posX;
double dy1 = entity.getEntityBoundingBox().minY + entity.height * world.rand.nextFloat(); double dy1 = entity.posY + entity.height * world.rand.nextFloat();
double dz1 = entity.posZ; double dz1 = entity.posZ;
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5,
world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
@@ -41,7 +41,7 @@ public class Blink extends Spell {
if(world.isRemote){ if(world.isRemote){
for(int i = 0; i < 10; i++){ for(int i = 0; i < 10; i++){
double dx = caster.posX; double dx = caster.posX;
double dy = caster.getEntityBoundingBox().minY + 2 * world.rand.nextFloat(); double dy = caster.posY + 2 * world.rand.nextFloat();
double dz = caster.posZ; double dz = caster.posZ;
// For portal particles, velocity is not velocity but the offset where they start, then drift to // For portal particles, velocity is not velocity but the offset where they start, then drift to
// the actual position given. // the actual position given.
@@ -80,7 +80,7 @@ public class Blink extends Spell {
float angle = (float)(Math.atan2(target.posZ - caster.posZ, target.posX - caster.posX) float angle = (float)(Math.atan2(target.posZ - caster.posZ, target.posX - caster.posX)
+ world.rand.nextDouble() * Math.PI); + world.rand.nextDouble() * Math.PI);
double radius = caster.getDistance(target.posX, target.getEntityBoundingBox().minY, target.posZ) double radius = caster.getDistance(target.posX, target.posY, target.posZ)
+ world.rand.nextDouble() * 3.0d; + world.rand.nextDouble() * 3.0d;
int x = MathHelper.floor(target.posX + MathHelper.sin(angle) * radius); int x = MathHelper.floor(target.posX + MathHelper.sin(angle) * radius);
@@ -94,7 +94,7 @@ public class Blink extends Spell {
if(world.isRemote){ if(world.isRemote){
for(int i = 0; i < 10; i++){ for(int i = 0; i < 10; i++){
double dx1 = caster.posX; double dx1 = caster.posX;
double dy1 = caster.getEntityBoundingBox().minY + caster.height * world.rand.nextFloat(); double dy1 = caster.posY + caster.height * world.rand.nextFloat();
double dz1 = caster.posZ; double dz1 = caster.posZ;
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5,
world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
@@ -110,7 +110,7 @@ public class ChainLightning extends SpellRay {
ParticleBuilder.create(Type.LIGHTNING).entity(caster) ParticleBuilder.create(Type.LIGHTNING).entity(caster)
.pos(caster != null ? origin.subtract(caster.getPositionVector()) : origin).target(target).spawn(world); .pos(caster != null ? origin.subtract(caster.getPositionVector()) : origin).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);
} }
//target.playSound(WizardrySounds.SPELL_SPARK, 1, 1.5f + 0.4f * world.rand.nextFloat()); //target.playSound(WizardrySounds.SPELL_SPARK, 1, 1.5f + 0.4f * world.rand.nextFloat());
@@ -84,7 +84,7 @@ public class Divination extends Spell {
BlockPos target = sphere.get(sphere.size() - 1); BlockPos target = sphere.get(sphere.size() - 1);
direction = EnumFacing.getFacingFromVector((float)(target.getX() + 0.5 - caster.posX), direction = EnumFacing.getFacingFromVector((float)(target.getX() + 0.5 - caster.posX),
(float)(target.getY() + 0.5 - (caster.getEntityBoundingBox().minY + caster.getEyeHeight())), (float)(target.getY() + 0.5 - (caster.posY + caster.getEyeHeight())),
(float)(target.getZ() + 0.5 - caster.posZ)); (float)(target.getZ() + 0.5 - caster.posZ));
strength = Strength.forWeight(calculateWeight(world, caster, target, range, modifiers)); strength = Strength.forWeight(calculateWeight(world, caster, target, range, modifiers));
@@ -61,7 +61,7 @@ public class DragonFireball extends Spell {
EntityDragonFireball fireball = new EntityDragonFireball(world, caster, 1, 1, 1); EntityDragonFireball fireball = new EntityDragonFireball(world, caster, 1, 1, 1);
double dx = target.posX - caster.posX; double dx = target.posX - caster.posX;
double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) double dy = target.posY + (double)(target.height / 2.0F)
- (caster.posY + (double)(caster.height / 2.0F)); - (caster.posY + (double)(caster.height / 2.0F));
double dz = target.posZ - caster.posZ; double dz = target.posZ - caster.posZ;
@@ -41,7 +41,7 @@ public class Fangs extends Spell {
@Override @Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!spawnFangs(world, new Vec3d(caster.posX, caster.getEntityBoundingBox().minY, caster.posZ), if(!spawnFangs(world, caster.getPositionVector(),
GeometryUtils.replaceComponent(caster.getLookVec(), Axis.Y, 0).normalize(), caster, modifiers)) return false; GeometryUtils.replaceComponent(caster.getLookVec(), Axis.Y, 0).normalize(), caster, modifiers)) return false;
this.playSound(world, caster, ticksInUse, -1, modifiers); this.playSound(world, caster, ticksInUse, -1, modifiers);
return true; return true;
@@ -3,12 +3,9 @@ package electroblob.wizardry.spell;
import electroblob.wizardry.client.DrawingUtils; import electroblob.wizardry.client.DrawingUtils;
import electroblob.wizardry.item.SpellActions; import electroblob.wizardry.item.SpellActions;
import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.util.BlockUtils; import electroblob.wizardry.util.*;
import electroblob.wizardry.util.BlockUtils.SurfaceCriteria; import electroblob.wizardry.util.BlockUtils.SurfaceCriteria;
import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type; import electroblob.wizardry.util.ParticleBuilder.Type;
import electroblob.wizardry.util.SpellModifiers;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -32,7 +29,7 @@ public class Firestorm extends SpellAreaEffect {
@Override @Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
burnNearbyBlocks(world, new Vec3d(caster.posX, caster.getEntityBoundingBox().minY, caster.posZ), caster, modifiers); burnNearbyBlocks(world, caster.getPositionVector(), caster, modifiers);
return super.cast(world, caster, hand, ticksInUse, modifiers); return super.cast(world, caster, hand, ticksInUse, modifiers);
} }
@@ -18,7 +18,7 @@ public class FlamingAxe extends SpellConjuration {
for(int i=0; i<10; i++){ for(int i=0; i<10; i++){
double x = caster.posX + world.rand.nextDouble() * 2 - 1; double x = caster.posX + world.rand.nextDouble() * 2 - 1;
double y = caster.getEntityBoundingBox().minY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble(); double y = caster.posY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble();
double z = caster.posZ + world.rand.nextDouble() * 2 - 1; double z = caster.posZ + world.rand.nextDouble() * 2 - 1;
world.spawnParticle(EnumParticleTypes.FLAME, x, y, z, 0, 0, 0); world.spawnParticle(EnumParticleTypes.FLAME, x, y, z, 0, 0, 0);
} }
@@ -46,7 +46,7 @@ public class FlamingWeapon extends Spell {
if(world.isRemote){ if(world.isRemote){
for(int i=0; i<10; i++){ for(int i=0; i<10; i++){
double x = caster.posX + world.rand.nextDouble() * 2 - 1; double x = caster.posX + world.rand.nextDouble() * 2 - 1;
double y = caster.getEntityBoundingBox().minY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble(); double y = caster.posY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble();
double z = caster.posZ + world.rand.nextDouble() * 2 - 1; double z = caster.posZ + world.rand.nextDouble() * 2 - 1;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(0.9f, 0.7f, 1).spawn(world); ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(0.9f, 0.7f, 1).spawn(world);
} }
@@ -46,11 +46,11 @@ public class Flight extends Spell {
if(world.isRemote){ if(world.isRemote){
double x = caster.posX - 1 + world.rand.nextDouble() * 2; double x = caster.posX - 1 + world.rand.nextDouble() * 2;
double y = caster.getEntityBoundingBox().minY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble(); double y = caster.posY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble();
double z = caster.posZ - 1 + world.rand.nextDouble() * 2; double z = caster.posZ - 1 + world.rand.nextDouble() * 2;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, -0.1, 0).time(15).clr(0.8f, 1, 0.5f).spawn(world); ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, -0.1, 0).time(15).clr(0.8f, 1, 0.5f).spawn(world);
x = caster.posX - 1 + world.rand.nextDouble() * 2; x = caster.posX - 1 + world.rand.nextDouble() * 2;
y = caster.getEntityBoundingBox().minY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble(); y = caster.posY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble();
z = caster.posZ - 1 + world.rand.nextDouble() * 2; z = caster.posZ - 1 + world.rand.nextDouble() * 2;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, -0.1, 0).time(15).clr(1f, 1f, 1f).spawn(world); ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, -0.1, 0).time(15).clr(1f, 1f, 1f).spawn(world);
} }
@@ -52,7 +52,7 @@ public class FreezingWeapon extends Spell {
if(world.isRemote){ if(world.isRemote){
for(int i=0; i<10; i++){ for(int i=0; i<10; i++){
double x = caster.posX + world.rand.nextDouble() * 2 - 1; double x = caster.posX + world.rand.nextDouble() * 2 - 1;
double y = caster.getEntityBoundingBox().minY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble(); double y = caster.posY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble();
double z = caster.posZ + world.rand.nextDouble() * 2 - 1; double z = caster.posZ + world.rand.nextDouble() * 2 - 1;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(0.9f, 0.7f, 1).spawn(world); ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(0.9f, 0.7f, 1).spawn(world);
} }
@@ -19,7 +19,7 @@ public class FrostAxe extends SpellConjuration {
for(int i=0; i<10; i++){ for(int i=0; i<10; i++){
double x = caster.posX + world.rand.nextDouble() * 2 - 1; double x = caster.posX + world.rand.nextDouble() * 2 - 1;
double y = caster.getEntityBoundingBox().minY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble(); double y = caster.posY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble();
double z = caster.posZ + world.rand.nextDouble() * 2 - 1; double z = caster.posZ + world.rand.nextDouble() * 2 - 1;
ParticleBuilder.create(Type.SNOW).pos(x, y, z).spawn(world); ParticleBuilder.create(Type.SNOW).pos(x, y, z).spawn(world);
} }
@@ -57,11 +57,11 @@ public class Glide extends Spell {
if(world.isRemote){ if(world.isRemote){
double x = caster.posX - 0.25 + world.rand.nextDouble() / 2; double x = caster.posX - 0.25 + world.rand.nextDouble() / 2;
double y = caster.getEntityBoundingBox().minY + world.rand.nextDouble(); double y = caster.posY + world.rand.nextDouble();
double z = caster.posZ - 0.25 + world.rand.nextDouble() / 2; double z = caster.posZ - 0.25 + world.rand.nextDouble() / 2;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, -0.1, 0).time(15).clr(1f, 1f, 1f).spawn(world); ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, -0.1, 0).time(15).clr(1f, 1f, 1f).spawn(world);
x = caster.posX - 0.25 + world.rand.nextDouble() / 2; x = caster.posX - 0.25 + world.rand.nextDouble() / 2;
y = caster.getEntityBoundingBox().minY + world.rand.nextDouble(); y = caster.posY + world.rand.nextDouble();
z = caster.posZ - 0.25 + world.rand.nextDouble() / 2; z = caster.posZ - 0.25 + world.rand.nextDouble() / 2;
ParticleBuilder.create(Type.LEAF).pos(x, y, z).time(20).spawn(world); ParticleBuilder.create(Type.LEAF).pos(x, y, z).time(20).spawn(world);
} }
@@ -75,7 +75,7 @@ public class Grapple extends Spell {
WizardData data = WizardData.get(caster); WizardData data = WizardData.get(caster);
Vec3d origin = new Vec3d(caster.posX, caster.getEntityBoundingBox().minY + caster.getEyeHeight(), caster.posZ); Vec3d origin = caster.getPositionEyes(1);
float extensionSpeed = getProperty(EXTENSION_SPEED).floatValue() * modifiers.get(SpellModifiers.POTENCY); float extensionSpeed = getProperty(EXTENSION_SPEED).floatValue() * modifiers.get(SpellModifiers.POTENCY);
@@ -98,7 +98,7 @@ public class Grapple extends Spell {
if(hit.entityHit instanceof EntityLivingBase){ if(hit.entityHit instanceof EntityLivingBase){
// If the target is an entity, we need to use the entity's centre rather than the original hit position // If the target is an entity, we need to use the entity's centre rather than the original hit position
// because the entity will have moved! // because the entity will have moved!
target = new Vec3d(hit.entityHit.posX, hit.entityHit.getEntityBoundingBox().minY + hit.entityHit.height/2, hit.entityHit.posZ); target = GeometryUtils.getCentre(hit.entityHit);
} }
double distance = origin.distanceTo(target); double distance = origin.distanceTo(target);
@@ -209,11 +209,11 @@ public class Grapple extends Spell {
if(target == null) return false; if(target == null) return false;
Vec3d origin = new Vec3d(caster.posX, caster.getEntityBoundingBox().minY + caster.getEyeHeight(), caster.posZ); Vec3d origin = caster.getPositionEyes(1);
// If the target is an entity, we need to use the entity's centre rather than the original hit position // If the target is an entity, we need to use the entity's centre rather than the original hit position
// because the entity will have moved! // because the entity will have moved!
Vec3d targetVec = new Vec3d(target.posX, target.getEntityBoundingBox().minY + target.height/2, target.posZ); Vec3d targetVec = GeometryUtils.getCentre(target);
RayTraceResult hit = findTarget(world, caster, origin, targetVec.subtract(origin).normalize(), modifiers); RayTraceResult hit = findTarget(world, caster, origin, targetVec.subtract(origin).normalize(), modifiers);
@@ -284,7 +284,7 @@ public class Grapple extends Spell {
// If the target is an entity, we need to use the entity's centre rather than the original hit position // If the target is an entity, we need to use the entity's centre rather than the original hit position
// because the entity will have moved! // because the entity will have moved!
Vec3d target = new Vec3d(entity.posX, entity.getEntityBoundingBox().minY + entity.height/2, entity.posZ); Vec3d target = GeometryUtils.getCentre(entity);
double distance = origin.distanceTo(target); double distance = origin.distanceTo(target);
Vec3d vec = target.subtract(origin).normalize(); Vec3d vec = target.subtract(origin).normalize();
@@ -344,7 +344,7 @@ public class Grapple extends Spell {
if(caster != null){ if(caster != null){
origin = new Vec3d(caster.posX, caster.getEntityBoundingBox().minY + caster.getEyeHeight(), caster.posZ); origin = caster.getPositionEyes(1);
if(caster instanceof EntityPlayer){ if(caster instanceof EntityPlayer){
WizardData data = WizardData.get((EntityPlayer)caster); WizardData data = WizardData.get((EntityPlayer)caster);
@@ -354,7 +354,7 @@ public class Grapple extends Spell {
} }
}else if(caster instanceof EntityLiving){ }else if(caster instanceof EntityLiving){
Entity entity = ((EntityLiving)caster).getAttackTarget(); Entity entity = ((EntityLiving)caster).getAttackTarget();
if(entity != null) target = new Vec3d(entity.posX, entity.getEntityBoundingBox().minY + entity.height/2, entity.posZ); if(entity != null) target = GeometryUtils.getCentre(entity);
} }
if(target != null) direction = target.subtract(origin).normalize(); if(target != null) direction = target.subtract(origin).normalize();
@@ -6,11 +6,8 @@ import electroblob.wizardry.registry.WizardryBlocks;
import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.registry.WizardryPotions; import electroblob.wizardry.registry.WizardryPotions;
import electroblob.wizardry.registry.WizardrySounds; import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.util.BlockUtils; import electroblob.wizardry.util.*;
import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type; import electroblob.wizardry.util.ParticleBuilder.Type;
import electroblob.wizardry.util.SpellModifiers;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -36,7 +33,7 @@ public class IceAge extends SpellAreaEffect {
@Override @Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
freezeNearbyBlocks(world, new Vec3d(caster.posX, caster.getEntityBoundingBox().minY, caster.posZ), caster, modifiers); freezeNearbyBlocks(world, caster.getPositionVector(), caster, modifiers);
return super.cast(world, caster, hand, ticksInUse, modifiers); return super.cast(world, caster, hand, ticksInUse, modifiers);
} }
@@ -65,7 +65,7 @@ public class ImbueWeapon extends Spell {
if(world.isRemote){ if(world.isRemote){
for(int i=0; i<10; i++){ for(int i=0; i<10; i++){
double x = caster.posX + world.rand.nextDouble() * 2 - 1; double x = caster.posX + world.rand.nextDouble() * 2 - 1;
double y = caster.getEntityBoundingBox().minY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble(); double y = caster.posY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble();
double z = caster.posZ + world.rand.nextDouble() * 2 - 1; double z = caster.posZ + world.rand.nextDouble() * 2 - 1;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(0.9f, 0.7f, 1).spawn(world); ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(0.9f, 0.7f, 1).spawn(world);
} }
@@ -66,7 +66,7 @@ public class Intimidate extends SpellAreaEffect {
@Override @Override
protected void spawnParticleEffect(World world, Vec3d origin, double radius, @Nullable EntityLivingBase caster, SpellModifiers modifiers){ protected void spawnParticleEffect(World world, Vec3d origin, double radius, @Nullable EntityLivingBase caster, SpellModifiers modifiers){
if(caster != null) origin = caster.getPositionEyes(0); if(caster != null) origin = caster.getPositionEyes(1);
for(int i = 0; i < 30; i++){ for(int i = 0; i < 30; i++){
double x = origin.x - 1 + world.rand.nextDouble() * 2; double x = origin.x - 1 + world.rand.nextDouble() * 2;
@@ -54,7 +54,7 @@ public class InvokeWeather extends Spell {
if(world.isRemote){ if(world.isRemote){
for(int i = 0; i < 10; i++){ for(int i = 0; i < 10; i++){
double x = caster.posX + world.rand.nextDouble() * 2 - 1; double x = caster.posX + world.rand.nextDouble() * 2 - 1;
double y = caster.getEntityBoundingBox().minY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble(); double y = caster.posY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble();
double z = caster.posZ + world.rand.nextDouble() * 2 - 1; double z = caster.posZ + world.rand.nextDouble() * 2 - 1;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(0.5f, 0.7f, 1).spawn(world); ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(0.5f, 0.7f, 1).spawn(world);
} }
@@ -30,7 +30,7 @@ public class Leap extends Spell {
if(world.isRemote){ if(world.isRemote){
for(int i = 0; i < 10; i++){ for(int i = 0; i < 10; i++){
double x = caster.posX + world.rand.nextFloat() - 0.5F; double x = caster.posX + world.rand.nextFloat() - 0.5F;
double y = caster.getEntityBoundingBox().minY; double y = caster.posY;
double z = caster.posZ + world.rand.nextFloat() - 0.5F; double z = caster.posZ + world.rand.nextFloat() - 0.5F;
world.spawnParticle(EnumParticleTypes.CLOUD, x, y, z, 0, 0, 0); world.spawnParticle(EnumParticleTypes.CLOUD, x, y, z, 0, 0, 0);
} }
@@ -47,7 +47,7 @@ public class Levitation extends Spell {
if(world.isRemote){ if(world.isRemote){
double x = caster.posX - 0.25 + world.rand.nextDouble() * 0.5; double x = caster.posX - 0.25 + world.rand.nextDouble() * 0.5;
double y = caster.getEntityBoundingBox().minY; double y = caster.getPositionEyes(1).y;
double z = caster.posZ - 0.25 + world.rand.nextDouble() * 0.5; double z = caster.posZ - 0.25 + world.rand.nextDouble() * 0.5;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, -0.1, 0).time(15).clr(0.5f, 1, 0.7f).spawn(world); ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, -0.1, 0).time(15).clr(0.5f, 1, 0.7f).spawn(world);
} }
@@ -70,7 +70,7 @@ public class LightningPulse extends Spell {
} }
if(world.isRemote){ if(world.isRemote){
ParticleBuilder.create(Type.LIGHTNING_PULSE).pos(caster.posX, caster.getEntityBoundingBox().minY ParticleBuilder.create(Type.LIGHTNING_PULSE).pos(caster.posX, caster.posY
+ GeometryUtils.ANTI_Z_FIGHTING_OFFSET, caster.posZ) + GeometryUtils.ANTI_Z_FIGHTING_OFFSET, caster.posZ)
.scale(modifiers.get(WizardryItems.blast_upgrade)).spawn(world); .scale(modifiers.get(WizardryItems.blast_upgrade)).spawn(world);
} }
@@ -85,10 +85,10 @@ public class MindControl extends SpellRay {
for(int i=0; i<10; i++){ for(int i=0; i<10; i++){
ParticleBuilder.create(Type.DARK_MAGIC, world.rand, target.posX, ParticleBuilder.create(Type.DARK_MAGIC, world.rand, target.posX,
target.getEntityBoundingBox().minY + target.getEyeHeight(), target.posZ, 0.25, false) target.posY + target.getEyeHeight(), target.posZ, 0.25, false)
.clr(0.8f, 0.2f, 1.0f).spawn(world); .clr(0.8f, 0.2f, 1.0f).spawn(world);
ParticleBuilder.create(Type.DARK_MAGIC, world.rand, target.posX, ParticleBuilder.create(Type.DARK_MAGIC, world.rand, target.posX,
target.getEntityBoundingBox().minY + target.getEyeHeight(), target.posZ, 0.25, false) target.posY + target.getEyeHeight(), target.posZ, 0.25, false)
.clr(0.2f, 0.04f, 0.25f).spawn(world); .clr(0.2f, 0.04f, 0.25f).spawn(world);
} }
} }
@@ -53,7 +53,7 @@ public class MindTrick extends SpellRay {
}else{ }else{
for(int i=0; i<10; i++){ for(int i=0; i<10; i++){
ParticleBuilder.create(Type.DARK_MAGIC, world.rand, target.posX, ParticleBuilder.create(Type.DARK_MAGIC, world.rand, target.posX,
target.getEntityBoundingBox().minY + target.getEyeHeight(), target.posZ, 0.25, false) target.posY + target.getEyeHeight(), target.posZ, 0.25, false)
.clr(0.8f, 0.2f, 1.0f).spawn(world); .clr(0.8f, 0.2f, 1.0f).spawn(world);
} }
} }
@@ -42,7 +42,7 @@ public class PhaseStep extends Spell {
for(int i = 0; i < 10; i++){ for(int i = 0; i < 10; i++){
double dx1 = caster.posX; double dx1 = caster.posX;
double dy1 = caster.getEntityBoundingBox().minY + 2 * world.rand.nextFloat(); double dy1 = caster.posY + 2 * world.rand.nextFloat();
double dz1 = caster.posZ; double dz1 = caster.posZ;
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5,
world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
@@ -68,7 +68,7 @@ public class PocketFurnace extends Spell {
if(world.isRemote){ if(world.isRemote){
for(int i = 0; i < 10; i++){ for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)caster.getEntityBoundingBox().minY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat()); double y1 = (double)((float)caster.posY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
world.spawnParticle(EnumParticleTypes.FLAME, x1, y1, z1, 0, 0.01F, 0); world.spawnParticle(EnumParticleTypes.FLAME, x1, y1, z1, 0, 0.01F, 0);
} }
@@ -140,7 +140,7 @@ public class Possession extends SpellRay {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec(); 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(!shootSpell(world, origin, look, caster, ticksInUse, modifiers)) return false; if(!shootSpell(world, origin, look, caster, ticksInUse, modifiers)) return false;
@@ -43,7 +43,7 @@ public class RemoveCurse extends SpellBuff {
for(int i = 0; i < particleCount*2; i++){ for(int i = 0; i < particleCount*2; i++){
double x = caster.posX + world.rand.nextDouble() * 2 - 1; double x = caster.posX + world.rand.nextDouble() * 2 - 1;
double y = caster.getEntityBoundingBox().minY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble(); double y = caster.posY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble();
double z = caster.posZ + world.rand.nextDouble() * 2 - 1; double z = caster.posZ + world.rand.nextDouble() * 2 - 1;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.14, 0).clr(0x0f001b) ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.14, 0).clr(0x0f001b)
.time(20 + world.rand.nextInt(12)).spawn(world); .time(20 + world.rand.nextInt(12)).spawn(world);
@@ -50,7 +50,7 @@ public class ShadowWard extends Spell {
double dx = -1 + 2 * world.rand.nextFloat(); double dx = -1 + 2 * world.rand.nextFloat();
double dy = -1 + world.rand.nextFloat(); double dy = -1 + world.rand.nextFloat();
double dz = -1 + 2 * world.rand.nextFloat(); double dz = -1 + 2 * world.rand.nextFloat();
world.spawnParticle(EnumParticleTypes.PORTAL, caster.posX, caster.getEntityBoundingBox().minY + caster.getEyeHeight(), caster.posZ, dx, dy, dz); world.spawnParticle(EnumParticleTypes.PORTAL, caster.posX, caster.posY + caster.getEyeHeight(), caster.posZ, dx, dy, dz);
} }
if(ticksInUse % 50 == 0){ if(ticksInUse % 50 == 0){
@@ -70,7 +70,7 @@ public class Shockwave extends SpellAreaEffect {
double velocityFactor = proximity * getProperty(MAX_REPULSION_VELOCITY).floatValue(); double velocityFactor = proximity * getProperty(MAX_REPULSION_VELOCITY).floatValue();
double dx = target.posX - origin.x; double dx = target.posX - origin.x;
double dy = target.getEntityBoundingBox().minY + 1 - origin.y; double dy = target.posY + 1 - origin.y;
double dz = target.posZ - origin.z; double dz = target.posZ - origin.z;
target.motionX = velocityFactor * dx; target.motionX = velocityFactor * dx;
@@ -46,7 +46,7 @@ public class SpectralPathway extends Spell {
// Gets the coordinates of the nearest block intersection to the player's feet. // Gets the coordinates of the nearest block intersection to the player's feet.
// Remember that a block always takes the coordinates of its northwestern corner. // Remember that a block always takes the coordinates of its northwestern corner.
BlockPos origin = new BlockPos(Math.round(caster.posX), (int)caster.getEntityBoundingBox().minY - 1, BlockPos origin = new BlockPos(Math.round(caster.posX), (int)caster.posY - 1,
Math.round(caster.posZ)); Math.round(caster.posZ));
int startPoint = direction.getAxisDirection() == AxisDirection.POSITIVE ? -1 : 0; int startPoint = direction.getAxisDirection() == AxisDirection.POSITIVE ? -1 : 0;
@@ -108,7 +108,7 @@ public class SpeedTime extends Spell {
double particleSpread = 2; double particleSpread = 2;
double x = caster.posX + 2; double x = caster.posX + 2;
double y = caster.getEntityBoundingBox().minY + caster.height / 2; double y = caster.posY + caster.height / 2;
double z = caster.posZ; double z = caster.posZ;
ParticleBuilder.create(ParticleBuilder.Type.SPARKLE, world.rand, x, y, z, particleSpread, false) ParticleBuilder.create(ParticleBuilder.Type.SPARKLE, world.rand, x, y, z, particleSpread, false)
@@ -4,6 +4,7 @@ import electroblob.wizardry.Wizardry;
import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.util.AllyDesignationSystem; import electroblob.wizardry.util.AllyDesignationSystem;
import electroblob.wizardry.util.EntityUtils; import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.GeometryUtils;
import electroblob.wizardry.util.SpellModifiers; import electroblob.wizardry.util.SpellModifiers;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
@@ -104,7 +105,7 @@ public abstract class SpellAreaEffect extends Spell {
@Override @Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
boolean result = findAndAffectEntities(world, new Vec3d(caster.posX, caster.getEntityBoundingBox().minY, caster.posZ), boolean result = findAndAffectEntities(world, caster.getPositionVector(),
caster, ticksInUse, modifiers); caster, ticksInUse, modifiers);
if(result) this.playSound(world, caster, ticksInUse, -1, modifiers); if(result) this.playSound(world, caster, ticksInUse, -1, modifiers);
return result; return result;
@@ -195,7 +195,7 @@ public class SpellBuff extends Spell {
for(int i = 0; i < particleCount; i++){ for(int i = 0; i < particleCount; i++){
double x = caster.posX + world.rand.nextDouble() * 2 - 1; double x = caster.posX + world.rand.nextDouble() * 2 - 1;
double y = caster.getEntityBoundingBox().minY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble(); double y = caster.posY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble();
double z = caster.posZ + world.rand.nextDouble() * 2 - 1; double z = caster.posZ + world.rand.nextDouble() * 2 - 1;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(r, g, b).spawn(world); ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(r, g, b).spawn(world);
} }
@@ -70,7 +70,7 @@ public class SpellConjuration extends Spell {
for(int i=0; i<10; i++){ for(int i=0; i<10; i++){
double x = caster.posX + world.rand.nextDouble() * 2 - 1; double x = caster.posX + world.rand.nextDouble() * 2 - 1;
double y = caster.getEntityBoundingBox().minY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble(); double y = caster.posY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble();
double z = caster.posZ + world.rand.nextDouble() * 2 - 1; double z = caster.posZ + world.rand.nextDouble() * 2 - 1;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(0.7f, 0.9f, 1).spawn(world); ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(0.7f, 0.9f, 1).spawn(world);
} }
@@ -109,7 +109,7 @@ public class SpellConstructRanged<T extends EntityMagicConstruct> extends SpellC
Vec3d look = caster.getLookVec(); Vec3d look = caster.getLookVec();
double x = caster.posX + look.x * range; double x = caster.posX + look.x * range;
double y = caster.getEntityBoundingBox().minY + caster.getEyeHeight() + look.y * range; double y = caster.posY + caster.getEyeHeight() + look.y * range;
double z = caster.posZ + look.z * range; double z = caster.posZ + look.z * range;
if(!spawnConstruct(world, x, y, z, null, caster, modifiers)) return false; if(!spawnConstruct(world, x, y, z, null, caster, modifiers)) return false;
@@ -128,7 +128,7 @@ public class SpellConstructRanged<T extends EntityMagicConstruct> extends SpellC
SpellModifiers modifiers){ SpellModifiers modifiers){
double range = getProperty(RANGE).doubleValue() * modifiers.get(WizardryItems.range_upgrade); double range = getProperty(RANGE).doubleValue() * modifiers.get(WizardryItems.range_upgrade);
Vec3d origin = new Vec3d(caster.posX, caster.getEntityBoundingBox().minY + caster.getEyeHeight(), caster.posZ); Vec3d origin = caster.getPositionEyes(1);
if(target != null && caster.getDistance(target) <= range){ if(target != null && caster.getDistance(target) <= range){
@@ -160,7 +160,7 @@ public abstract class SpellRay extends Spell {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec(); 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)){ if(!this.isContinuous && world.isRemote && !Wizardry.proxy.isFirstPerson(caster)){
origin = origin.add(look.scale(1.2)); origin = origin.add(look.scale(1.2));
} }
@@ -175,16 +175,16 @@ public abstract class SpellRay extends Spell {
@Override @Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ 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 // 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; Vec3d targetPos = null;
if(!ignoreLivingEntities || !EntityUtils.isLiving(target)){ 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{ }else{
int x = MathHelper.floor(target.posX); 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); int z = MathHelper.floor(target.posZ);
BlockPos pos = new BlockPos(x, y, z); BlockPos pos = new BlockPos(x, y, z);
@@ -127,10 +127,10 @@ public class SpellThrowable<T extends EntityThrowable> extends Spell {
throwable.ignoreEntity = caster; throwable.ignoreEntity = caster;
throwable.posY = caster.getEntityBoundingBox().minY + (double)caster.getEyeHeight() - LAUNCH_Y_OFFSET; throwable.posY = caster.posY + (double)caster.getEyeHeight() - LAUNCH_Y_OFFSET;
double dx = target.posX - caster.posX; double dx = target.posX - caster.posX;
double dy = !throwable.hasNoGravity() ? target.getEntityBoundingBox().minY + (double)(target.height / 3.0f) - throwable.posY double dy = !throwable.hasNoGravity() ? target.posY + (double)(target.height / 3.0f) - throwable.posY
: target.getEntityBoundingBox().minY + (double)(target.height / 2.0f) - throwable.posY; : target.posY + (double)(target.height / 2.0f) - throwable.posY;
double dz = target.posZ - caster.posZ; double dz = target.posZ - caster.posZ;
double horizontalDistance = MathHelper.sqrt(dx * dx + dz * dz); double horizontalDistance = MathHelper.sqrt(dx * dx + dz * dz);
@@ -89,7 +89,7 @@ public class Thunderstorm extends Spell {
ParticleBuilder.create(Type.LIGHTNING).pos(x, y, z).target(secondaryTarget).spawn(world); ParticleBuilder.create(Type.LIGHTNING).pos(x, y, z).target(secondaryTarget).spawn(world);
ParticleBuilder.spawnShockParticles(world, secondaryTarget.posX, ParticleBuilder.spawnShockParticles(world, secondaryTarget.posX,
secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height / 2, secondaryTarget.posY + secondaryTarget.height / 2,
secondaryTarget.posZ); secondaryTarget.posZ);
} }
@@ -115,7 +115,7 @@ public class Thunderstorm extends Spell {
ParticleBuilder.create(Type.LIGHTNING).entity(secondaryTarget) ParticleBuilder.create(Type.LIGHTNING).entity(secondaryTarget)
.pos(0, secondaryTarget.height / 2, 0).target(tertiaryTarget).spawn(world); .pos(0, secondaryTarget.height / 2, 0).target(tertiaryTarget).spawn(world);
ParticleBuilder.spawnShockParticles(world, tertiaryTarget.posX, ParticleBuilder.spawnShockParticles(world, tertiaryTarget.posX,
tertiaryTarget.getEntityBoundingBox().minY + tertiaryTarget.height / 2, tertiaryTarget.posY + tertiaryTarget.height / 2,
tertiaryTarget.posZ); tertiaryTarget.posZ);
} }
@@ -41,7 +41,7 @@ public class Whirlwind extends SpellRay {
// Left as EntityLivingBase because why not be able to move armour stands around? // Left as EntityLivingBase because why not be able to move armour stands around?
if(target instanceof EntityLivingBase){ if(target instanceof EntityLivingBase){
Vec3d vec = target.getPositionVector().add(0, target.getEyeHeight(), 0).subtract(origin).normalize(); Vec3d vec = target.getPositionEyes(1).subtract(origin).normalize();
if(!world.isRemote){ if(!world.isRemote){
@@ -74,7 +74,7 @@ public class WitherSkull extends Spell {
EntityWitherSkull witherskull = new EntityWitherSkull(world, caster, 1, 1, 1); EntityWitherSkull witherskull = new EntityWitherSkull(world, caster, 1, 1, 1);
double dx = target.posX - caster.posX; double dx = target.posX - caster.posX;
double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) double dy = target.posY + (double)(target.height / 2.0F)
- (caster.posY + (double)(caster.height / 2.0F)); - (caster.posY + (double)(caster.height / 2.0F));
double dz = target.posZ - caster.posZ; double dz = target.posZ - caster.posZ;
@@ -125,7 +125,7 @@ public final class BlockUtils {
* is negative. * is negative.
*/ */
public static IBlockState getBlockEntityIsStandingOn(Entity entity){ public static IBlockState getBlockEntityIsStandingOn(Entity entity){
BlockPos pos = new BlockPos(MathHelper.floor(entity.posX), (int)entity.getEntityBoundingBox().minY - 1, BlockPos pos = new BlockPos(MathHelper.floor(entity.posX), (int)entity.posY - 1,
MathHelper.floor(entity.posZ)); MathHelper.floor(entity.posZ));
return entity.world.getBlockState(pos); return entity.world.getBlockState(pos);
} }
@@ -210,7 +210,7 @@ public final class EntityUtils {
} }
} }
box = box.offset(destination.subtract(entity.posX, box.minY, entity.posZ)); box = box.offset(destination.subtract(entity.posX, entity.posY, entity.posZ));
// All the parameters of this method are INCLUSIVE, so even the max coordinates should be rounded down // All the parameters of this method are INCLUSIVE, so even the max coordinates should be rounded down
Iterable<BlockPos> cuboid = BlockPos.getAllInBox(MathHelper.floor(box.minX), MathHelper.floor(box.minY), Iterable<BlockPos> cuboid = BlockPos.getAllInBox(MathHelper.floor(box.minX), MathHelper.floor(box.minY),
@@ -1,5 +1,6 @@
package electroblob.wizardry.util; package electroblob.wizardry.util;
import net.minecraft.entity.Entity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumFacing.Axis; import net.minecraft.util.EnumFacing.Axis;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
@@ -49,6 +50,14 @@ public final class GeometryUtils {
return new Vec3d(box.minX + (box.maxX - box.minX) * 0.5, box.minY + (box.maxY - box.minY) * 0.5, box.minZ + (box.maxZ - box.minZ) * 0.5); return new Vec3d(box.minX + (box.maxX - box.minX) * 0.5, box.minY + (box.maxY - box.minY) * 0.5, box.minZ + (box.maxZ - box.minZ) * 0.5);
} }
/**
* Returns a {@link Vec3d} of the coordinates at the centre of the given entity's bounding box. This is more
* efficient than {@code GeometryUtils.getCentre(entity.getEntityBoundingBox())} as it can use the entity's fields.
*/
public static Vec3d getCentre(Entity entity){
return new Vec3d(entity.posX, entity.posY + entity.height/2, entity.posZ);
}
/** /**
* Returns a {@link Vec3d} of the coordinates at the centre of the given face of the given block position (i.e. the * Returns a {@link Vec3d} of the coordinates at the centre of the given face of the given block position (i.e. the
* centre of the block plus 0.5 in the given direction). * centre of the block plus 0.5 in the given direction).
@@ -768,7 +768,7 @@ public final class ParticleBuilder {
for(int i = 0; i < 10; i++){ for(int i = 0; i < 10; i++){
double x = entity.posX + world.rand.nextDouble() * 2 - 1; double x = entity.posX + world.rand.nextDouble() * 2 - 1;
double y = entity.getEntityBoundingBox().minY + entity.getEyeHeight() - 0.5 + world.rand.nextDouble(); double y = entity.posY + entity.getEyeHeight() - 0.5 + world.rand.nextDouble();
double z = entity.posZ + world.rand.nextDouble() * 2 - 1; double z = entity.posZ + world.rand.nextDouble() * 2 - 1;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(1, 1, 0.3f).spawn(world); ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(1, 1, 0.3f).spawn(world);
} }
@@ -43,7 +43,7 @@ public final class RayTracer {
public static RayTraceResult standardBlockRayTrace(World world, EntityLivingBase entity, double range, boolean hitLiquids, public static RayTraceResult standardBlockRayTrace(World world, EntityLivingBase entity, double range, boolean hitLiquids,
boolean ignoreUncollidables, boolean returnLastUncollidable){ boolean ignoreUncollidables, boolean returnLastUncollidable){
// This method does not apply an offset like ray spells do, since it is not desirable in most other use cases. // This method does not apply an offset like ray spells do, since it is not desirable in most other use cases.
Vec3d origin = new Vec3d(entity.posX, entity.getEntityBoundingBox().minY + entity.getEyeHeight(), entity.posZ); Vec3d origin = entity.getPositionEyes(1);
Vec3d endpoint = origin.add(entity.getLookVec().scale(range)); Vec3d endpoint = origin.add(entity.getLookVec().scale(range));
return world.rayTraceBlocks(origin, endpoint, hitLiquids, ignoreUncollidables, returnLastUncollidable); return world.rayTraceBlocks(origin, endpoint, hitLiquids, ignoreUncollidables, returnLastUncollidable);
} }
@@ -76,7 +76,7 @@ public final class RayTracer {
@Nullable @Nullable
public static RayTraceResult standardEntityRayTrace(World world, Entity entity, double range, boolean hitLiquids){ public static RayTraceResult standardEntityRayTrace(World world, Entity entity, double range, boolean hitLiquids){
// This method does not apply an offset like ray spells do, since it is not desirable in most other use cases. // This method does not apply an offset like ray spells do, since it is not desirable in most other use cases.
Vec3d origin = new Vec3d(entity.posX, entity.getEntityBoundingBox().minY + entity.getEyeHeight(), entity.posZ); Vec3d origin = entity.getPositionEyes(1);
Vec3d endpoint = origin.add(entity.getLookVec().scale(range)); Vec3d endpoint = origin.add(entity.getLookVec().scale(range));
return rayTrace(world, origin, endpoint, 0, hitLiquids, false, false, Entity.class, ignoreEntityFilter(entity)); return rayTrace(world, origin, endpoint, 0, hitLiquids, false, false, Entity.class, ignoreEntityFilter(entity));
} }