diff options
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityCreature.java')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityCreature.java | 219 |
1 files changed, 112 insertions, 107 deletions
diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java index 98afd9cd..26c8c7e9 100644 --- a/src/main/java/net/minecraft/server/EntityCreature.java +++ b/src/main/java/net/minecraft/server/EntityCreature.java @@ -1,11 +1,12 @@ package net.minecraft.server; -import java.util.Random; - // CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftMonster; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.entity.CraftCreature; import org.bukkit.craftbukkit.entity.CraftEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent.TargetReason; // CraftBukkit end @@ -14,155 +15,159 @@ public class EntityCreature extends EntityLiving { private PathEntity a; protected Entity d; - protected boolean e; + protected boolean e = false; public EntityCreature(World world) { super(world); - e = false; - // CraftBukkit start - CraftServer server = ((WorldServer) this.l).getServer(); - this.bukkitEntity = new CraftCreature(server, this); - // CraftBukkit end } protected void d() { - e = false; - float f = 16F; + this.e = false; + float f = 16.0F; - if (d == null) { + if (this.d == null) { // CraftBukkit start - Entity target = l(); - if(target != null) { + Entity target = this.l(); + if (target != null) { EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), TargetReason.CLOSEST_PLAYER); - CraftServer server = ((WorldServer) this.l).getServer(); + CraftServer server = ((WorldServer) this.world).getServer(); server.getPluginManager().callEvent(event); - if(!event.isCancelled()) { - if(event.getTarget() == null) { - d = null; + if (!event.isCancelled()) { + if (event.getTarget() == null) { + this.d = null; } else { - d = ((CraftEntity) event.getTarget()).getHandle(); + this.d = ((CraftEntity) event.getTarget()).getHandle(); } } } // CraftBukkit end - if (d != null) { - a = l.a(((Entity) (this)), d, f); + if (this.d != null) { + this.a = this.world.a(this, this.d, f); } - } else if (!d.B()) { + } else if (!this.d.B()) { // CraftBukkit start EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, TargetReason.TARGET_DIED); - CraftServer server = ((WorldServer) this.l).getServer(); + CraftServer server = ((WorldServer) this.world).getServer(); server.getPluginManager().callEvent(event); - if(!event.isCancelled()) { - if(event.getTarget() == null) { - d = null; + if (!event.isCancelled()) { + if (event.getTarget() == null) { + this.d = null; } else { - d = ((CraftEntity) event.getTarget()).getHandle(); + this.d = ((CraftEntity) event.getTarget()).getHandle(); } } // CraftBukkit end } else { - float f1 = d.a(((Entity) (this))); + float f1 = this.d.a((Entity) this); - if (i(d)) { - a(d, f1); + if (this.i(this.d)) { + this.a(this.d, f1); } } - if (!e && d != null && (a == null || W.nextInt(20) == 0)) { - a = l.a(((Entity) (this)), d, f); - } else if (a == null && W.nextInt(80) == 0 || W.nextInt(80) == 0) { + + if (!this.e && this.d != null && (this.a == null || this.random.nextInt(20) == 0)) { + this.a = this.world.a(this, this.d, f); + } else if (this.a == null && this.random.nextInt(80) == 0 || this.random.nextInt(80) == 0) { boolean flag = false; + int i = -1; int j = -1; int k = -1; - int i1 = -1; - float f2 = -99999F; + float f2 = -99999.0F; - for (int j1 = 0; j1 < 10; j1++) { - int k1 = MathHelper.b((p + (double) W.nextInt(13)) - 6D); - int l1 = MathHelper.b((q + (double) W.nextInt(7)) - 3D); - int i2 = MathHelper.b((r + (double) W.nextInt(13)) - 6D); - float f3 = a(k1, l1, i2); + for (int l = 0; l < 10; ++l) { + int i1 = MathHelper.b(this.locX + (double) this.random.nextInt(13) - 6.0D); + int j1 = MathHelper.b(this.locY + (double) this.random.nextInt(7) - 3.0D); + int k1 = MathHelper.b(this.locZ + (double) this.random.nextInt(13) - 6.0D); + float f3 = this.a(i1, j1, k1); if (f3 > f2) { f2 = f3; - j = k1; - k = l1; - i1 = i2; + i = i1; + j = j1; + k = k1; flag = true; } } if (flag) { - a = l.a(((Entity) (this)), j, k, i1, 10F); + this.a = this.world.a(this, i, j, k, 10.0F); } } - int i = MathHelper.b(z.b); - boolean flag1 = v(); - boolean flag2 = x(); - w = 0.0F; - if (a == null || W.nextInt(100) == 0) { - super.d(); - a = null; - return; - } - Vec3D vec3d = a.a(((Entity) (this))); - - for (double d1 = I * 2.0F; vec3d != null && vec3d.d(p, vec3d.b, r) < d1 * d1;) { - a.a(); - if (a.b()) { - vec3d = null; - a = null; - } else { - vec3d = a.a(((Entity) (this))); - } - } + int l1 = MathHelper.b(this.boundingBox.b); + boolean flag1 = this.v(); + boolean flag2 = this.x(); - bA = false; - if (vec3d != null) { - double d2 = vec3d.a - p; - double d3 = vec3d.c - r; - double d4 = vec3d.b - (double) i; - float f4 = (float) ((Math.atan2(d3, d2) * 180D) / 3.1415927410125732D) - 90F; - float f5 = f4 - v; - - by = bC; - for (; f5 < -180F; f5 += 360F) { - ; - } - for (; f5 >= 180F; f5 -= 360F) { - ; - } - if (f5 > 30F) { - f5 = 30F; + this.pitch = 0.0F; + if (this.a != null && this.random.nextInt(100) != 0) { + Vec3D vec3d = this.a.a(this); + double d0 = (double) (this.length * 2.0F); + + while (vec3d != null && vec3d.d(this.locX, vec3d.b, this.locZ) < d0 * d0) { + this.a.a(); + if (this.a.b()) { + vec3d = null; + this.a = null; + } else { + vec3d = this.a.a(this); + } } - if (f5 < -30F) { - f5 = -30F; + + this.bA = false; + if (vec3d != null) { + double d1 = vec3d.a - this.locX; + double d2 = vec3d.c - this.locZ; + double d3 = vec3d.b - (double) l1; + float f4 = (float) (Math.atan2(d2, d1) * 180.0D / 3.1415927410125732D) - 90.0F; + float f5 = f4 - this.yaw; + + for (this.by = this.bC; f5 < -180.0F; f5 += 360.0F) { + ; + } + + while (f5 >= 180.0F) { + f5 -= 360.0F; + } + + if (f5 > 30.0F) { + f5 = 30.0F; + } + + if (f5 < -30.0F) { + f5 = -30.0F; + } + + this.yaw += f5; + if (this.e && this.d != null) { + double d4 = this.d.locX - this.locX; + double d5 = this.d.locZ - this.locZ; + float f6 = this.yaw; + + this.yaw = (float) (Math.atan2(d5, d4) * 180.0D / 3.1415927410125732D) - 90.0F; + f5 = (f6 - this.yaw + 90.0F) * 3.1415927F / 180.0F; + this.bx = -MathHelper.a(f5) * this.by * 1.0F; + this.by = MathHelper.b(f5) * this.by * 1.0F; + } + + if (d3 > 0.0D) { + this.bA = true; + } } - v += f5; - if (e && d != null) { - double d5 = d.p - p; - double d6 = d.r - r; - float f7 = v; - v = (float) ((Math.atan2(d6, d5) * 180D) / 3.1415927410125732D) - 90F; - float f6 = (((f7 - v) + 90F) * 3.141593F) / 180F; + if (this.d != null) { + this.b(this.d, 30.0F); + } - bx = -MathHelper.a(f6) * by * 1.0F; - by = MathHelper.b(f6) * by * 1.0F; + if (this.B) { + this.bA = true; } - if (d4 > 0.0D) { - bA = true; + + if (this.random.nextFloat() < 0.8F && (flag1 || flag2)) { + this.bA = true; } - } - if (d != null) { - b(d, 30F); - } - if (B) { - bA = true; - } - if (W.nextFloat() < 0.8F && (flag1 || flag2)) { - bA = true; + } else { + super.d(); + this.a = null; } } @@ -177,10 +182,10 @@ public class EntityCreature extends EntityLiving { } public boolean b() { - int i = MathHelper.b(p); - int j = MathHelper.b(z.b); - int k = MathHelper.b(r); + int i = MathHelper.b(this.locX); + int j = MathHelper.b(this.boundingBox.b); + int k = MathHelper.b(this.locZ); - return super.b() && a(i, j, k) >= 0.0F; + return super.b() && this.a(i, j, k) >= 0.0F; } } |