diff options
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityBoat.java')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityBoat.java | 521 |
1 files changed, 268 insertions, 253 deletions
diff --git a/src/main/java/net/minecraft/server/EntityBoat.java b/src/main/java/net/minecraft/server/EntityBoat.java index 0e929470..7511397a 100644 --- a/src/main/java/net/minecraft/server/EntityBoat.java +++ b/src/main/java/net/minecraft/server/EntityBoat.java @@ -1,7 +1,6 @@ package net.minecraft.server; import java.util.List; -import java.util.Random; // CraftBukkit start import org.bukkit.Location; @@ -19,7 +18,7 @@ import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; import org.bukkit.event.vehicle.VehicleMoveEvent; // CraftBukkit end -public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit +public class EntityBoat extends Entity { public int a; public int b; @@ -32,27 +31,44 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit private double am; // CraftBukkit start - /**@deprecated*/ - private CraftBoat boat; - /**@deprecated*/ - public CraftEntity getCraftEntity() { - return boat; + private void handleCreation(World world) { + CraftServer server = ((WorldServer) world).getServer(); + Type eventType = Type.VEHICLE_CREATE; + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + VehicleCreateEvent event = new VehicleCreateEvent(eventType, vehicle); + server.getPluginManager().callEvent(event); + } + + public void c(Entity entity) { + CraftServer server = ((WorldServer) this.world).getServer(); + Type eventType = Type.VEHICLE_COLLISION_ENTITY; + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity(); + + VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent(eventType, vehicle, hitEntity); + server.getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + + super.c(entity); } // CraftBukkit end public EntityBoat(World world) { super(world); - a = 0; - b = 0; - c = 1; - i = true; - a(1.5F, 0.6F); - H = J / 2.0F; - M = false; + this.a = 0; + this.b = 0; + this.c = 1; + this.i = true; + this.a(1.5F, 0.6F); + this.height = this.width / 2.0F; + this.M = false; - handleCreation(world); // CraftBukkit // CraftBukkit start - CraftServer server = ((WorldServer) this.l).getServer(); + handleCreation(world); + CraftServer server = ((WorldServer) this.world).getServer(); this.bukkitEntity = new CraftBoat(server, this); // CraftBukkit end } @@ -60,325 +76,324 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit protected void a() {} public AxisAlignedBB d(Entity entity) { - return entity.z; + return entity.boundingBox; } public AxisAlignedBB u() { - return z; + return this.boundingBox; } public boolean z() { return true; } - public EntityBoat(World world, double d1, double d2, double d3) { + public EntityBoat(World world, double d0, double d1, double d2) { this(world); - a(d1, d2 + (double) H, d3); - s = 0.0D; - t = 0.0D; - u = 0.0D; - m = d1; - n = d2; - o = d3; + this.a(d0, d1 + (double) this.height, d2); + this.motX = 0.0D; + this.motY = 0.0D; + this.motZ = 0.0D; + this.lastX = d0; + this.lastY = d1; + this.lastZ = d2; handleCreation(world); // CraftBukkit } - // CraftBukkit start - private void handleCreation(World world) { - CraftServer server = ((WorldServer) world).getServer(); - Type eventType = Type.VEHICLE_CREATE; - Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - VehicleCreateEvent event = new VehicleCreateEvent(eventType, vehicle); - server.getPluginManager().callEvent(event); - } - // CraftBukkit end - public double k() { - return (double) J * 0.0D - 0.30000001192092896D; + return (double) this.width * 0.0D - 0.30000001192092896D; } public boolean a(Entity entity, int i) { - // CraftBukkit start - Type eventType = Type.VEHICLE_DAMAGE; - Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - org.bukkit.entity.Entity attacker = (entity == null)?null:entity.getBukkitEntity(); - int damage = i; - - VehicleDamageEvent event = new VehicleDamageEvent(eventType, vehicle, attacker, damage); - ((WorldServer) l).getServer().getPluginManager().callEvent(event); + if (!this.world.isStatic && !this.dead) { + // CraftBukkit start + Type eventType = Type.VEHICLE_DAMAGE; + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + org.bukkit.entity.Entity attacker = (entity == null) ? null : entity.getBukkitEntity(); + int damage = i; - if (event.isCancelled()) { - return true; - } - // CraftBukkit end + VehicleDamageEvent event = new VehicleDamageEvent(eventType, vehicle, attacker, damage); + ((WorldServer) this.world).getServer().getPluginManager().callEvent(event); - if (this.l.z || G) { - return true; - } - c = -c; - b = 10; - a += i * 10; - y(); - if (a > 40) { - for (int j = 0; j < 3; j++) { - a(Block.x.bi, 1, 0.0F); + if (event.isCancelled()) { + return true; } + // CraftBukkit end + + this.c = -this.c; + this.b = 10; + this.a += i * 10; + this.y(); + if (this.a > 40) { + int j; - for (int l = 0; l < 2; l++) { - a(Item.B.ba, 1, 0.0F); + for (j = 0; j < 3; ++j) { + this.a(Block.WOOD.id, 1, 0.0F); + } + + for (j = 0; j < 2; ++j) { + this.a(Item.STICK.id, 1, 0.0F); + } + + this.q(); } - q(); + return true; + } else { + return true; } - return true; } public boolean c_() { - return !G; + return !this.dead; } public void b_() { // CraftBukkit start - double prevX = p; - double prevY = q; - double prevZ = r; - float prevYaw = v; - float prevPitch = w; + double prevX = this.locX; + double prevY = this.locY; + double prevZ = this.locZ; + float prevYaw = this.yaw; + float prevPitch = this.pitch; // CraftBukkit end super.b_(); - if (b > 0) { - b--; + if (this.b > 0) { + --this.b; } - if (a > 0) { - a--; + + if (this.a > 0) { + --this.a; } - m = p; - n = q; - o = r; - int i = 5; - double d1 = 0.0D; - - for (int j = 0; j < i; j++) { - double d2 = (z.b + ((z.e - z.b) * (double) (j + 0)) / (double) i) - 0.125D; - double d3 = (z.b + ((z.e - z.b) * (double) (j + 1)) / (double) i) - 0.125D; - AxisAlignedBB axisalignedbb = AxisAlignedBB.b(z.a, d2, z.c, z.d, d3, z.f); - - if (this.l.b(axisalignedbb, Material.f)) { - d1 += 1.0D / (double) i; + + this.lastX = this.locX; + this.lastY = this.locY; + this.lastZ = this.locZ; + byte b0 = 5; + double d0 = 0.0D; + + for (int i = 0; i < b0; ++i) { + double d1 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (i + 0) / (double) b0 - 0.125D; + double d2 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (i + 1) / (double) b0 - 0.125D; + AxisAlignedBB axisalignedbb = AxisAlignedBB.b(this.boundingBox.a, d1, this.boundingBox.c, this.boundingBox.d, d2, this.boundingBox.f); + + if (this.world.b(axisalignedbb, Material.WATER)) { + d0 += 1.0D / (double) b0; } } - if (this.l.z) { - if (d > 0) { - double d4 = p + (e - p) / (double) d; - double d7 = q + (f - q) / (double) d; - double d10 = r + (ak - r) / (double) d; - double d13; + double d3; + double d4; + double d5; + double d6; - for (d13 = al - (double) v; d13 < -180D; d13 += 360D) { + if (this.world.isStatic) { + if (this.d > 0) { + d3 = this.locX + (this.e - this.locX) / (double) this.d; + d4 = this.locY + (this.f - this.locY) / (double) this.d; + d5 = this.locZ + (this.ak - this.locZ) / (double) this.d; + + for (d6 = this.al - (double) this.yaw; d6 < -180.0D; d6 += 360.0D) { ; } - for (; d13 >= 180D; d13 -= 360D) { - ; + + while (d6 >= 180.0D) { + d6 -= 360.0D; } - v += ((float) (d13 / (double) d)); - w += ((float) ((am - (double) w) / (double) d)); - d--; - a(d4, d7, d10); - b(v, w); + + this.yaw = (float) ((double) this.yaw + d6 / (double) this.d); + this.pitch = (float) ((double) this.pitch + (this.am - (double) this.pitch) / (double) this.d); + --this.d; + this.a(d3, d4, d5); + this.b(this.yaw, this.pitch); } else { - double d5 = p + s; - double d8 = q + t; - double d11 = r + u; - - a(d5, d8, d11); - if (A) { - s *= 0.5D; - t *= 0.5D; - u *= 0.5D; + d3 = this.locX + this.motX; + d4 = this.locY + this.motY; + d5 = this.locZ + this.motZ; + this.a(d3, d4, d5); + if (this.onGround) { + this.motX *= 0.5D; + this.motY *= 0.5D; + this.motZ *= 0.5D; } - s *= 0.99000000953674316D; - t *= 0.94999998807907104D; - u *= 0.99000000953674316D; - } - return; - } - double d6 = d1 * 2D - 1.0D; - t += 0.039999999105930328D * d6; - if (this.j != null) { - s += this.j.s * 0.20000000000000001D; - u += this.j.u * 0.20000000000000001D; - } - double d9 = 0.40000000000000002D; + this.motX *= 0.9900000095367432D; + this.motY *= 0.949999988079071D; + this.motZ *= 0.9900000095367432D; + } + } else { + d3 = d0 * 2.0D - 1.0D; + this.motY += 0.03999999910593033D * d3; + if (this.passenger != null) { + this.motX += this.passenger.motX * 0.2D; + this.motZ += this.passenger.motZ * 0.2D; + } - if (s < -d9) { - s = -d9; - } - if (s > d9) { - s = d9; - } - if (u < -d9) { - u = -d9; - } - if (u > d9) { - u = d9; - } - if (A) { - s *= 0.5D; - t *= 0.5D; - u *= 0.5D; - } - c(s, t, u); - double d12 = Math.sqrt(s * s + u * u); + d4 = 0.4D; + if (this.motX < -d4) { + this.motX = -d4; + } - if (d12 > 0.14999999999999999D) { - double d14 = Math.cos(((double) v * 3.1415926535897931D) / 180D); - double d16 = Math.sin(((double) v * 3.1415926535897931D) / 180D); + if (this.motX > d4) { + this.motX = d4; + } - for (int l = 0; (double) l < 1.0D + d12 * 60D; l++) { - double d18 = W.nextFloat() * 2.0F - 1.0F; - double d19 = (double) (W.nextInt(2) * 2 - 1) * 0.69999999999999996D; + if (this.motZ < -d4) { + this.motZ = -d4; + } - if (W.nextBoolean()) { - double d20 = (p - d14 * d18 * 0.80000000000000004D) + d16 * d19; - double d22 = r - d16 * d18 * 0.80000000000000004D - d14 * d19; + if (this.motZ > d4) { + this.motZ = d4; + } - this.l.a("splash", d20, q - 0.125D, d22, s, t, u); - } else { - double d21 = p + d14 + d16 * d18 * 0.69999999999999996D; - double d23 = (r + d16) - d14 * d18 * 0.69999999999999996D; + if (this.onGround) { + this.motX *= 0.5D; + this.motY *= 0.5D; + this.motZ *= 0.5D; + } - this.l.a("splash", d21, q - 0.125D, d23, s, t, u); + this.c(this.motX, this.motY, this.motZ); + d5 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); + double d7; + + if (d5 > 0.15D) { + d6 = Math.cos((double) this.yaw * 3.141592653589793D / 180.0D); + d7 = Math.sin((double) this.yaw * 3.141592653589793D / 180.0D); + + for (int j = 0; (double) j < 1.0D + d5 * 60.0D; ++j) { + double d8 = (double) (this.random.nextFloat() * 2.0F - 1.0F); + double d9 = (double) (this.random.nextInt(2) * 2 - 1) * 0.7D; + double d10; + double d11; + + if (this.random.nextBoolean()) { + d10 = this.locX - d6 * d8 * 0.8D + d7 * d9; + d11 = this.locZ - d7 * d8 * 0.8D - d6 * d9; + this.world.a("splash", d10, this.locY - 0.125D, d11, this.motX, this.motY, this.motZ); + } else { + d10 = this.locX + d6 + d7 * d8 * 0.7D; + d11 = this.locZ + d7 - d6 * d8 * 0.7D; + this.world.a("splash", d10, this.locY - 0.125D, d11, this.motX, this.motY, this.motZ); + } } } - } - if (B && d12 > 0.14999999999999999D) { - if (!this.l.z) { - q(); - for (int i1 = 0; i1 < 3; i1++) { - a(Block.x.bi, 1, 0.0F); - } - for (int j1 = 0; j1 < 2; j1++) { - a(Item.B.ba, 1, 0.0F); + if (this.B && d5 > 0.15D) { + if (!this.world.isStatic) { + this.q(); + + int k; + + for (k = 0; k < 3; ++k) { + this.a(Block.WOOD.id, 1, 0.0F); + } + + for (k = 0; k < 2; ++k) { + this.a(Item.STICK.id, 1, 0.0F); + } } + } else { + this.motX *= 0.9900000095367432D; + this.motY *= 0.949999988079071D; + this.motZ *= 0.9900000095367432D; } - } else { - s *= 0.99000000953674316D; - t *= 0.94999998807907104D; - u *= 0.99000000953674316D; - } - w = 0.0F; - double d15 = v; - double d17 = m - p; - double d24 = o - r; - if (d17 * d17 + d24 * d24 > 0.001D) { - d15 = (float) ((Math.atan2(d24, d17) * 180D) / 3.1415926535897931D); - } - double d25; + this.pitch = 0.0F; + d6 = (double) this.yaw; + d7 = this.lastX - this.locX; + double d12 = this.lastZ - this.locZ; - for (d25 = d15 - (double) v; d25 >= 180D; d25 -= 360D) { - ; - } - for (; d25 < -180D; d25 += 360D) { - ; - } - if (d25 > 20D) { - d25 = 20D; - } - if (d25 < -20D) { - d25 = -20D; - } - v += ((float) (d25)); - b(v, w); + if (d7 * d7 + d12 * d12 > 0.0010D) { + d6 = (double) ((float) (Math.atan2(d12, d7) * 180.0D / 3.141592653589793D)); + } - // CraftBukkit start - CraftServer server = ((WorldServer)l).getServer(); - CraftWorld world = ((WorldServer)l).getWorld(); - Type eventType = Type.VEHICLE_MOVE; - Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - Location from = new Location(world, prevX, prevY, prevZ, prevYaw, prevPitch); - Location to = new Location(world, p, q, r, v, w); - - VehicleMoveEvent event = new VehicleMoveEvent(eventType, vehicle, from, to); - server.getPluginManager().callEvent(event); - // CraftBukkit end + double d13; - List list = this.l.b(((Entity) (this)), z.b(0.20000000298023224D, 0.0D, 0.20000000298023224D)); + for (d13 = d6 - (double) this.yaw; d13 >= 180.0D; d13 -= 360.0D) { + ; + } - if (list != null && list.size() > 0) { - for (int k1 = 0; k1 < list.size(); k1++) { - Entity entity = (Entity) list.get(k1); + while (d13 < -180.0D) { + d13 += 360.0D; + } - if (entity != this.j && entity.z() && (entity instanceof EntityBoat)) { - entity.c(((Entity) (this))); - } + if (d13 > 20.0D) { + d13 = 20.0D; } - } - if (this.j != null && this.j.G) { - this.j = null; - } - } - public void E() { - if (j == null) { - return; - } else { - double d1 = Math.cos(((double) v * 3.1415926535897931D) / 180D) * 0.40000000000000002D; - double d2 = Math.sin(((double) v * 3.1415926535897931D) / 180D) * 0.40000000000000002D; + if (d13 < -20.0D) { + d13 = -20.0D; + } - j.a(p + d1, q + k() + j.F(), r + d2); - return; + this.yaw = (float) ((double) this.yaw + d13); + this.b(this.yaw, this.pitch); + + // CraftBukkit start + CraftServer server = ((WorldServer) this.world).getServer(); + CraftWorld world = ((WorldServer) this.world).getWorld(); + Type eventType = Type.VEHICLE_MOVE; + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + Location from = new Location(world, prevX, prevY, prevZ, prevYaw, prevPitch); + Location to = new Location(world, this.locX, this.locY, this.locZ, this.yaw, this.pitch); + + VehicleMoveEvent event = new VehicleMoveEvent(eventType, vehicle, from, to); + server.getPluginManager().callEvent(event); + // CraftBukkit end + + List list = this.world.b((Entity) this, this.boundingBox.b(0.20000000298023224D, 0.0D, 0.20000000298023224D)); + + if (list != null && list.size() > 0) { + for (int l = 0; l < list.size(); ++l) { + Entity entity = (Entity) list.get(l); + + if (entity != this.passenger && entity.z() && entity instanceof EntityBoat) { + entity.c((Entity) this); + } + } + } + + if (this.passenger != null && this.passenger.dead) { + this.passenger = null; + } } } - // CraftBukkit start - public void c(Entity entity) { - CraftServer server = ((WorldServer)l).getServer(); - Type eventType = Type.VEHICLE_COLLISION_ENTITY; - Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - org.bukkit.entity.Entity hitEntity = (entity == null)?null:entity.getBukkitEntity(); - - VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent(eventType, vehicle, hitEntity); - server.getPluginManager().callEvent(collsionEvent); + public void E() { + if (this.passenger != null) { + double d0 = Math.cos((double) this.yaw * 3.141592653589793D / 180.0D) * 0.4D; + double d1 = Math.sin((double) this.yaw * 3.141592653589793D / 180.0D) * 0.4D; - if (collsionEvent.isCancelled()) { - return; + this.passenger.a(this.locX + d0, this.locY + this.k() + this.passenger.F(), this.locZ + d1); } - - super.c(entity); } - // CraftBukkit end protected void a(NBTTagCompound nbttagcompound) {} protected void b(NBTTagCompound nbttagcompound) {} - public boolean a(EntityPlayer entityplayer) { - if (j != null && (j instanceof EntityPlayer) && j != entityplayer) { + public boolean a(EntityHuman entityhuman) { + if (this.passenger != null && this.passenger instanceof EntityHuman && this.passenger != entityhuman) { return true; - } - if (!l.z) { - // CraftBukkit start - CraftServer server = ((WorldServer)l).getServer(); - Type eventType = Type.VEHICLE_ENTER; - Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - org.bukkit.entity.Entity player = entityplayer.getBukkitEntity(); - - VehicleEnterEvent event = new VehicleEnterEvent(eventType, vehicle, player); - server.getPluginManager().callEvent(event); + } else { + if (!this.world.isStatic) { + // CraftBukkit start + CraftServer server = ((WorldServer) this.world).getServer(); + Type eventType = Type.VEHICLE_ENTER; + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + org.bukkit.entity.Entity player = entityhuman.getBukkitEntity(); + + VehicleEnterEvent event = new VehicleEnterEvent(eventType, vehicle, player); + server.getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return true; + } + // CraftBukkit end - if (event.isCancelled()) { - return true; + entityhuman.e(this); } - // CraftBukkit end - entityplayer.e(((Entity) (this))); + return true; } - return true; } } |