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
@@ -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.
ParticleBuilder.create(Type.LIGHTNING).entity(caster)
.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.
@@ -109,7 +109,7 @@ public class ArcaneJammer extends SpellRay {
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++){
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 z = MathHelper.floor(entity.posZ - MathHelper.cos(angle) * radius);
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){
for(int i=0; i<10; i++){
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;
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, 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){
for(int i = 0; i < 10; i++){
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;
// For portal particles, velocity is not velocity but the offset where they start, then drift to
// 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)
+ 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;
int x = MathHelper.floor(target.posX + MathHelper.sin(angle) * radius);
@@ -94,7 +94,7 @@ public class Blink extends Spell {
if(world.isRemote){
for(int i = 0; i < 10; i++){
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;
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, 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)
.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());
@@ -84,7 +84,7 @@ public class Divination extends Spell {
BlockPos target = sphere.get(sphere.size() - 1);
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));
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);
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));
double dz = target.posZ - caster.posZ;
@@ -41,7 +41,7 @@ public class Fangs extends Spell {
@Override
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;
this.playSound(world, caster, ticksInUse, -1, modifiers);
return true;
@@ -3,12 +3,9 @@ package electroblob.wizardry.spell;
import electroblob.wizardry.client.DrawingUtils;
import electroblob.wizardry.item.SpellActions;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.util.BlockUtils;
import electroblob.wizardry.util.*;
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.SpellModifiers;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -32,7 +29,7 @@ public class Firestorm extends SpellAreaEffect {
@Override
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);
}
@@ -18,7 +18,7 @@ public class FlamingAxe extends SpellConjuration {
for(int i=0; i<10; i++){
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;
world.spawnParticle(EnumParticleTypes.FLAME, x, y, z, 0, 0, 0);
}
@@ -46,7 +46,7 @@ public class FlamingWeapon extends Spell {
if(world.isRemote){
for(int i=0; i<10; i++){
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;
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){
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;
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;
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;
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){
for(int i=0; i<10; i++){
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;
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++){
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;
ParticleBuilder.create(Type.SNOW).pos(x, y, z).spawn(world);
}
@@ -57,11 +57,11 @@ public class Glide extends Spell {
if(world.isRemote){
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;
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;
y = caster.getEntityBoundingBox().minY + world.rand.nextDouble();
y = caster.posY + world.rand.nextDouble();
z = caster.posZ - 0.25 + world.rand.nextDouble() / 2;
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);
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);
@@ -98,7 +98,7 @@ public class Grapple extends Spell {
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
// 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);
@@ -209,11 +209,11 @@ public class Grapple extends Spell {
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
// 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);
@@ -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
// 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);
Vec3d vec = target.subtract(origin).normalize();
@@ -344,7 +344,7 @@ public class Grapple extends Spell {
if(caster != null){
origin = new Vec3d(caster.posX, caster.getEntityBoundingBox().minY + caster.getEyeHeight(), caster.posZ);
origin = caster.getPositionEyes(1);
if(caster instanceof EntityPlayer){
WizardData data = WizardData.get((EntityPlayer)caster);
@@ -354,7 +354,7 @@ public class Grapple extends Spell {
}
}else if(caster instanceof EntityLiving){
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();
@@ -6,11 +6,8 @@ import electroblob.wizardry.registry.WizardryBlocks;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.registry.WizardryPotions;
import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.util.BlockUtils;
import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.*;
import electroblob.wizardry.util.ParticleBuilder.Type;
import electroblob.wizardry.util.SpellModifiers;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -36,7 +33,7 @@ public class IceAge extends SpellAreaEffect {
@Override
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);
}
@@ -65,7 +65,7 @@ public class ImbueWeapon extends Spell {
if(world.isRemote){
for(int i=0; i<10; i++){
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;
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
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++){
double x = origin.x - 1 + world.rand.nextDouble() * 2;
@@ -54,7 +54,7 @@ public class InvokeWeather extends Spell {
if(world.isRemote){
for(int i = 0; i < 10; i++){
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;
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){
for(int i = 0; i < 10; i++){
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;
world.spawnParticle(EnumParticleTypes.CLOUD, x, y, z, 0, 0, 0);
}
@@ -47,7 +47,7 @@ public class Levitation extends Spell {
if(world.isRemote){
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;
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){
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)
.scale(modifiers.get(WizardryItems.blast_upgrade)).spawn(world);
}
@@ -85,10 +85,10 @@ public class MindControl extends SpellRay {
for(int i=0; i<10; i++){
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);
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);
}
}
@@ -53,7 +53,7 @@ public class MindTrick extends SpellRay {
}else{
for(int i=0; i<10; i++){
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);
}
}
@@ -42,7 +42,7 @@ public class PhaseStep extends Spell {
for(int i = 0; i < 10; i++){
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;
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, 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){
for(int i = 0; i < 10; i++){
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);
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){
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;
@@ -43,7 +43,7 @@ public class RemoveCurse extends SpellBuff {
for(int i = 0; i < particleCount*2; i++){
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;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.14, 0).clr(0x0f001b)
.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 dy = -1 + 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){
@@ -70,7 +70,7 @@ public class Shockwave extends SpellAreaEffect {
double velocityFactor = proximity * getProperty(MAX_REPULSION_VELOCITY).floatValue();
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;
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.
// 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));
int startPoint = direction.getAxisDirection() == AxisDirection.POSITIVE ? -1 : 0;
@@ -108,7 +108,7 @@ public class SpeedTime extends Spell {
double particleSpread = 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;
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.util.AllyDesignationSystem;
import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.GeometryUtils;
import electroblob.wizardry.util.SpellModifiers;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
@@ -104,7 +105,7 @@ public abstract class SpellAreaEffect extends Spell {
@Override
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);
if(result) this.playSound(world, caster, ticksInUse, -1, modifiers);
return result;
@@ -195,7 +195,7 @@ public class SpellBuff extends Spell {
for(int i = 0; i < particleCount; i++){
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;
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++){
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;
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();
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;
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){
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){
@@ -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);
@@ -127,10 +127,10 @@ public class SpellThrowable<T extends EntityThrowable> extends Spell {
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 dy = !throwable.hasNoGravity() ? target.getEntityBoundingBox().minY + (double)(target.height / 3.0f) - throwable.posY
: target.getEntityBoundingBox().minY + (double)(target.height / 2.0f) - throwable.posY;
double dy = !throwable.hasNoGravity() ? target.posY + (double)(target.height / 3.0f) - throwable.posY
: target.posY + (double)(target.height / 2.0f) - throwable.posY;
double dz = target.posZ - caster.posZ;
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.spawnShockParticles(world, secondaryTarget.posX,
secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height / 2,
secondaryTarget.posY + secondaryTarget.height / 2,
secondaryTarget.posZ);
}
@@ -115,7 +115,7 @@ public class Thunderstorm extends Spell {
ParticleBuilder.create(Type.LIGHTNING).entity(secondaryTarget)
.pos(0, secondaryTarget.height / 2, 0).target(tertiaryTarget).spawn(world);
ParticleBuilder.spawnShockParticles(world, tertiaryTarget.posX,
tertiaryTarget.getEntityBoundingBox().minY + tertiaryTarget.height / 2,
tertiaryTarget.posY + tertiaryTarget.height / 2,
tertiaryTarget.posZ);
}
@@ -41,7 +41,7 @@ public class Whirlwind extends SpellRay {
// Left as EntityLivingBase because why not be able to move armour stands around?
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){
@@ -74,7 +74,7 @@ public class WitherSkull extends Spell {
EntityWitherSkull witherskull = new EntityWitherSkull(world, caster, 1, 1, 1);
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));
double dz = target.posZ - caster.posZ;