summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/EntityMinecart.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityMinecart.java')
-rw-r--r--src/main/java/net/minecraft/server/EntityMinecart.java1153
1 files changed, 548 insertions, 605 deletions
diff --git a/src/main/java/net/minecraft/server/EntityMinecart.java b/src/main/java/net/minecraft/server/EntityMinecart.java
index d28adc0f..c328fd8c 100644
--- a/src/main/java/net/minecraft/server/EntityMinecart.java
+++ b/src/main/java/net/minecraft/server/EntityMinecart.java
@@ -1,7 +1,6 @@
package net.minecraft.server;
import java.util.List;
-import java.util.Random;
// CraftBukkit start
import org.bukkit.Location;
@@ -17,9 +16,9 @@ import org.bukkit.event.Event.Type;
import org.bukkit.event.vehicle.*;
// CraftBukkit end
-public class EntityMinecart extends Entity implements IInventory, CraftMappable { // CraftBukkit
+public class EntityMinecart extends Entity implements IInventory {
- private ItemStack al[];
+ private ItemStack[] al;
public int a;
public int b;
public int c;
@@ -28,69 +27,7 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
public int e;
public double f;
public double ak;
- private static final int an[][][] = {
- {
- {
- 0, 0, -1
- }, {
- 0, 0, 1
- }
- }, {
- {
- -1, 0, 0
- }, {
- 1, 0, 0
- }
- }, {
- {
- -1, -1, 0
- }, {
- 1, 0, 0
- }
- }, {
- {
- -1, 0, 0
- }, {
- 1, -1, 0
- }
- }, {
- {
- 0, 0, -1
- }, {
- 0, -1, 1
- }
- }, {
- {
- 0, -1, -1
- }, {
- 0, 0, 1
- }
- }, {
- {
- 0, 0, 1
- }, {
- 1, 0, 0
- }
- }, {
- {
- 0, 0, 1
- }, {
- -1, 0, 0
- }
- }, {
- {
- 0, 0, -1
- }, {
- -1, 0, 0
- }
- }, {
- {
- 0, 0, -1
- }, {
- 1, 0, 0
- }
- }
- };
+ private static final int[][][] an = new int[][][] { { { 0, 0, -1}, { 0, 0, 1}}, { { -1, 0, 0}, { 1, 0, 0}}, { { -1, -1, 0}, { 1, 0, 0}}, { { -1, 0, 0}, { 1, -1, 0}}, { { 0, 0, -1}, { 0, -1, 1}}, { { 0, -1, -1}, { 0, 0, 1}}, { { 0, 0, 1}, { 1, 0, 0}}, { { 0, 0, 1}, { -1, 0, 0}}, { { 0, 0, -1}, { -1, 0, 0}}, { { 0, 0, -1}, { 1, 0, 0}}};
private int ao;
private double ap;
private double aq;
@@ -99,10 +36,8 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
private double at;
// CraftBukkit start
- protected org.bukkit.entity.Entity bukkitPoweredMinecart; //CraftBukkit
- protected org.bukkit.entity.Entity bukkitStorageMinecart; //CraftBukkit
- /**@deprecated*/
- private CraftMinecart minecart;
+ protected org.bukkit.entity.Entity bukkitPoweredMinecart;
+ protected org.bukkit.entity.Entity bukkitStorageMinecart;
private boolean slowWhenEmpty = true;
private double derailedX = 0.5;
@@ -111,30 +46,46 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
private double flyingX = 0.94999998807907104;
private double flyingY = 0.94999998807907104;
private double flyingZ = 0.94999998807907104;
- /**@deprecated*/
- public CraftEntity getCraftEntity() {
- return minecart;
- }
public ItemStack[] getContents() {
return this.al;
}
+
+ 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);
+ }
+
+ @Override
+ public org.bukkit.entity.Entity getBukkitEntity(){
+ if (this.d == CraftMinecart.Type.StorageMinecart.getId()) {
+ return this.bukkitStorageMinecart;
+ } else if (this.d == CraftMinecart.Type.PoweredMinecart.getId()) {
+ return this.bukkitPoweredMinecart;
+ } else {
+ return this.bukkitEntity;
+ }
+ }
// CraftBukkit end
public EntityMinecart(World world) {
super(world);
- al = new ItemStack[36];
- a = 0;
- b = 0;
- c = 1;
- am = false;
- i = true;
- a(0.98F, 0.7F);
- H = J / 2.0F;
- M = false;
+ this.al = new ItemStack[36];
+ this.a = 0;
+ this.b = 0;
+ this.c = 1;
+ this.am = false;
+ this.i = true;
+ this.a(0.98F, 0.7F);
+ this.height = this.width / 2.0F;
+ this.M = false;
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftMinecart(server, this);
this.bukkitPoweredMinecart = new CraftPoweredMinecart(server, this);
this.bukkitStorageMinecart = new CraftStorageMinecart(server, this);
@@ -145,7 +96,7 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
protected void a() {}
public AxisAlignedBB d(Entity entity) {
- return entity.z;
+ return entity.boundingBox;
}
public AxisAlignedBB u() {
@@ -156,102 +107,90 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
return true;
}
- public EntityMinecart(World world, double d1, double d2, double d3, int i) {
+ public EntityMinecart(World world, double d0, double d1, double d2, int i) {
this(world);
- a(d1, d2 + (double) H, d3);
- s = 0.0D;
- t = 0.0D;
- u = 0.0D;
- m = d1;
- n = d2;
- o = d3;
- d = i;
- }
-
- // 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);
+ 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;
+ this.d = i;
}
- // 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 passenger = (entity == null)?null:entity.getBukkitEntity();
- int damage = i;
-
- VehicleDamageEvent event = new VehicleDamageEvent(eventType, vehicle, passenger, 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 passenger = (entity == null) ? null : entity.getBukkitEntity();
+ int damage = i;
- if (event.isCancelled()) {
- return true;
- }
- i = event.getDamage();
- // CraftBukkit end
+ VehicleDamageEvent event = new VehicleDamageEvent(eventType, vehicle, passenger, damage);
+ ((WorldServer)this.world).getServer().getPluginManager().callEvent(event);
- if (l.z || G) {
- return true;
- }
- c = -c;
- b = 10;
- y();
- a += i * 10;
- if (a > 40) {
- a(Item.ax.ba, 1, 0.0F);
- if (d == 1) {
- a(Block.au.bi, 1, 0.0F);
- } else if (d == 2) {
- a(Block.aB.bi, 1, 0.0F);
+ if (event.isCancelled()) {
+ return true;
+ }
+ i = event.getDamage();
+ // CraftBukkit end
+
+ this.c = -this.c;
+ this.b = 10;
+ this.y();
+ this.a += i * 10;
+ if (this.a > 40) {
+ this.a(Item.MINECART.id, 1, 0.0F);
+ if (this.d == 1) {
+ this.a(Block.CHEST.id, 1, 0.0F);
+ } else if (this.d == 2) {
+ this.a(Block.FURNACE.id, 1, 0.0F);
+ }
+
+ this.q();
}
- q();
+
+ return true;
+ } else {
+ return true;
}
- return true;
}
public boolean c_() {
- return !G;
+ return !this.dead;
}
public void q() {
- label0:
- for (int i = 0; i < h_(); i++) {
- ItemStack itemstack = a(i);
+ for (int i = 0; i < this.h_(); ++i) {
+ ItemStack itemstack = this.a(i);
- if (itemstack == null) {
- continue;
- }
- float f1 = W.nextFloat() * 0.8F + 0.1F;
- float f2 = W.nextFloat() * 0.8F + 0.1F;
- float f3 = W.nextFloat() * 0.8F + 0.1F;
+ if (itemstack != null) {
+ float f = this.random.nextFloat() * 0.8F + 0.1F;
+ float f1 = this.random.nextFloat() * 0.8F + 0.1F;
+ float f2 = this.random.nextFloat() * 0.8F + 0.1F;
- do {
- if (itemstack.a <= 0) {
- continue label0;
- }
- int j = W.nextInt(21) + 10;
+ while (itemstack.count > 0) {
+ int j = this.random.nextInt(21) + 10;
- if (j > itemstack.a) {
- j = itemstack.a;
- }
- itemstack.a -= j;
- EntityItem entityitem = new EntityItem(l, p + (double) f1, q + (double) f2, r + (double) f3, new ItemStack(itemstack.c, j, itemstack.h()));
- float f4 = 0.05F;
+ if (j > itemstack.count) {
+ j = itemstack.count;
+ }
+
+ itemstack.count -= j;
+ EntityItem entityitem = new EntityItem(this.world, this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, new ItemStack(itemstack.id, j, itemstack.h()));
+ float f3 = 0.05F;
- entityitem.s = (float) W.nextGaussian() * f4;
- entityitem.t = (float) W.nextGaussian() * f4 + 0.2F;
- entityitem.u = (float) W.nextGaussian() * f4;
- l.a(((Entity) (entityitem)));
- } while (true);
+ entityitem.motX = (double) ((float) this.random.nextGaussian() * f3);
+ entityitem.motY = (double) ((float) this.random.nextGaussian() * f3 + 0.2F);
+ entityitem.motZ = (double) ((float) this.random.nextGaussian() * f3);
+ this.world.a((Entity) entityitem);
+ }
+ }
}
super.q();
@@ -259,478 +198,492 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
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
- if (b > 0) {
- b--;
+
+ if (this.b > 0) {
+ --this.b;
}
- if (a > 0) {
- a--;
+
+ if (this.a > 0) {
+ --this.a;
}
- if (this.l.z && ao > 0) {
- if (ao > 0) {
- double d1 = p + (ap - p) / (double) ao;
- double d2 = q + (aq - q) / (double) ao;
- double d3 = r + (ar - r) / (double) ao;
- double d4;
-
- for (d4 = as - (double) v; d4 < -180D; d4 += 360D) {
+
+ double d0;
+
+ if (this.world.isStatic && this.ao > 0) {
+ if (this.ao > 0) {
+ double d1 = this.locX + (this.ap - this.locX) / (double) this.ao;
+ double d2 = this.locY + (this.aq - this.locY) / (double) this.ao;
+ double d3 = this.locZ + (this.ar - this.locZ) / (double) this.ao;
+
+ for (d0 = this.as - (double) this.yaw; d0 < -180.0D; d0 += 360.0D) {
;
}
- for (; d4 >= 180D; d4 -= 360D) {
- ;
+
+ while (d0 >= 180.0D) {
+ d0 -= 360.0D;
}
- v += ((float) (d4 / (double) ao));
- w += ((float) ((at - (double) w) / (double) ao));
- ao--;
- a(d1, d2, d3);
- b(v, w);
+
+ this.yaw = (float) ((double) this.yaw + d0 / (double) this.ao);
+ this.pitch = (float) ((double) this.pitch + (this.at - (double) this.pitch) / (double) this.ao);
+ --this.ao;
+ this.a(d1, d2, d3);
+ this.b(this.yaw, this.pitch);
} else {
- a(p, q, r);
- b(v, w);
+ this.a(this.locX, this.locY, this.locZ);
+ this.b(this.yaw, this.pitch);
}
- return;
- }
- m = p;
- n = q;
- o = r;
- t -= 0.039999999105930328D;
- int i = MathHelper.b(p);
- int j = MathHelper.b(q);
- int l = MathHelper.b(r);
-
- if (this.l.a(i, j - 1, l) == Block.aG.bi) {
- j--;
- }
- double d6 = 0.40000000000000002D;
- boolean flag = false;
- double d5 = 0.0078125D;
-
- if (this.l.a(i, j, l) == Block.aG.bi) {
- Vec3D vec3d = g(p, q, r);
- int i1 = this.l.b(i, j, l);
+ } else {
+ this.lastX = this.locX;
+ this.lastY = this.locY;
+ this.lastZ = this.locZ;
+ this.motY -= 0.03999999910593033D;
+ int i = MathHelper.b(this.locX);
+ int j = MathHelper.b(this.locY);
+ int k = MathHelper.b(this.locZ);
- q = j;
- if (i1 >= 2 && i1 <= 5) {
- q = j + 1;
+ if (this.world.getTypeId(i, j - 1, k) == Block.RAILS.id) {
+ --j;
}
- if (i1 == 2) {
- s -= d5;
- }
- if (i1 == 3) {
- s += d5;
- }
- if (i1 == 4) {
- u += d5;
- }
- if (i1 == 5) {
- u -= d5;
- }
- int ai[][] = an[i1];
- double d7 = ai[1][0] - ai[0][0];
- double d8 = ai[1][2] - ai[0][2];
- double d9 = Math.sqrt(d7 * d7 + d8 * d8);
- double d10 = s * d7 + u * d8;
-
- if (d10 < 0.0D) {
- d7 = -d7;
- d8 = -d8;
- }
- double d11 = Math.sqrt(s * s + u * u);
-
- s = (d11 * d7) / d9;
- u = (d11 * d8) / d9;
- double d14 = 0.0D;
- double d15 = (double) i + 0.5D + (double) ai[0][0] * 0.5D;
- double d16 = (double) l + 0.5D + (double) ai[0][2] * 0.5D;
- double d17 = (double) i + 0.5D + (double) ai[1][0] * 0.5D;
- double d18 = (double) l + 0.5D + (double) ai[1][2] * 0.5D;
-
- d7 = d17 - d15;
- d8 = d18 - d16;
- if (d7 == 0.0D) {
- p = (double) i + 0.5D;
- d14 = r - (double) l;
- } else if (d8 == 0.0D) {
- r = (double) l + 0.5D;
- d14 = p - (double) i;
- } else {
- double d19 = p - d15;
- double d21 = r - d16;
- double d23 = (d19 * d7 + d21 * d8) * 2D;
- d14 = d23;
- }
- p = d15 + d7 * d14;
- r = d16 + d8 * d14;
- a(p, q + (double) H, r);
- double d20 = s;
- double d22 = u;
-
- if (this.j != null) {
- d20 *= 0.75D;
- d22 *= 0.75D;
- }
- if (d20 < -d6) {
- d20 = -d6;
- }
- if (d20 > d6) {
- d20 = d6;
- }
- if (d22 < -d6) {
- d22 = -d6;
- }
- if (d22 > d6) {
- d22 = d6;
- }
- c(d20, 0.0D, d22);
- if (ai[0][1] != 0 && MathHelper.b(p) - i == ai[0][0] && MathHelper.b(r) - l == ai[0][2]) {
- a(p, q + (double) ai[0][1], r);
- } else if (ai[1][1] != 0 && MathHelper.b(p) - i == ai[1][0] && MathHelper.b(r) - l == ai[1][2]) {
- a(p, q + (double) ai[1][1], r);
- }
- if (this.j != null || !slowWhenEmpty) { // CraftBukkit
- s *= 0.99699997901916504D;
- t *= 0.0D;
- u *= 0.99699997901916504D;
- } else {
- if (d == 2) {
- double d24 = MathHelper.a(f * f + ak * ak);
-
- if (d24 > 0.01D) {
- flag = true;
- f /= d24;
- ak /= d24;
- double d25 = 0.040000000000000001D;
-
- s *= 0.80000001192092896D;
- t *= 0.0D;
- u *= 0.80000001192092896D;
- s += f * d25;
- u += ak * d25;
- } else {
- s *= 0.89999997615814209D;
- t *= 0.0D;
- u *= 0.89999997615814209D;
+ double d4 = 0.4D;
+ boolean flag = false;
+
+ d0 = 0.0078125D;
+ if (this.world.getTypeId(i, j, k) == Block.RAILS.id) {
+ Vec3D vec3d = this.g(this.locX, this.locY, this.locZ);
+ int l = this.world.getData(i, j, k);
+
+ this.locY = (double) j;
+ if (l >= 2 && l <= 5) {
+ this.locY = (double) (j + 1);
+ }
+
+ if (l == 2) {
+ this.motX -= d0;
+ }
+
+ if (l == 3) {
+ this.motX += d0;
+ }
+
+ if (l == 4) {
+ this.motZ += d0;
+ }
+
+ if (l == 5) {
+ this.motZ -= d0;
+ }
+
+ int[][] aint = an[l];
+ double d5 = (double) (aint[1][0] - aint[0][0]);
+ double d6 = (double) (aint[1][2] - aint[0][2]);
+ double d7 = Math.sqrt(d5 * d5 + d6 * d6);
+ double d8 = this.motX * d5 + this.motZ * d6;
+
+ if (d8 < 0.0D) {
+ d5 = -d5;
+ d6 = -d6;
+ }
+
+ double d9 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
+
+ this.motX = d9 * d5 / d7;
+ this.motZ = d9 * d6 / d7;
+ double d10 = 0.0D;
+ double d11 = (double) i + 0.5D + (double) aint[0][0] * 0.5D;
+ double d12 = (double) k + 0.5D + (double) aint[0][2] * 0.5D;
+ double d13 = (double) i + 0.5D + (double) aint[1][0] * 0.5D;
+ double d14 = (double) k + 0.5D + (double) aint[1][2] * 0.5D;
+
+ d5 = d13 - d11;
+ d6 = d14 - d12;
+ double d15;
+ double d16;
+ double d17;
+
+ if (d5 == 0.0D) {
+ this.locX = (double) i + 0.5D;
+ d10 = this.locZ - (double) k;
+ } else if (d6 == 0.0D) {
+ this.locZ = (double) k + 0.5D;
+ d10 = this.locX - (double) i;
+ } else {
+ d15 = this.locX - d11;
+ d17 = this.locZ - d12;
+ d16 = (d15 * d5 + d17 * d6) * 2.0D;
+ d10 = d16;
+ }
+
+ this.locX = d11 + d5 * d10;
+ this.locZ = d12 + d6 * d10;
+ this.a(this.locX, this.locY + (double) this.height, this.locZ);
+ d15 = this.motX;
+ d17 = this.motZ;
+ if (this.passenger != null) {
+ d15 *= 0.75D;
+ d17 *= 0.75D;
+ }
+
+ if (d15 < -d4) {
+ d15 = -d4;
+ }
+
+ if (d15 > d4) {
+ d15 = d4;
+ }
+
+ if (d17 < -d4) {
+ d17 = -d4;
+ }
+
+ if (d17 > d4) {
+ d17 = d4;
+ }
+
+ this.c(d15, 0.0D, d17);
+ if (aint[0][1] != 0 && MathHelper.b(this.locX) - i == aint[0][0] && MathHelper.b(this.locZ) - k == aint[0][2]) {
+ this.a(this.locX, this.locY + (double) aint[0][1], this.locZ);
+ } else if (aint[1][1] != 0 && MathHelper.b(this.locX) - i == aint[1][0] && MathHelper.b(this.locZ) - k == aint[1][2]) {
+ this.a(this.locX, this.locY + (double) aint[1][1], this.locZ);
+ }
+
+ if (this.passenger != null) {
+ this.motX *= 0.996999979019165D;
+ this.motY *= 0.0D;
+ this.motZ *= 0.996999979019165D;
+ } else {
+ if (this.d == 2) {
+ d16 = (double) MathHelper.a(this.f * this.f + this.ak * this.ak);
+ if (d16 > 0.01D) {
+ flag = true;
+ this.f /= d16;
+ this.ak /= d16;
+ double d18 = 0.04D;
+
+ this.motX *= 0.800000011920929D;
+ this.motY *= 0.0D;
+ this.motZ *= 0.800000011920929D;
+ this.motX += this.f * d18;
+ this.motZ += this.ak * d18;
+ } else {
+ this.motX *= 0.8999999761581421D;
+ this.motY *= 0.0D;
+ this.motZ *= 0.8999999761581421D;
+ }
}
+
+ this.motX *= 0.9599999785423279D;
+ this.motY *= 0.0D;
+ this.motZ *= 0.9599999785423279D;
}
- s *= 0.95999997854232788D;
- t *= 0.0D;
- u *= 0.95999997854232788D;
- }
- Vec3D vec3d1 = g(p, q, r);
- if (vec3d1 != null && vec3d != null) {
- double d26 = (vec3d.b - vec3d1.b) * 0.050000000000000003D;
- double d12 = Math.sqrt(s * s + u * u);
+ Vec3D vec3d1 = this.g(this.locX, this.locY, this.locZ);
+
+ if (vec3d1 != null && vec3d != null) {
+ double d19 = (vec3d.b - vec3d1.b) * 0.05D;
- if (d12 > 0.0D) {
- s = (s / d12) * (d12 + d26);
- u = (u / d12) * (d12 + d26);
+ d9 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
+ if (d9 > 0.0D) {
+ this.motX = this.motX / d9 * (d9 + d19);
+ this.motZ = this.motZ / d9 * (d9 + d19);
+ }
+
+ this.a(this.locX, vec3d1.b, this.locZ);
}
- a(p, vec3d1.b, r);
- }
- int j1 = MathHelper.b(p);
- int k1 = MathHelper.b(r);
- if (j1 != i || k1 != l) {
- double d13 = Math.sqrt(s * s + u * u);
+ int i1 = MathHelper.b(this.locX);
+ int j1 = MathHelper.b(this.locZ);
- s = d13 * (double) (j1 - i);
- u = d13 * (double) (k1 - l);
- }
- if (d == 2) {
- double d27 = MathHelper.a(f * f + ak * ak);
-
- if (d27 > 0.01D && s * s + u * u > 0.001D) {
- f /= d27;
- ak /= d27;
- if (f * s + ak * u < 0.0D) {
- f = 0.0D;
- ak = 0.0D;
- } else {
- f = s;
- ak = u;
+ if (i1 != i || j1 != k) {
+ d9 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
+ this.motX = d9 * (double) (i1 - i);
+ this.motZ = d9 * (double) (j1 - k);
+ }
+
+ if (this.d == 2) {
+ double d20 = (double) MathHelper.a(this.f * this.f + this.ak * this.ak);
+
+ if (d20 > 0.01D && this.motX * this.motX + this.motZ * this.motZ > 0.0010D) {
+ this.f /= d20;
+ this.ak /= d20;
+ if (this.f * this.motX + this.ak * this.motZ < 0.0D) {
+ this.f = 0.0D;
+ this.ak = 0.0D;
+ } else {
+ this.f = this.motX;
+ this.ak = this.motZ;
+ }
}
}
+ } else {
+ if (this.motX < -d4) {
+ this.motX = -d4;
+ }
+
+ if (this.motX > d4) {
+ this.motX = d4;
+ }
+
+ if (this.motZ < -d4) {
+ this.motZ = -d4;
+ }
+
+ if (this.motZ > d4) {
+ this.motZ = d4;
+ }
+
+ if (this.onGround) {
+ this.motX *= 0.5D;
+ this.motY *= 0.5D;
+ this.motZ *= 0.5D;
+ }
+
+ this.c(this.motX, this.motY, this.motZ);
+ if (!this.onGround) {
+ this.motX *= 0.949999988079071D;
+ this.motY *= 0.949999988079071D;
+ this.motZ *= 0.949999988079071D;
+ }
}
- } else {
- if (s < -d6) {
- s = -d6;
- }
- if (s > d6) {
- s = d6;
- }
- if (u < -d6) {
- u = -d6;
- }
- if (u > d6) {
- u = d6;
+
+ this.pitch = 0.0F;
+ double d21 = this.lastX - this.locX;
+ double d22 = this.lastZ - this.locZ;
+
+ if (d21 * d21 + d22 * d22 > 0.0010D) {
+ this.yaw = (float) (Math.atan2(d22, d21) * 180.0D / 3.141592653589793D);
+ if (this.am) {
+ this.yaw += 180.0F;
+ }
}
- if (A) {
- // CraftBukkit start
- s *= derailedX;
- t *= derailedY;
- u *= derailedZ;
- // CraftBukkit end
+
+ double d23;
+
+ for (d23 = (double) (this.yaw - this.lastYaw); d23 >= 180.0D; d23 -= 360.0D) {
+ ;
}
- c(s, t, u);
- if (!A) {
- // CraftBukkit start
- s *= flyingX;
- t *= flyingY;
- u *= flyingZ;
- // CraftBukkit end
+
+ while (d23 < -180.0D) {
+ d23 += 360.0D;
}
- }
- w = 0.0F;
- double d28 = m - p;
- double d29 = o - r;
-
- if (d28 * d28 + d29 * d29 > 0.001D) {
- v = (float) ((Math.atan2(d29, d28) * 180D) / 3.1415926535897931D);
- if (am) {
- v += 180F;
+
+ if (d23 < -170.0D || d23 >= 170.0D) {
+ this.yaw += 180.0F;
+ this.am = !this.am;
}
- }
- double d30;
- for (d30 = v - x; d30 >= 180D; d30 -= 360D) {
- ;
- }
- for (; d30 < -180D; d30 += 360D) {
- ;
- }
- if (d30 < -170D || d30 >= 170D) {
- v += 180F;
- am = !am;
- }
- b(v, w);
+ this.b(this.yaw, this.pitch);
- // CraftBukkit start
- CraftServer server = ((WorldServer)this.l).getServer();
- CraftWorld world = ((WorldServer)this.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
+ // 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);
- List list = this.l.b(((Entity) (this)), z.b(0.20000000298023224D, 0.0D, 0.20000000298023224D));
+ VehicleMoveEvent event = new VehicleMoveEvent(eventType , vehicle , from, to);
+ server.getPluginManager().callEvent(event);
+ // CraftBukkit end
- if (list != null && list.size() > 0) {
- for (int l1 = 0; l1 < list.size(); l1++) {
- Entity entity = (Entity) list.get(l1);
+ List list = this.world.b((Entity) this, this.boundingBox.b(0.20000000298023224D, 0.0D, 0.20000000298023224D));
- if (entity != this.j && entity.z() && (entity instanceof EntityMinecart)) {
- entity.c(((Entity) (this)));
+ if (list != null && list.size() > 0) {
+ for (int k1 = 0; k1 < list.size(); ++k1) {
+ Entity entity = (Entity) list.get(k1);
+
+ if (entity != this.passenger && entity.z() && entity instanceof EntityMinecart) {
+ entity.c((Entity) this);
+ }
}
}
- }
- if (this.j != null && this.j.G) {
- this.j = null;
- }
- if (flag && W.nextInt(4) == 0) {
- e--;
- if (e < 0) {
- f = ak = 0.0D;
+
+ if (this.passenger != null && this.passenger.dead) {
+ this.passenger = null;
+ }
+
+ if (flag && this.random.nextInt(4) == 0) {
+ --this.e;
+ if (this.e < 0) {
+ this.f = this.ak = 0.0D;
+ }
+
+ this.world.a("largesmoke", this.locX, this.locY + 0.8D, this.locZ, 0.0D, 0.0D, 0.0D);
}
- this.l.a("largesmoke", p, q + 0.80000000000000004D, r, 0.0D, 0.0D, 0.0D);
}
}
- public Vec3D g(double d1, double d2, double d3) {
- int i = MathHelper.b(d1);
- int j = MathHelper.b(d2);
- int l = MathHelper.b(d3);
+ public Vec3D g(double d0, double d1, double d2) {
+ int i = MathHelper.b(d0);
+ int j = MathHelper.b(d1);
+ int k = MathHelper.b(d2);
- if (this.l.a(i, j - 1, l) == Block.aG.bi) {
- j--;
+ if (this.world.getTypeId(i, j - 1, k) == Block.RAILS.id) {
+ --j;
}
- if (this.l.a(i, j, l) == Block.aG.bi) {
- int i1 = this.l.b(i, j, l);
- d2 = j;
- if (i1 >= 2 && i1 <= 5) {
- d2 = j + 1;
- }
- int ai[][] = an[i1];
- double d4 = 0.0D;
- double d5 = (double) i + 0.5D + (double) ai[0][0] * 0.5D;
- double d6 = (double) j + 0.5D + (double) ai[0][1] * 0.5D;
- double d7 = (double) l + 0.5D + (double) ai[0][2] * 0.5D;
- double d8 = (double) i + 0.5D + (double) ai[1][0] * 0.5D;
- double d9 = (double) j + 0.5D + (double) ai[1][1] * 0.5D;
- double d10 = (double) l + 0.5D + (double) ai[1][2] * 0.5D;
- double d11 = d8 - d5;
- double d12 = (d9 - d6) * 2D;
- double d13 = d10 - d7;
-
- if (d11 == 0.0D) {
- d1 = (double) i + 0.5D;
- d4 = d3 - (double) l;
- } else if (d13 == 0.0D) {
- d3 = (double) l + 0.5D;
- d4 = d1 - (double) i;
+ if (this.world.getTypeId(i, j, k) == Block.RAILS.id) {
+ int l = this.world.getData(i, j, k);
+
+ d1 = (double) j;
+ if (l >= 2 && l <= 5) {
+ d1 = (double) (j + 1);
+ }
+
+ int[][] aint = an[l];
+ double d3 = 0.0D;
+ double d4 = (double) i + 0.5D + (double) aint[0][0] * 0.5D;
+ double d5 = (double) j + 0.5D + (double) aint[0][1] * 0.5D;
+ double d6 = (double) k + 0.5D + (double) aint[0][2] * 0.5D;
+ double d7 = (double) i + 0.5D + (double) aint[1][0] * 0.5D;
+ double d8 = (double) j + 0.5D + (double) aint[1][1] * 0.5D;
+ double d9 = (double) k + 0.5D + (double) aint[1][2] * 0.5D;
+ double d10 = d7 - d4;
+ double d11 = (d8 - d5) * 2.0D;
+ double d12 = d9 - d6;
+
+ if (d10 == 0.0D) {
+ d0 = (double) i + 0.5D;
+ d3 = d2 - (double) k;
+ } else if (d12 == 0.0D) {
+ d2 = (double) k + 0.5D;
+ d3 = d0 - (double) i;
} else {
- double d14 = d1 - d5;
- double d15 = d3 - d7;
- double d16 = (d14 * d11 + d15 * d13) * 2D;
+ double d13 = d0 - d4;
+ double d14 = d2 - d6;
+ double d15 = (d13 * d10 + d14 * d12) * 2.0D;
- d4 = d16;
+ d3 = d15;
}
- d1 = d5 + d11 * d4;
- d2 = d6 + d12 * d4;
- d3 = d7 + d13 * d4;
- if (d12 < 0.0D) {
- d2++;
+
+ d0 = d4 + d10 * d3;
+ d1 = d5 + d11 * d3;
+ d2 = d6 + d12 * d3;
+ if (d11 < 0.0D) {
+ ++d1;
}
- if (d12 > 0.0D) {
- d2 += 0.5D;
+
+ if (d11 > 0.0D) {
+ d1 += 0.5D;
}
- return Vec3D.b(d1, d2, d3);
+
+ return Vec3D.b(d0, d1, d2);
} else {
return null;
}
}
protected void a(NBTTagCompound nbttagcompound) {
- nbttagcompound.a("Type", d);
- if (d == 2) {
- nbttagcompound.a("PushX", f);
- nbttagcompound.a("PushZ", ak);
- nbttagcompound.a("Fuel", (short) e);
- } else if (d == 1) {
+ nbttagcompound.a("Type", this.d);
+ if (this.d == 2) {
+ nbttagcompound.a("PushX", this.f);
+ nbttagcompound.a("PushZ", this.ak);
+ nbttagcompound.a("Fuel", (short) this.e);
+ } else if (this.d == 1) {
NBTTagList nbttaglist = new NBTTagList();
- for (int i = 0; i < al.length; i++) {
- if (al[i] != null) {
+ for (int i = 0; i < this.al.length; ++i) {
+ if (this.al[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.a("Slot", (byte) i);
- al[i].a(nbttagcompound1);
- nbttaglist.a(((NBTBase) (nbttagcompound1)));
+ this.al[i].a(nbttagcompound1);
+ nbttaglist.a((NBTBase) nbttagcompound1);
}
}
- nbttagcompound.a("Items", ((NBTBase) (nbttaglist)));
+ nbttagcompound.a("Items", (NBTBase) nbttaglist);
}
}
protected void b(NBTTagCompound nbttagcompound) {
- d = nbttagcompound.d("Type");
- if (d == 2) {
- f = nbttagcompound.g("PushX");
- ak = nbttagcompound.g("PushZ");
- e = ((int) (nbttagcompound.c("Fuel")));
- } else if (d == 1) {
+ this.d = nbttagcompound.d("Type");
+ if (this.d == 2) {
+ this.f = nbttagcompound.g("PushX");
+ this.ak = nbttagcompound.g("PushZ");
+ this.e = nbttagcompound.c("Fuel");
+ } else if (this.d == 1) {
NBTTagList nbttaglist = nbttagcompound.k("Items");
- al = new ItemStack[h_()];
- for (int i = 0; i < nbttaglist.b(); i++) {
+ this.al = new ItemStack[this.h_()];
+
+ for (int i = 0; i < nbttaglist.b(); ++i) {
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i);
- int j = nbttagcompound1.b("Slot") & 0xff;
+ int j = nbttagcompound1.b("Slot") & 255;
- if (j >= 0 && j < al.length) {
- al[j] = new ItemStack(nbttagcompound1);
+ if (j >= 0 && j < this.al.length) {
+ this.al[j] = new ItemStack(nbttagcompound1);
}
}
}
}
public void c(Entity entity) {
- if (l.z) {
- return;
- }
- if (entity == j) {
- return;
- }
-
- // CraftBukkit start
- 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);
-
- if (collsionEvent.isCancelled()) {
- return;
- }
-
- if ((entity instanceof EntityLiving) && !(entity instanceof EntityPlayer) && d == 0 && s * s + u * u > 0.01D && j == null && entity.k == null) {
- if (!collsionEvent.isPickupCancelled()) {
- eventType = Type.VEHICLE_ENTER;
-
- VehicleEnterEvent enterEvent = new VehicleEnterEvent(eventType, vehicle, hitEntity);
- server.getPluginManager().callEvent(enterEvent);
-
- if (!enterEvent.isCancelled()) {
- entity.e(((Entity) (this)));
+ if (!this.world.isStatic) {
+ if (entity != this.passenger) {
+ if (entity instanceof EntityLiving && !(entity instanceof EntityHuman) && this.d == 0 && this.motX * this.motX + this.motZ * this.motZ > 0.01D && this.passenger == null && entity.vehicle == null) {
+ entity.e((Entity) this);
}
- }
- }
- // CraftBukkit end
- double d1 = entity.p - p;
- double d2 = entity.r - r;
- double d3 = d1 * d1 + d2 * d2;
+ double d0 = entity.locX - this.locX;
+ double d1 = entity.locZ - this.locZ;
+ double d2 = d0 * d0 + d1 * d1;
- // CraftBukkit
- if (d3 >= 9.9999997473787516E-005D && !collsionEvent.isCollisionCancelled()) {
- d3 = MathHelper.a(d3);
- d1 /= d3;
- d2 /= d3;
- double d4 = 1.0D / d3;
+ if (d2 >= 9.999999747378752E-5D) {
+ d2 = (double) MathHelper.a(d2);
+ d0 /= d2;
+ d1 /= d2;
+ double d3 = 1.0D / d2;
- if (d4 > 1.0D) {
- d4 = 1.0D;
- }
- d1 *= d4;
- d2 *= d4;
- d1 *= 0.10000000149011612D;
- d2 *= 0.10000000149011612D;
- d1 *= 1.0F - U;
- d2 *= 1.0F - U;
- d1 *= 0.5D;
- d2 *= 0.5D;
- if (entity instanceof EntityMinecart) {
- double d5 = entity.s + s;
- double d6 = entity.u + u;
-
- if (((EntityMinecart) entity).d == 2 && d != 2) {
- s *= 0.20000000298023224D;
- u *= 0.20000000298023224D;
- f(entity.s - d1, 0.0D, entity.u - d2);
- entity.s *= 0.69999998807907104D;
- entity.u *= 0.69999998807907104D;
- } else if (((EntityMinecart) entity).d != 2 && d == 2) {
- entity.s *= 0.20000000298023224D;
- entity.u *= 0.20000000298023224D;
- entity.f(s + d1, 0.0D, u + d2);
- s *= 0.69999998807907104D;
- u *= 0.69999998807907104D;
- } else {
- d5 /= 2D;
- d6 /= 2D;
- s *= 0.20000000298023224D;
- u *= 0.20000000298023224D;
- f(d5 - d1, 0.0D, d6 - d2);
- entity.s *= 0.20000000298023224D;
- entity.u *= 0.20000000298023224D;
- entity.f(d5 + d1, 0.0D, d6 + d2);
+ if (d3 > 1.0D) {
+ d3 = 1.0D;
+ }
+
+ d0 *= d3;
+ d1 *= d3;
+ d0 *= 0.10000000149011612D;
+ d1 *= 0.10000000149011612D;
+ d0 *= (double) (1.0F - this.U);
+ d1 *= (double) (1.0F - this.U);
+ d0 *= 0.5D;
+ d1 *= 0.5D;
+ if (entity instanceof EntityMinecart) {
+ double d4 = entity.motX + this.motX;
+ double d5 = entity.motZ + this.motZ;
+
+ if (((EntityMinecart) entity).d == 2 && this.d != 2) {
+ this.motX *= 0.20000000298023224D;
+ this.motZ *= 0.20000000298023224D;
+ this.f(entity.motX - d0, 0.0D, entity.motZ - d1);
+ entity.motX *= 0.699999988079071D;
+ entity.motZ *= 0.699999988079071D;
+ } else if (((EntityMinecart) entity).d != 2 && this.d == 2) {
+ entity.motX *= 0.20000000298023224D;
+ entity.motZ *= 0.20000000298023224D;
+ entity.f(this.motX + d0, 0.0D, this.motZ + d1);
+ this.motX *= 0.699999988079071D;
+ this.motZ *= 0.699999988079071D;
+ } else {
+ d4 /= 2.0D;
+ d5 /= 2.0D;
+ this.motX *= 0.20000000298023224D;
+ this.motZ *= 0.20000000298023224D;
+ this.f(d4 - d0, 0.0D, d5 - d1);
+ entity.motX *= 0.20000000298023224D;
+ entity.motZ *= 0.20000000298023224D;
+ entity.f(d4 + d0, 0.0D, d5 + d1);
+ }
+ } else {
+ this.f(-d0, 0.0D, -d1);
+ entity.f(d0 / 4.0D, 0.0D, d1 / 4.0D);
+ }
}
- } else {
- f(-d1, 0.0D, -d2);
- entity.f(d1 / 4D, 0.0D, d2 / 4D);
}
}
}
@@ -740,32 +693,34 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
}
public ItemStack a(int i) {
- return al[i];
+ return this.al[i];
}
public ItemStack b(int i, int j) {
- if (al[i] != null) {
- if (al[i].a <= j) {
- ItemStack itemstack = al[i];
+ if (this.al[i] != null) {
+ ItemStack itemstack;
- al[i] = null;
+ if (this.al[i].count <= j) {
+ itemstack = this.al[i];
+ this.al[i] = null;
return itemstack;
- }
- ItemStack itemstack1 = al[i].a(j);
+ } else {
+ itemstack = this.al[i].a(j);
+ if (this.al[i].count == 0) {
+ this.al[i] = null;
+ }
- if (al[i].a == 0) {
- al[i] = null;
+ return itemstack;
}
- return itemstack1;
} else {
return null;
}
}
public void a(int i, ItemStack itemstack) {
- al[i] = itemstack;
- if (itemstack != null && itemstack.a > c()) {
- itemstack.a = c();
+ this.al[i] = itemstack;
+ if (itemstack != null && itemstack.count > this.c()) {
+ itemstack.count = this.c();
}
}
@@ -779,18 +734,19 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
public void d() {}
- public boolean a(EntityPlayer entityplayer) {
- if (d == 0) {
- if (j != null && (j instanceof EntityPlayer) && j != entityplayer) {
+ public boolean a(EntityHuman entityhuman) {
+ if (this.d == 0) {
+ if (this.passenger != null && this.passenger instanceof EntityHuman && this.passenger != entityhuman) {
return true;
}
- if (!l.z) {
+
+ if (!this.world.isStatic) {
// CraftBukkit start
- CraftServer server = ((WorldServer) l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
Type eventType = Type.VEHICLE_ENTER;
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
- org.bukkit.entity.Entity player = (entityplayer == null)?null:entityplayer.getBukkitEntity();
-
+ org.bukkit.entity.Entity player = (entityhuman == null) ? null : entityhuman.getBukkitEntity();
+
VehicleEnterEvent event = new VehicleEnterEvent(eventType, vehicle, player);
server.getPluginManager().callEvent(event);
@@ -799,44 +755,31 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
}
// CraftBukkit end
- entityplayer.e(((Entity) (this)));
+ entityhuman.e(this);
}
- } else if (d == 1) {
- if (!l.z) {
- entityplayer.a(((IInventory) (this)));
+ } else if (this.d == 1) {
+ if (!this.world.isStatic) {
+ entityhuman.a((IInventory) this);
}
- } else if (d == 2) {
- ItemStack itemstack = entityplayer.an.e();
+ } else if (this.d == 2) {
+ ItemStack itemstack = entityhuman.inventory.e();
- if (itemstack != null && itemstack.c == Item.k.ba) {
- if (--itemstack.a == 0) {
- entityplayer.an.a(entityplayer.an.c, ((ItemStack) (null)));
+ if (itemstack != null && itemstack.id == Item.COAL.id) {
+ if (--itemstack.count == 0) {
+ entityhuman.inventory.a(entityhuman.inventory.c, (ItemStack) null);
}
- e += 1200;
+
+ this.e += 1200;
}
- f = p - entityplayer.p;
- ak = r - entityplayer.r;
+
+ this.f = this.locX - entityhuman.locX;
+ this.ak = this.locZ - entityhuman.locZ;
}
+
return true;
}
- public boolean a_(EntityPlayer entityplayer) {
- if (G) {
- return false;
- }
- return entityplayer.b(((Entity) (this))) <= 64D;
+ public boolean a_(EntityHuman entityhuman) {
+ return this.dead ? false : entityhuman.b((Entity) this) <= 64.0D;
}
-
- // CraftBukkit start
- @Override
- public org.bukkit.entity.Entity getBukkitEntity(){
- if (this.d == CraftMinecart.Type.StorageMinecart.getId()) {
- return this.bukkitStorageMinecart;
- } else if (this.d == CraftMinecart.Type.PoweredMinecart.getId()) {
- return this.bukkitPoweredMinecart;
- } else {
- return this.bukkitEntity;
- }
- }
- // CraftBukkit end
}