diff options
Diffstat (limited to 'src/main/java/net/minecraft/server/Entity.java')
-rw-r--r-- | src/main/java/net/minecraft/server/Entity.java | 1280 |
1 files changed, 657 insertions, 623 deletions
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 8fd6672a..74a2ac9c 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -14,41 +14,41 @@ import java.util.Random; public abstract class Entity { - private static int a = 0; - public int g; + private static int entityCount = 0; + public int id; public double h; public boolean i; - public Entity j; - public Entity k; - public World l; - public double m; - public double n; - public double o; - public double p; - public double q; - public double r; - public double s; - public double t; - public double u; - public float v; - public float w; - public float x; - public float y; - public final AxisAlignedBB z = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); - public boolean A; + public Entity passenger; + public Entity vehicle; + public World world; + public double lastX; + public double lastY; + public double lastZ; + public double locX; + public double locY; + public double locZ; + public double motX; + public double motY; + public double motZ; + public float yaw; + public float pitch; + public float lastYaw; + public float lastPitch; + public final AxisAlignedBB boundingBox; + public boolean onGround; public boolean B; public boolean C; public boolean D; public boolean E; public boolean F; - public boolean G; - public float H; - public float I; - public float J; + public boolean dead; + public float height; + public float length; + public float width; public float K; public float L; protected boolean M; - protected float N; + protected float fallDistance; private int b; public double O; public double P; @@ -58,473 +58,509 @@ public abstract class Entity { public boolean T; public float U; public boolean V; - protected Random W; - public int X; - public int Y; - public int Z; - protected int aa; + protected Random random; + public int ticksLived; + public int maxFireTicks; + public int fireTicks; + protected int maxAirTicks; protected boolean ab; - public int ac; - public int ad; - private boolean c; + public int noDamageTicks; + public int airTicks; + private boolean justCreated; protected boolean ae; - protected DataWatcher af; + protected DataWatcher datawatcher; private double d; private double e; public boolean ag; - public int ah; + public int chunkX; public int ai; - public int aj; - - protected org.bukkit.entity.Entity bukkitEntity; // CraftBukkit + public int chunkZ; public Entity(World world) { - g = a++; - h = 1.0D; - i = false; - A = false; - D = false; - E = false; - F = true; - G = false; - H = 0.0F; - I = 0.6F; - J = 1.8F; - K = 0.0F; - L = 0.0F; - M = true; - N = 0.0F; - b = 1; - R = 0.0F; - S = 0.0F; - T = false; - U = 0.0F; - V = false; - W = new Random(); - X = 0; - Y = 1; - Z = 0; - aa = 300; - ab = false; - ac = 0; - ad = 300; - c = true; - ae = false; - af = new DataWatcher(); - ag = false; - l = world; - a(0.0D, 0.0D, 0.0D); - af.a(0, ((Byte.valueOf((byte) 0)))); - a(); - - bukkitEntity = null; // CraftBukkit + this.id = entityCount++; + this.h = 1.0D; + this.i = false; + this.boundingBox = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); + this.onGround = false; + this.D = false; + this.E = false; + this.F = true; + this.dead = false; + this.height = 0.0F; + this.length = 0.6F; + this.width = 1.8F; + this.K = 0.0F; + this.L = 0.0F; + this.M = true; + this.fallDistance = 0.0F; + this.b = 1; + this.R = 0.0F; + this.S = 0.0F; + this.T = false; + this.U = 0.0F; + this.V = false; + this.random = new Random(); + this.ticksLived = 0; + this.maxFireTicks = 1; + this.fireTicks = 0; + this.maxAirTicks = 300; + this.ab = false; + this.noDamageTicks = 0; + this.airTicks = 300; + this.justCreated = true; + this.ae = false; + this.datawatcher = new DataWatcher(); + this.ag = false; + this.world = world; + this.a(0.0D, 0.0D, 0.0D); + this.datawatcher.a(0, Byte.valueOf((byte) 0)); + this.a(); + + // CraftBukkit start + bukkitEntity = null; } + protected org.bukkit.entity.Entity bukkitEntity; + // CraftBukkit end protected abstract void a(); public DataWatcher p() { - return af; + return this.datawatcher; } - public boolean equals(Object obj) { - if (obj instanceof Entity) { - return ((Entity) obj).g == g; - } else { - return false; - } + public boolean equals(Object object) { + return object instanceof Entity ? ((Entity) object).id == this.id : false; } public int hashCode() { - return g; + return this.id; } public void q() { - G = true; + this.dead = true; } - protected void a(float f1, float f2) { - I = f1; - J = f2; + protected void a(float f, float f1) { + this.length = f; + this.width = f1; } - protected void b(float f1, float f2) { - v = f1; - w = f2; + protected void b(float f, float f1) { + this.yaw = f; + this.pitch = f1; } - public void a(double d1, double d2, double d3) { - p = d1; - q = d2; - r = d3; - float f1 = I / 2.0F; - float f2 = J; + public void a(double d0, double d1, double d2) { + this.locX = d0; + this.locY = d1; + this.locZ = d2; + float f = this.length / 2.0F; + float f1 = this.width; - z.c(d1 - (double) f1, (d2 - (double) H) + (double) R, d3 - (double) f1, d1 + (double) f1, (d2 - (double) H) + (double) R + (double) f2, d3 + (double) f1); + this.boundingBox.c(d0 - (double) f, d1 - (double) this.height + (double) this.R, d2 - (double) f, d0 + (double) f, d1 - (double) this.height + (double) this.R + (double) f1, d2 + (double) f); } public void b_() { - r(); + this.r(); } public void r() { - if (k != null && k.G) { - k = null; + if (this.vehicle != null && this.vehicle.dead) { + this.vehicle = null; } - X++; - K = L; - m = p; - n = q; - o = r; - y = w; - x = v; - if (v()) { - if (!ab && !c) { - float f1 = MathHelper.a(s * s * 0.20000000298023224D + t * t + u * u * 0.20000000298023224D) * 0.2F; - - if (f1 > 1.0F) { - f1 = 1.0F; + + ++this.ticksLived; + this.K = this.L; + this.lastX = this.locX; + this.lastY = this.locY; + this.lastZ = this.locZ; + this.lastPitch = this.pitch; + this.lastYaw = this.yaw; + if (this.v()) { + if (!this.ab && !this.justCreated) { + float f = MathHelper.a(this.motX * this.motX * 0.20000000298023224D + this.motY * this.motY + this.motZ * this.motZ * 0.20000000298023224D) * 0.2F; + + if (f > 1.0F) { + f = 1.0F; } - l.a(this, "random.splash", f1, 1.0F + (W.nextFloat() - W.nextFloat()) * 0.4F); - float f2 = MathHelper.b(z.b); - for (int i1 = 0; (float) i1 < 1.0F + I * 20F; i1++) { - float f3 = (W.nextFloat() * 2.0F - 1.0F) * I; - float f5 = (W.nextFloat() * 2.0F - 1.0F) * I; + this.world.a(this, "random.splash", f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); + float f1 = (float) MathHelper.b(this.boundingBox.b); - l.a("bubble", p + (double) f3, f2 + 1.0F, r + (double) f5, s, t - (double) (W.nextFloat() * 0.2F), u); - } + int i; + float f2; + float f3; - for (int j1 = 0; (float) j1 < 1.0F + I * 20F; j1++) { - float f4 = (W.nextFloat() * 2.0F - 1.0F) * I; - float f6 = (W.nextFloat() * 2.0F - 1.0F) * I; + for (i = 0; (float) i < 1.0F + this.length * 20.0F; ++i) { + f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length; + f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length; + this.world.a("bubble", this.locX + (double) f2, (double) (f1 + 1.0F), this.locZ + (double) f3, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ); + } - l.a("splash", p + (double) f4, f2 + 1.0F, r + (double) f6, s, t, u); + for (i = 0; (float) i < 1.0F + this.length * 20.0F; ++i) { + f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length; + f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length; + this.world.a("splash", this.locX + (double) f2, (double) (f1 + 1.0F), this.locZ + (double) f3, this.motX, this.motY, this.motZ); } } - N = 0.0F; - ab = true; - Z = 0; + + this.fallDistance = 0.0F; + this.ab = true; + this.fireTicks = 0; } else { - ab = false; + this.ab = false; } - if (l.z) { - Z = 0; - } else if (Z > 0) { - if (ae) { - Z -= 4; - if (Z < 0) { - Z = 0; + + if (this.world.isStatic) { + this.fireTicks = 0; + } else if (this.fireTicks > 0) { + if (this.ae) { + this.fireTicks -= 4; + if (this.fireTicks < 0) { + this.fireTicks = 0; } } else { - if (Z % 20 == 0) { + if (this.fireTicks % 20 == 0) { // CraftBukkit start // TODO: this event spams! if(this instanceof EntityLiving) { - CraftServer server = ((WorldServer) l).getServer(); + CraftServer server = ((WorldServer) this.world).getServer(); org.bukkit.entity.Entity damagee = this.getBukkitEntity(); DamageCause damageType = EntityDamageEvent.DamageCause.DROWNING; int damageDone = 1; - EntityDamageEvent ede = new EntityDamageEvent(damagee, damageType, damageDone); - server.getPluginManager().callEvent(ede); + EntityDamageEvent event = new EntityDamageEvent(damagee, damageType, damageDone); + server.getPluginManager().callEvent(event); - if (!ede.isCancelled()){ - a(((Entity) (null)), ede.getDamage()); + if (!event.isCancelled()){ + this.a((Entity) null, event.getDamage()); } } else { - a(((Entity) (null)), 1); + this.a((Entity) null, 1); } // CraftBukkit end } - Z--; + + --this.fireTicks; } } - if (x()) { - s(); + + if (this.x()) { + this.s(); } - if (q < -64D) { - t(); + + if (this.locY < -64.0D) { + this.t(); } - if (!l.z) { - a(0, Z > 0); - a(2, k != null); + + if (!this.world.isStatic) { + this.a(0, this.fireTicks > 0); + this.a(2, this.vehicle != null); } - c = false; + + this.justCreated = false; } protected void s() { - if (!ae) { + if (!this.ae) { // CraftBukkit start // TODO: this event spams! if(this instanceof EntityLiving) { - CraftServer server = ((WorldServer) l).getServer(); + CraftServer server = ((WorldServer) this.world).getServer(); // TODO: shouldn't be sending null for the block. - org.bukkit.block.Block damager = null;//((WorldServer) l).getWorld().getBlockAt(i, j, k); + org.bukkit.block.Block damager = null; //((WorldServer) this.l).getWorld().getBlockAt(i, j, k); org.bukkit.entity.Entity damagee = this.getBukkitEntity(); DamageCause damageType = EntityDamageEvent.DamageCause.LAVA; int damageDone = 4; - EntityDamageByBlockEvent ede = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone); - server.getPluginManager().callEvent(ede); - if (!ede.isCancelled()){ - a(((Entity) (null)), ede.getDamage()); + EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone); + server.getPluginManager().callEvent(event); + if (!event.isCancelled()){ + this.a((Entity) null, event.getDamage()); } - if(Z <= 0){ + if(this.fireTicks <= 0){ // not on fire yet Type eventType = Type.ENTITY_COMBUST; - EntityCombustEvent ece = new EntityCombustEvent(eventType, damagee); - server.getPluginManager().callEvent(ece); - if (!ece.isCancelled()){ - Z = 600; + EntityCombustEvent combustEvent = new EntityCombustEvent(eventType, damagee); + server.getPluginManager().callEvent(combustEvent); + if (!combustEvent.isCancelled()){ + this.fireTicks = 600; } } else { // reset fire level back to max - Z = 600; + this.fireTicks = 600; } - - } else { - a(((Entity) (null)), 4); - Z = 600; + return; } // CraftBukkit end + + this.a((Entity) null, 4); + this.fireTicks = 600; } } protected void t() { - q(); + this.q(); } - public boolean b(double d1, double d2, double d3) { - AxisAlignedBB axisalignedbb = z.c(d1, d2, d3); - List list = l.a(this, axisalignedbb); + public boolean b(double d0, double d1, double d2) { + AxisAlignedBB axisalignedbb = this.boundingBox.c(d0, d1, d2); + List list = this.world.a(this, axisalignedbb); - if (list.size() > 0) { - return false; - } - return !l.b(axisalignedbb); + return list.size() > 0 ? false : !this.world.b(axisalignedbb); } - public void c(double d1, double d2, double d3) { - if (T) { - z.d(d1, d2, d3); - p = (z.a + z.d) / 2D; - q = (z.b + (double) H) - (double) R; - r = (z.c + z.f) / 2D; - return; - } - double d4 = p; - double d5 = r; - double d6 = d1; - double d7 = d2; - double d8 = d3; - AxisAlignedBB axisalignedbb = z.b(); - boolean flag = A && J(); - - if (flag) { - double d9 = 0.050000000000000003D; - - for (; d1 != 0.0D && l.a(this, z.c(d1, -1D, 0.0D)).size() == 0; d6 = d1) { - if (d1 < d9 && d1 >= -d9) { - d1 = 0.0D; - continue; - } - if (d1 > 0.0D) { - d1 -= d9; - } else { - d1 += d9; + public void c(double d0, double d1, double d2) { + if (this.T) { + this.boundingBox.d(d0, d1, d2); + this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D; + this.locY = this.boundingBox.b + (double) this.height - (double) this.R; + this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D; + } else { + double d3 = this.locX; + double d4 = this.locZ; + double d5 = d0; + double d6 = d1; + double d7 = d2; + AxisAlignedBB axisalignedbb = this.boundingBox.b(); + boolean flag = this.onGround && this.J(); + + if (flag) { + double d8; + + for (d8 = 0.05D; d0 != 0.0D && this.world.a(this, this.boundingBox.c(d0, -1.0D, 0.0D)).size() == 0; d5 = d0) { + if (d0 < d8 && d0 >= -d8) { + d0 = 0.0D; + } else if (d0 > 0.0D) { + d0 -= d8; + } else { + d0 += d8; + } } - } - for (; d3 != 0.0D && l.a(this, z.c(0.0D, -1D, d3)).size() == 0; d8 = d3) { - if (d3 < d9 && d3 >= -d9) { - d3 = 0.0D; - continue; - } - if (d3 > 0.0D) { - d3 -= d9; - } else { - d3 += d9; + for (; d2 != 0.0D && this.world.a(this, this.boundingBox.c(0.0D, -1.0D, d2)).size() == 0; d7 = d2) { + if (d2 < d8 && d2 >= -d8) { + d2 = 0.0D; + } else if (d2 > 0.0D) { + d2 -= d8; + } else { + d2 += d8; + } } } - } - List list = l.a(this, z.a(d1, d2, d3)); - for (int i1 = 0; i1 < list.size(); i1++) { - d2 = ((AxisAlignedBB) list.get(i1)).b(z, d2); - } - - z.d(0.0D, d2, 0.0D); - if (!F && d7 != d2) { - d1 = d2 = d3 = 0.0D; - } - boolean flag1 = A || d7 != d2 && d7 < 0.0D; + List list = this.world.a(this, this.boundingBox.a(d0, d1, d2)); - for (int j1 = 0; j1 < list.size(); j1++) { - d1 = ((AxisAlignedBB) list.get(j1)).a(z, d1); - } + for (int i = 0; i < list.size(); ++i) { + d1 = ((AxisAlignedBB) list.get(i)).b(this.boundingBox, d1); + } - z.d(d1, 0.0D, 0.0D); - if (!F && d6 != d1) { - d1 = d2 = d3 = 0.0D; - } - for (int k1 = 0; k1 < list.size(); k1++) { - d3 = ((AxisAlignedBB) list.get(k1)).c(z, d3); - } + this.boundingBox.d(0.0D, d1, 0.0D); + if (!this.F && d6 != d1) { + d2 = 0.0D; + d1 = 0.0D; + d0 = 0.0D; + } - z.d(0.0D, 0.0D, d3); - if (!F && d8 != d3) { - d1 = d2 = d3 = 0.0D; - } - if (S > 0.0F && flag1 && R < 0.05F && (d6 != d1 || d8 != d3)) { - double d10 = d1; - double d12 = d2; - double d14 = d3; + boolean flag1 = this.onGround || d6 != d1 && d6 < 0.0D; - d1 = d6; - d2 = S; - d3 = d8; - AxisAlignedBB axisalignedbb1 = z.b(); + int j; - z.b(axisalignedbb); - List list1 = l.a(this, z.a(d1, d2, d3)); + for (j = 0; j < list.size(); ++j) { + d0 = ((AxisAlignedBB) list.get(j)).a(this.boundingBox, d0); + } - for (int j2 = 0; j2 < list1.size(); j2++) { - d2 = ((AxisAlignedBB) list1.get(j2)).b(z, d2); + this.boundingBox.d(d0, 0.0D, 0.0D); + if (!this.F && d5 != d0) { + d2 = 0.0D; + d1 = 0.0D; + d0 = 0.0D; } - z.d(0.0D, d2, 0.0D); - if (!F && d7 != d2) { - d1 = d2 = d3 = 0.0D; + for (j = 0; j < list.size(); ++j) { + d2 = ((AxisAlignedBB) list.get(j)).c(this.boundingBox, d2); } - for (int k2 = 0; k2 < list1.size(); k2++) { - d1 = ((AxisAlignedBB) list1.get(k2)).a(z, d1); + + this.boundingBox.d(0.0D, 0.0D, d2); + if (!this.F && d7 != d2) { + d2 = 0.0D; + d1 = 0.0D; + d0 = 0.0D; } - z.d(d1, 0.0D, 0.0D); - if (!F && d6 != d1) { - d1 = d2 = d3 = 0.0D; + double d9; + double d10; + int k; + + if (this.S > 0.0F && flag1 && this.R < 0.05F && (d5 != d0 || d7 != d2)) { + d9 = d0; + d10 = d1; + double d11 = d2; + + d0 = d5; + d1 = (double) this.S; + d2 = d7; + AxisAlignedBB axisalignedbb1 = this.boundingBox.b(); + + this.boundingBox.b(axisalignedbb); + list = this.world.a(this, this.boundingBox.a(d5, d1, d7)); + + for (k = 0; k < list.size(); ++k) { + d1 = ((AxisAlignedBB) list.get(k)).b(this.boundingBox, d1); + } + + this.boundingBox.d(0.0D, d1, 0.0D); + if (!this.F && d6 != d1) { + d2 = 0.0D; + d1 = 0.0D; + d0 = 0.0D; + } + + for (k = 0; k < list.size(); ++k) { + d0 = ((AxisAlignedBB) list.get(k)).a(this.boundingBox, d0); + } + + this.boundingBox.d(d0, 0.0D, 0.0D); + if (!this.F && d5 != d0) { + d2 = 0.0D; + d1 = 0.0D; + d0 = 0.0D; + } + + for (k = 0; k < list.size(); ++k) { + d2 = ((AxisAlignedBB) list.get(k)).c(this.boundingBox, d2); + } + + this.boundingBox.d(0.0D, 0.0D, d2); + if (!this.F && d7 != d2) { + d2 = 0.0D; + d1 = 0.0D; + d0 = 0.0D; + } + + if (d9 * d9 + d11 * d11 >= d0 * d0 + d2 * d2) { + d0 = d9; + d1 = d10; + d2 = d11; + this.boundingBox.b(axisalignedbb1); + } else { + this.R = (float) ((double) this.R + 0.5D); + } } - for (int l2 = 0; l2 < list1.size(); l2++) { - d3 = ((AxisAlignedBB) list1.get(l2)).c(z, d3); + + this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D; + this.locY = this.boundingBox.b + (double) this.height - (double) this.R; + this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D; + this.B = d5 != d0 || d7 != d2; + this.C = d6 != d1; + this.onGround = d6 != d1 && d6 < 0.0D; + this.D = this.B || this.C; + this.a(d1, this.onGround); + if (d5 != d0) { + this.motX = 0.0D; } - z.d(0.0D, 0.0D, d3); - if (!F && d8 != d3) { - d1 = d2 = d3 = 0.0D; + if (d6 != d1) { + this.motY = 0.0D; } - if (d10 * d10 + d14 * d14 >= d1 * d1 + d3 * d3) { - d1 = d10; - d2 = d12; - d3 = d14; - z.b(axisalignedbb1); - } else { - R += 0.5D; + + if (d7 != d2) { + this.motZ = 0.0D; } - } - p = (z.a + z.d) / 2D; - q = (z.b + (double) H) - (double) R; - r = (z.c + z.f) / 2D; - B = d6 != d1 || d8 != d3; - C = d7 != d2; - A = d7 != d2 && d7 < 0.0D; - D = B || C; - a(d2, A); - if (d6 != d1) { - s = 0.0D; - } - if (d7 != d2) { - t = 0.0D; - } - if (d8 != d3) { - u = 0.0D; - } - double d11 = p - d4; - double d13 = r - d5; - - if (M && !flag) { - L += ((float) ((double) MathHelper.a(d11 * d11 + d13 * d13) * 0.59999999999999998D)); - int k3 = MathHelper.b(p); - int i4 = MathHelper.b(q - 0.20000000298023224D - (double) H); - int l1 = MathHelper.b(r); - int i3 = l.a(k3, i4, l1); - - if (L > (float) b && i3 > 0) { - b++; - StepSound stepsound = Block.m[i3].br; - - if (l.a(k3, i4 + 1, l1) == Block.aS.bi) { - stepsound = Block.aS.br; - l.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b()); - } else if (!Block.m[i3].bt.d()) { - l.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b()); + + d9 = this.locX - d3; + d10 = this.locZ - d4; + int l; + int i1; + int j1; + + if (this.M && !flag) { + this.L = (float) ((double) this.L + (double) MathHelper.a(d9 * d9 + d10 * d10) * 0.6D); + l = MathHelper.b(this.locX); + i1 = MathHelper.b(this.locY - 0.20000000298023224D - (double) this.height); + j1 = MathHelper.b(this.locZ); + k = this.world.getTypeId(l, i1, j1); + if (this.L > (float) this.b && k > 0) { + ++this.b; + StepSound stepsound = Block.byId[k].stepSound; + + if (this.world.getTypeId(l, i1 + 1, j1) == Block.SNOW.id) { + stepsound = Block.SNOW.stepSound; + this.world.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b()); + } else if (!Block.byId[k].material.isLiquid()) { + this.world.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b()); + } + + Block.byId[k].b(this.world, l, i1, j1, this); } - Block.m[i3].b(l, k3, i4, l1, this); } - } - int l3 = MathHelper.b(z.a); - int j4 = MathHelper.b(z.b); - int i2 = MathHelper.b(z.c); - int j3 = MathHelper.b(z.d); - int k4 = MathHelper.b(z.e); - int l4 = MathHelper.b(z.f); - - if (l.a(l3, j4, i2, j3, k4, l4)) { - for (int i5 = l3; i5 <= j3; i5++) { - for (int j5 = j4; j5 <= k4; j5++) { - for (int k5 = i2; k5 <= l4; k5++) { - int l5 = l.a(i5, j5, k5); - - if (l5 > 0) { - Block.m[l5].a(l, i5, j5, k5, this); + + l = MathHelper.b(this.boundingBox.a); + i1 = MathHelper.b(this.boundingBox.b); + j1 = MathHelper.b(this.boundingBox.c); + k = MathHelper.b(this.boundingBox.d); + int k1 = MathHelper.b(this.boundingBox.e); + int l1 = MathHelper.b(this.boundingBox.f); + + if (this.world.a(l, i1, j1, k, k1, l1)) { + for (int i2 = l; i2 <= k; ++i2) { + for (int j2 = i1; j2 <= k1; ++j2) { + for (int k2 = j1; k2 <= l1; ++k2) { + int l2 = this.world.getTypeId(i2, j2, k2); + + if (l2 > 0) { + Block.byId[l2].a(this.world, i2, j2, k2, this); + } } } } } - } - R *= 0.4F; - boolean flag2 = v(); - - if (l.c(z)) { - b(1); - if (!flag2) { - Z++; - // CraftBukkit start - if(Z <= 0){ - // not on fire yet - CraftServer server = ((WorldServer) l).getServer(); - org.bukkit.entity.Entity damagee = this.getBukkitEntity(); - Type eventType = Type.ENTITY_COMBUST; - - EntityCombustEvent ece = new EntityCombustEvent(eventType, damagee); - server.getPluginManager().callEvent(ece); - - if (!ece.isCancelled()){ - Z = 300; + + this.R *= 0.4F; + boolean flag2 = this.v(); + + if (this.world.c(this.boundingBox)) { + this.b(1); + if (!flag2) { + ++this.fireTicks; + // CraftBukkit start + if (this.fireTicks <= 0){ + // not on fire yet + CraftServer server = ((WorldServer) this.world).getServer(); + org.bukkit.entity.Entity damagee = this.getBukkitEntity(); + Type eventType = Type.ENTITY_COMBUST; + + EntityCombustEvent event = new EntityCombustEvent(eventType, damagee); + server.getPluginManager().callEvent(event); + + if (!event.isCancelled()){ + this.fireTicks = 300; + } + } else { + // CraftBukkit end - reset fire level back to max + this.fireTicks = 300; } - } else { - // reset fire level back to max - Z = 300; } - // CraftBukkit end + } else if (this.fireTicks <= 0) { + this.fireTicks = -this.maxFireTicks; + } + + if (flag2 && this.fireTicks > 0) { + this.world.a(this, "random.fizz", 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); + this.fireTicks = -this.maxFireTicks; } - } else if (Z <= 0) { - Z = -Y; - } - if (flag2 && Z > 0) { - l.a(this, "random.fizz", 0.7F, 1.6F + (W.nextFloat() - W.nextFloat()) * 0.4F); - Z = -Y; } } - protected void a(double d1, boolean flag) { + protected void a(double d0, boolean flag) { if (flag) { - if (N > 0.0F) { - a(N); - N = 0.0F; + if (this.fallDistance > 0.0F) { + this.a(this.fallDistance); + this.fallDistance = 0.0F; } - } else if (d1 < 0.0D) { - N -= ((float) (d1)); + } else if (d0 < 0.0D) { + this.fallDistance = (float) ((double) this.fallDistance - d0); } } @@ -532,46 +568,46 @@ public abstract class Entity { return null; } - protected void b(int i1) { - if (!ae) { + protected void b(int i) { + if (!this.ae) { // CraftBukkit start if(this instanceof EntityLiving) { - CraftServer server = ((WorldServer) l).getServer(); + CraftServer server = ((WorldServer) this.world).getServer(); org.bukkit.entity.Entity damagee = this.getBukkitEntity(); DamageCause damageType = EntityDamageEvent.DamageCause.FIRE; - int damageDone = i1; + int damageDone = i; - EntityDamageEvent ede = new EntityDamageEvent(damagee, damageType, damageDone); - server.getPluginManager().callEvent(ede); + EntityDamageEvent event = new EntityDamageEvent(damagee, damageType, damageDone); + server.getPluginManager().callEvent(event); - if (!ede.isCancelled()){ - a(((Entity) (null)), ede.getDamage()); + if (!event.isCancelled()){ + this.a((Entity) null, event.getDamage()); } return; } // CraftBukkit end - a(((Entity) (null)), i1); + this.a((Entity) null, i); } } - protected void a(float f1) {} + protected void a(float f) {} public boolean v() { - return l.a(z.b(0.0D, -0.40000000596046448D, 0.0D), Material.f, this); + return this.world.a(this.boundingBox.b(0.0D, -0.4000000059604645D, 0.0D), Material.WATER, this); } public boolean a(Material material) { - double d1 = q + (double) w(); - int i1 = MathHelper.b(p); - int j1 = MathHelper.d(MathHelper.b(d1)); - int k1 = MathHelper.b(r); - int l1 = l.a(i1, j1, k1); + double d0 = this.locY + (double) this.w(); + int i = MathHelper.b(this.locX); + int j = MathHelper.d((float) MathHelper.b(d0)); + int k = MathHelper.b(this.locZ); + int l = this.world.getTypeId(i, j, k); - if (l1 != 0 && Block.m[l1].bt == material) { - float f1 = BlockFluids.c(l.b(i1, j1, k1)) - 0.1111111F; - float f2 = (float) (j1 + 1) - f1; + if (l != 0 && Block.byId[l].material == material) { + float f = BlockFluids.c(this.world.getData(i, j, k)) - 0.11111111F; + float f1 = (float) (j + 1) - f; - return d1 < (double) f2; + return d0 < (double) f1; } else { return false; } @@ -582,143 +618,141 @@ public abstract class Entity { } public boolean x() { - return l.a(z.b(-0.10000000149011612D, -0.40000000596046448D, -0.10000000149011612D), Material.g); + return this.world.a(this.boundingBox.b(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.LAVA); } - public void a(float f1, float f2, float f3) { - float f4 = MathHelper.c(f1 * f1 + f2 * f2); - - if (f4 < 0.01F) { - return; - } - if (f4 < 1.0F) { - f4 = 1.0F; - } - f4 = f3 / f4; - f1 *= f4; - f2 *= f4; - float f5 = MathHelper.a((v * 3.141593F) / 180F); - float f6 = MathHelper.b((v * 3.141593F) / 180F); + public void a(float f, float f1, float f2) { + float f3 = MathHelper.c(f * f + f1 * f1); - s += f1 * f6 - f2 * f5; - u += f2 * f6 + f1 * f5; - } + if (f3 >= 0.01F) { + if (f3 < 1.0F) { + f3 = 1.0F; + } - public float b(float f1) { - int i1 = MathHelper.b(p); - double d1 = (z.e - z.b) * 0.66000000000000003D; - int j1 = MathHelper.b((q - (double) H) + d1); - int k1 = MathHelper.b(r); + f3 = f2 / f3; + f *= f3; + f1 *= f3; + float f4 = MathHelper.a(this.yaw * 3.1415927F / 180.0F); + float f5 = MathHelper.b(this.yaw * 3.1415927F / 180.0F); - if (l.a(MathHelper.b(z.a), MathHelper.b(z.b), MathHelper.b(z.c), MathHelper.b(z.d), MathHelper.b(z.e), MathHelper.b(z.f))) { - return l.l(i1, j1, k1); - } else { - return 0.0F; + this.motX += (double) (f * f5 - f1 * f4); + this.motZ += (double) (f1 * f5 + f * f4); } } - public void b(double d1, double d2, double d3, float f1, float f2) { - m = p = d1; - n = q = d2; - o = r = d3; - x = v = f1; - y = w = f2; - R = 0.0F; - double d4 = x - f1; + public float b(float f) { + int i = MathHelper.b(this.locX); + double d0 = (this.boundingBox.e - this.boundingBox.b) * 0.66D; + int j = MathHelper.b(this.locY - (double) this.height + d0); + int k = MathHelper.b(this.locZ); + + return this.world.a(MathHelper.b(this.boundingBox.a), MathHelper.b(this.boundingBox.b), MathHelper.b(this.boundingBox.c), MathHelper.b(this.boundingBox.d), MathHelper.b(this.boundingBox.e), MathHelper.b(this.boundingBox.f)) ? this.world.l(i, j, k) : 0.0F; + } - if (d4 < -180D) { - x += 360F; + public void b(double d0, double d1, double d2, float f, float f1) { + this.lastX = this.locX = d0; + this.lastY = this.locY = d1; + this.lastZ = this.locZ = d2; + this.lastYaw = this.yaw = f; + this.lastPitch = this.pitch = f1; + this.R = 0.0F; + double d3 = (double) (this.lastYaw - f); + + if (d3 < -180.0D) { + this.lastYaw += 360.0F; } - if (d4 >= 180D) { - x -= 360F; + + if (d3 >= 180.0D) { + this.lastYaw -= 360.0F; } - a(p, q, r); - b(f1, f2); + + this.a(this.locX, this.locY, this.locZ); + this.b(f, f1); } - public void c(double d1, double d2, double d3, float f1, float f2) { - O = m = p = d1; - P = n = q = d2 + (double) H; - Q = o = r = d3; - v = f1; - w = f2; - a(p, q, r); + public void c(double d0, double d1, double d2, float f, float f1) { + this.O = this.lastX = this.locX = d0; + this.P = this.lastY = this.locY = d1 + (double) this.height; + this.Q = this.lastZ = this.locZ = d2; + this.yaw = f; + this.pitch = f1; + this.a(this.locX, this.locY, this.locZ); } public float a(Entity entity) { - float f1 = (float) (p - entity.p); - float f2 = (float) (q - entity.q); - float f3 = (float) (r - entity.r); + float f = (float) (this.locX - entity.locX); + float f1 = (float) (this.locY - entity.locY); + float f2 = (float) (this.locZ - entity.locZ); - return MathHelper.c(f1 * f1 + f2 * f2 + f3 * f3); + return MathHelper.c(f * f + f1 * f1 + f2 * f2); } - public double d(double d1, double d2, double d3) { - double d4 = p - d1; - double d5 = q - d2; - double d6 = r - d3; + public double d(double d0, double d1, double d2) { + double d3 = this.locX - d0; + double d4 = this.locY - d1; + double d5 = this.locZ - d2; - return d4 * d4 + d5 * d5 + d6 * d6; + return d3 * d3 + d4 * d4 + d5 * d5; } - public double e(double d1, double d2, double d3) { - double d4 = p - d1; - double d5 = q - d2; - double d6 = r - d3; + public double e(double d0, double d1, double d2) { + double d3 = this.locX - d0; + double d4 = this.locY - d1; + double d5 = this.locZ - d2; - return (double) MathHelper.a(d4 * d4 + d5 * d5 + d6 * d6); + return (double) MathHelper.a(d3 * d3 + d4 * d4 + d5 * d5); } public double b(Entity entity) { - double d1 = p - entity.p; - double d2 = q - entity.q; - double d3 = r - entity.r; + double d0 = this.locX - entity.locX; + double d1 = this.locY - entity.locY; + double d2 = this.locZ - entity.locZ; - return d1 * d1 + d2 * d2 + d3 * d3; + return d0 * d0 + d1 * d1 + d2 * d2; } - public void b(EntityPlayer entityplayer) {} + public void b(EntityHuman entityhuman) {} public void c(Entity entity) { - if (entity.j == this || entity.k == this) { - return; - } - double d1 = entity.p - p; - double d2 = entity.r - r; - double d3 = MathHelper.a(d1, d2); - - if (d3 >= 0.0099999997764825821D) { - d3 = MathHelper.a(d3); - d1 /= d3; - d2 /= d3; - double d4 = 1.0D / d3; - - if (d4 > 1.0D) { - d4 = 1.0D; - } - d1 *= d4; - d2 *= d4; - d1 *= 0.05000000074505806D; - d2 *= 0.05000000074505806D; - d1 *= 1.0F - U; - d2 *= 1.0F - U; - f(-d1, 0.0D, -d2); - entity.f(d1, 0.0D, d2); + if (entity.passenger != this && entity.vehicle != this) { + double d0 = entity.locX - this.locX; + double d1 = entity.locZ - this.locZ; + double d2 = MathHelper.a(d0, d1); + + if (d2 >= 0.009999999776482582D) { + d2 = (double) MathHelper.a(d2); + d0 /= d2; + d1 /= d2; + double d3 = 1.0D / d2; + + if (d3 > 1.0D) { + d3 = 1.0D; + } + + d0 *= d3; + d1 *= d3; + d0 *= 0.05000000074505806D; + d1 *= 0.05000000074505806D; + d0 *= (double) (1.0F - this.U); + d1 *= (double) (1.0F - this.U); + this.f(-d0, 0.0D, -d1); + entity.f(d0, 0.0D, d1); + } } } - public void f(double d1, double d2, double d3) { - s += d1; - t += d2; - u += d3; + public void f(double d0, double d1, double d2) { + this.motX += d0; + this.motY += d1; + this.motZ += d2; } protected void y() { - E = true; + this.E = true; } - public boolean a(Entity entity, int i1) { - y(); + public boolean a(Entity entity, int i) { + this.y(); return false; } @@ -730,35 +764,29 @@ public abstract class Entity { return false; } - public void b(Entity entity, int i1) {} + public void b(Entity entity, int i) {} public boolean c(NBTTagCompound nbttagcompound) { - String s1 = A(); + String s = this.A(); - if (G || s1 == null) { - return false; - } else { - nbttagcompound.a("id", s1); - d(nbttagcompound); + if (!this.dead && s != null) { + nbttagcompound.a("id", s); + this.d(nbttagcompound); return true; + } else { + return false; } } public void d(NBTTagCompound nbttagcompound) { - nbttagcompound.a("Pos", ((NBTBase) (a(new double[] { - p, q, r - })))); - nbttagcompound.a("Motion", ((NBTBase) (a(new double[] { - s, t, u - })))); - nbttagcompound.a("Rotation", ((NBTBase) (a(new float[] { - v, w - })))); - nbttagcompound.a("FallDistance", N); - nbttagcompound.a("Fire", (short) Z); - nbttagcompound.a("Air", (short) ad); - nbttagcompound.a("OnGround", A); - a(nbttagcompound); + nbttagcompound.a("Pos", (NBTBase) this.a(new double[] { this.locX, this.locY, this.locZ})); + nbttagcompound.a("Motion", (NBTBase) this.a(new double[] { this.motX, this.motY, this.motZ})); + nbttagcompound.a("Rotation", (NBTBase) this.a(new float[] { this.yaw, this.pitch})); + nbttagcompound.a("FallDistance", this.fallDistance); + nbttagcompound.a("Fire", (short) this.fireTicks); + nbttagcompound.a("Air", (short) this.airTicks); + nbttagcompound.a("OnGround", this.onGround); + this.a(nbttagcompound); } public void e(NBTTagCompound nbttagcompound) { @@ -766,88 +794,88 @@ public abstract class Entity { NBTTagList nbttaglist1 = nbttagcompound.k("Motion"); NBTTagList nbttaglist2 = nbttagcompound.k("Rotation"); - a(0.0D, 0.0D, 0.0D); - s = ((NBTTagDouble) nbttaglist1.a(0)).a; - t = ((NBTTagDouble) nbttaglist1.a(1)).a; - u = ((NBTTagDouble) nbttaglist1.a(2)).a; - m = O = p = ((NBTTagDouble) nbttaglist.a(0)).a; - n = P = q = ((NBTTagDouble) nbttaglist.a(1)).a; - o = Q = r = ((NBTTagDouble) nbttaglist.a(2)).a; - x = v = ((NBTTagFloat) nbttaglist2.a(0)).a; - y = w = ((NBTTagFloat) nbttaglist2.a(1)).a; - N = nbttagcompound.f("FallDistance"); - Z = ((int) (nbttagcompound.c("Fire"))); - ad = ((int) (nbttagcompound.c("Air"))); - A = nbttagcompound.l("OnGround"); - a(p, q, r); - b(nbttagcompound); + this.a(0.0D, 0.0D, 0.0D); + this.motX = ((NBTTagDouble) nbttaglist1.a(0)).a; + this.motY = ((NBTTagDouble) nbttaglist1.a(1)).a; + this.motZ = ((NBTTagDouble) nbttaglist1.a(2)).a; + this.lastX = this.O = this.locX = ((NBTTagDouble) nbttaglist.a(0)).a; + this.lastY = this.P = this.locY = ((NBTTagDouble) nbttaglist.a(1)).a; + this.lastZ = this.Q = this.locZ = ((NBTTagDouble) nbttaglist.a(2)).a; + this.lastYaw = this.yaw = ((NBTTagFloat) nbttaglist2.a(0)).a; + this.lastPitch = this.pitch = ((NBTTagFloat) nbttaglist2.a(1)).a; + this.fallDistance = nbttagcompound.f("FallDistance"); + this.fireTicks = nbttagcompound.c("Fire"); + this.airTicks = nbttagcompound.c("Air"); + this.onGround = nbttagcompound.l("OnGround"); + this.a(this.locX, this.locY, this.locZ); + this.b(nbttagcompound); } protected final String A() { - return EntityList.b(this); + return EntityTypes.b(this); } protected abstract void b(NBTTagCompound nbttagcompound); protected abstract void a(NBTTagCompound nbttagcompound); - protected NBTTagList a(double ad1[]) { + protected NBTTagList a(double... adouble) { NBTTagList nbttaglist = new NBTTagList(); - double ad2[] = ad1; - int i1 = ad2.length; + double[] adouble1 = adouble; + int i = adouble.length; - for (int j1 = 0; j1 < i1; j1++) { - double d1 = ad2[j1]; + for (int j = 0; j < i; ++j) { + double d0 = adouble1[j]; - nbttaglist.a(((NBTBase) (new NBTTagDouble(d1)))); + nbttaglist.a((NBTBase) (new NBTTagDouble(d0))); } return nbttaglist; } - protected NBTTagList a(float af1[]) { + protected NBTTagList a(float... afloat) { NBTTagList nbttaglist = new NBTTagList(); - float af2[] = af1; - int i1 = af2.length; + float[] afloat1 = afloat; + int i = afloat.length; - for (int j1 = 0; j1 < i1; j1++) { - float f1 = af2[j1]; + for (int j = 0; j < i; ++j) { + float f = afloat1[j]; - nbttaglist.a(((NBTBase) (new NBTTagFloat(f1)))); + nbttaglist.a((NBTBase) (new NBTTagFloat(f))); } return nbttaglist; } - public EntityItem a(int i1, int j1) { - return a(i1, j1, 0.0F); + public EntityItem a(int i, int j) { + return this.a(i, j, 0.0F); } - public EntityItem a(int i1, int j1, float f1) { - return a(new ItemStack(i1, j1, 0), f1); + public EntityItem a(int i, int j, float f) { + return this.a(new ItemStack(i, j, 0), f); } - public EntityItem a(ItemStack itemstack, float f1) { - EntityItem entityitem = new EntityItem(l, p, q + (double) f1, r, itemstack); + public EntityItem a(ItemStack itemstack, float f) { + EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); entityitem.c = 10; - l.a(((Entity) (entityitem))); + this.world.a((Entity) entityitem); return entityitem; } public boolean B() { - return !G; + return !this.dead; } public boolean C() { - int i1 = MathHelper.b(p); - int j1 = MathHelper.b(q + (double) w()); - int k1 = MathHelper.b(r); + int i = MathHelper.b(this.locX); + int j = MathHelper.b(this.locY + (double) this.w()); + int k = MathHelper.b(this.locZ); - return l.d(i1, j1, k1); + return this.world.d(i, j, k); } - public boolean a(EntityPlayer entityplayer) { + public boolean a(EntityHuman entityhuman) { return false; } @@ -856,61 +884,69 @@ public abstract class Entity { } public void D() { - if (k.G) { - k = null; - return; - } - s = 0.0D; - t = 0.0D; - u = 0.0D; - b_(); - k.E(); - e += k.v - k.x; - d += k.w - k.y; - for (; e >= 180D; e -= 360D) { - ; - } - for (; e < -180D; e += 360D) { - ; - } - for (; d >= 180D; d -= 360D) { - ; - } - for (; d < -180D; d += 360D) { - ; - } - double d1 = e * 0.5D; - double d2 = d * 0.5D; - float f1 = 10F; + if (this.vehicle.dead) { + this.vehicle = null; + } else { + this.motX = 0.0D; + this.motY = 0.0D; + this.motZ = 0.0D; + this.b_(); + this.vehicle.E(); + this.e += (double) (this.vehicle.yaw - this.vehicle.lastYaw); + + for (this.d += (double) (this.vehicle.pitch - this.vehicle.lastPitch); this.e >= 180.0D; this.e -= 360.0D) { + ; + } - if (d1 > (double) f1) { - d1 = f1; - } - if (d1 < (double) (-f1)) { - d1 = -f1; - } - if (d2 > (double) f1) { - d2 = f1; - } - if (d2 < (double) (-f1)) { - d2 = -f1; + while (this.e < -180.0D) { + this.e += 360.0D; + } + + while (this.d >= 180.0D) { + this.d -= 360.0D; + } + + while (this.d < -180.0D) { + this.d += 360.0D; + } + + double d0 = this.e * 0.5D; + double d1 = this.d * 0.5D; + float f = 10.0F; + + if (d0 > (double) f) { + d0 = (double) f; + } + + if (d0 < (double) (-f)) { + d0 = (double) (-f); + } + + if (d1 > (double) f) { + d1 = (double) f; + } + + if (d1 < (double) (-f)) { + d1 = (double) (-f); + } + + this.e -= d0; + this.d -= d1; + this.yaw = (float) ((double) this.yaw + d0); + this.pitch = (float) ((double) this.pitch + d1); } - e -= d1; - d -= d2; - v += ((float) (d1)); - w += ((float) (d2)); } public void E() { - j.a(p, q + k() + j.F(), r); + this.passenger.a(this.locX, this.locY + this.k() + this.passenger.F(), this.locZ); } public double F() { - return (double) H; + return (double) this.height; } public double k() { - return (double) J * 0.75D; + return (double) this.width * 0.75D; } public void e(Entity entity) { @@ -918,36 +954,40 @@ public abstract class Entity { setPassengerOf(entity); } + public org.bukkit.entity.Entity getBukkitEntity(){ + return this.bukkitEntity; + } + public void setPassengerOf(Entity entity) { // e(null) doesn't really fly for overloaded methods, // so this method is needed // CraftBukkit end - - d = 0.0D; - e = 0.0D; + this.d = 0.0D; + this.e = 0.0D; if (entity == null) { - if (k != null) { - c(k.p, k.z.b + (double) k.J, k.r, v, w); - k.j = null; + if (this.vehicle != null) { + this.c(this.vehicle.locX, this.vehicle.boundingBox.b + (double) this.vehicle.width, this.vehicle.locZ, this.yaw, this.pitch); + this.vehicle.passenger = null; } - k = null; - return; - } - if (k == entity) { - k.j = null; - k = null; - c(entity.p, entity.z.b + (double) entity.J, entity.r, v, w); - return; - } - if (k != null) { - k.j = null; - } - if (entity.j != null) { - entity.j.k = null; + + this.vehicle = null; + } else if (this.vehicle == entity) { + this.vehicle.passenger = null; + this.vehicle = null; + this.c(entity.locX, entity.boundingBox.b + (double) entity.width, entity.locZ, this.yaw, this.pitch); + } else { + if (this.vehicle != null) { + this.vehicle.passenger = null; + } + + if (entity.passenger != null) { + entity.passenger.vehicle = null; + } + + this.vehicle = entity; + entity.passenger = this; } - k = entity; - entity.j = this; } public Vec3D G() { @@ -961,30 +1001,24 @@ public abstract class Entity { } public boolean J() { - return c(1); + return this.c(1); } public void b(boolean flag) { - a(1, flag); + this.a(1, flag); } - protected boolean c(int i1) { - return (af.a(0) & 1 << i1) != 0; + protected boolean c(int i) { + return (this.datawatcher.a(0) & 1 << i) != 0; } - protected void a(int i1, boolean flag) { - byte byte0 = af.a(0); + protected void a(int i, boolean flag) { + byte b0 = this.datawatcher.a(0); if (flag) { - af.b(0, ((Byte.valueOf((byte) (byte0 | 1 << i1))))); + this.datawatcher.b(0, Byte.valueOf((byte) (b0 | 1 << i))); } else { - af.b(0, ((Byte.valueOf((byte) (byte0 & ~(1 << i1)))))); + this.datawatcher.b(0, Byte.valueOf((byte) (b0 & ~(1 << i)))); } } - - // CraftBukkit start - public org.bukkit.entity.Entity getBukkitEntity(){ - return this.bukkitEntity; - } - // CraftBukkit end } |