summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/Entity.java
diff options
context:
space:
mode:
authorNate Mortensen <nate.richard.mortensen@gmail.com>2013-07-01 06:03:00 -0500
committerWesley Wolfe <weswolf@aol.com>2013-07-01 12:10:06 -0500
commit6c09066e224ac85b8a6464eaf8f53edfeb4beda4 (patch)
tree573e05f4b148cb1891a1d3839175e501e6257442 /src/main/java/net/minecraft/server/Entity.java
parentf887b76a259e12468b28d82d1eced93f0b73bd6d (diff)
downloadcraftbukkit-6c09066e224ac85b8a6464eaf8f53edfeb4beda4.tar
craftbukkit-6c09066e224ac85b8a6464eaf8f53edfeb4beda4.tar.gz
craftbukkit-6c09066e224ac85b8a6464eaf8f53edfeb4beda4.tar.lz
craftbukkit-6c09066e224ac85b8a6464eaf8f53edfeb4beda4.tar.xz
craftbukkit-6c09066e224ac85b8a6464eaf8f53edfeb4beda4.zip
Update CraftBukkit to 1.6.1
Diffstat (limited to 'src/main/java/net/minecraft/server/Entity.java')
-rw-r--r--src/main/java/net/minecraft/server/Entity.java199
1 files changed, 88 insertions, 111 deletions
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 0f7be97a..3953bc49 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -38,7 +38,7 @@ public abstract class Entity {
}
// CraftBukkit end
- private static int entityCount = 0;
+ private static int entityCount;
public int id;
public double l;
public boolean m;
@@ -108,42 +108,20 @@ public abstract class Entity {
private boolean invulnerable;
public UUID uniqueID; // CraftBukkit - private -> public
public EnumEntitySize at;
- public boolean valid = false; // CraftBukkit
+ public boolean valid; // CraftBukkit
public Entity(World world) {
this.id = entityCount++;
this.l = 1.0D;
- this.m = false;
this.boundingBox = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
- this.onGround = false;
- this.I = false;
- this.velocityChanged = false;
this.L = true;
- this.dead = false;
- this.height = 0.0F;
this.width = 0.6F;
this.length = 1.8F;
- this.Q = 0.0F;
- this.R = 0.0F;
- this.S = 0.0F;
- this.fallDistance = 0.0F;
this.c = 1;
- this.X = 0.0F;
- this.Y = 0.0F;
- this.Z = false;
- this.aa = 0.0F;
this.random = new Random();
- this.ticksLived = 0;
this.maxFireTicks = 1;
- this.fireTicks = 0;
- this.inWater = false;
- this.noDamageTicks = 0;
this.justCreated = true;
- this.fireProof = false;
this.datawatcher = new DataWatcher();
- this.ai = false;
- this.as = 0;
- this.invulnerable = false;
this.uniqueID = UUID.randomUUID();
this.at = EnumEntitySize.SIZE_2;
this.world = world;
@@ -279,7 +257,7 @@ public abstract class Entity {
b0 = -1;
}
- this.c(b0);
+ this.b(b0);
}
this.ap = false;
@@ -324,7 +302,7 @@ public abstract class Entity {
}
} else {
if (this.fireTicks % 20 == 0) {
- this.damageEntity(DamageSource.BURN, 1);
+ this.damageEntity(DamageSource.BURN, 1.0F);
}
--this.fireTicks;
@@ -342,7 +320,6 @@ public abstract class Entity {
if (!this.world.isStatic) {
this.a(0, this.fireTicks > 0);
- this.a(2, this.vehicle != null);
}
this.justCreated = false;
@@ -363,12 +340,12 @@ public abstract class Entity {
org.bukkit.block.Block damager = null; // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k);
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
- EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee, EntityDamageEvent.DamageCause.LAVA, 4);
+ EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee, EntityDamageEvent.DamageCause.LAVA, 4D);
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
damagee.setLastDamageCause(event);
- this.damageEntity(DamageSource.LAVA, event.getDamage());
+ this.damageEntity(DamageSource.LAVA, (float) event.getDamage());
}
if (this.fireTicks <= 0) {
@@ -549,7 +526,7 @@ public abstract class Entity {
d2 = d8;
AxisAlignedBB axisalignedbb1 = this.boundingBox.clone();
- this.boundingBox.c(axisalignedbb);
+ this.boundingBox.d(axisalignedbb);
list = this.world.getCubes(this, this.boundingBox.a(d6, d1, d8));
for (k = 0; k < list.size(); ++k) {
@@ -603,7 +580,7 @@ public abstract class Entity {
d0 = d10;
d1 = d11;
d2 = d12;
- this.boundingBox.c(axisalignedbb1);
+ this.boundingBox.d(axisalignedbb1);
}
}
@@ -653,7 +630,7 @@ public abstract class Entity {
}
// CraftBukkit end
- if (this.f_() && !flag && this.vehicle == null) {
+ if (this.e_() && !flag && this.vehicle == null) {
int l = MathHelper.floor(this.locX);
k = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height);
@@ -691,7 +668,16 @@ public abstract class Entity {
}
}
- this.C();
+ try {
+ this.C();
+ } catch (Throwable throwable) {
+ CrashReport crashreport = CrashReport.a(throwable, "Checking entity tile collision");
+ CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being checked for collision");
+
+ this.a(crashreportsystemdetails);
+ throw new ReportedException(crashreport);
+ }
+
boolean flag2 = this.F();
if (this.world.e(this.boundingBox.shrink(0.001D, 0.001D, 0.001D))) {
@@ -739,7 +725,15 @@ public abstract class Entity {
int j2 = this.world.getTypeId(k1, l1, i2);
if (j2 > 0) {
- Block.byId[j2].a(this.world, k1, l1, i2, this);
+ try {
+ Block.byId[j2].a(this.world, k1, l1, i2, this);
+ } catch (Throwable throwable) {
+ CrashReport crashreport = CrashReport.a(throwable, "Colliding entity with tile");
+ CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Tile being collided with");
+
+ CrashReportSystemDetails.a(crashreportsystemdetails, k1, l1, i2, j2, this.world.getData(k1, l1, i2));
+ throw new ReportedException(crashreport);
+ }
}
}
}
@@ -762,14 +756,14 @@ public abstract class Entity {
this.world.makeSound(this, s, f, f1);
}
- protected boolean f_() {
+ protected boolean e_() {
return true;
}
protected void a(double d0, boolean flag) {
if (flag) {
if (this.fallDistance > 0.0F) {
- this.a(this.fallDistance);
+ this.b(this.fallDistance);
this.fallDistance = 0.0F;
}
} else if (d0 < 0.0D) {
@@ -781,9 +775,9 @@ public abstract class Entity {
return null;
}
- protected void burn(int i) {
+ protected void burn(float i) { // CraftBukkit - int -> float
if (!this.fireProof) {
- this.damageEntity(DamageSource.FIRE, i);
+ this.damageEntity(DamageSource.FIRE, (float) i);
}
}
@@ -791,9 +785,9 @@ public abstract class Entity {
return this.fireProof;
}
- protected void a(float f) {
+ protected void b(float f) {
if (this.passenger != null) {
- this.passenger.a(f);
+ this.passenger.b(f);
}
}
@@ -889,7 +883,7 @@ public abstract class Entity {
}
}
- public float c(float f) {
+ public float d(float f) {
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.locZ);
@@ -1018,7 +1012,7 @@ public abstract class Entity {
this.velocityChanged = true;
}
- public boolean damageEntity(DamageSource damagesource, int i) {
+ public boolean damageEntity(DamageSource damagesource, float f) {
if (this.isInvulnerable()) {
return false;
} else {
@@ -1035,10 +1029,10 @@ public abstract class Entity {
return false;
}
- public void c(Entity entity, int i) {}
+ public void b(Entity entity, int i) {}
public boolean c(NBTTagCompound nbttagcompound) {
- String s = this.P();
+ String s = this.O();
if (!this.dead && s != null) {
nbttagcompound.setString("id", s);
@@ -1050,7 +1044,7 @@ public abstract class Entity {
}
public boolean d(NBTTagCompound nbttagcompound) {
- String s = this.P();
+ String s = this.O();
if (!this.dead && s != null && this.passenger == null) {
nbttagcompound.setString("id", s);
@@ -1162,7 +1156,8 @@ public abstract class Entity {
// Reset the persistence for tamed animals
if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) {
- entity.persistent = !entity.isTypeNotPersistent();
+ EntityInsentient entityinsentient = (EntityInsentient) entity;
+ entityinsentient.persistent = !entityinsentient.isTypeNotPersistent();
}
}
// CraftBukkit end
@@ -1215,7 +1210,7 @@ public abstract class Entity {
}
}
- protected final String P() {
+ protected final String O() {
return EntityTypes.b(this);
}
@@ -1223,6 +1218,8 @@ public abstract class Entity {
protected abstract void b(NBTTagCompound nbttagcompound);
+ public void P() {}
+
protected NBTTagList a(double... adouble) {
NBTTagList nbttaglist = new NBTTagList();
double[] adouble1 = adouble;
@@ -1260,11 +1257,15 @@ public abstract class Entity {
}
public EntityItem a(ItemStack itemstack, float f) {
- EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);
+ if (itemstack.count == 0) {
+ return null;
+ } else {
+ EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);
- entityitem.pickupDelay = 10;
- this.world.addEntity(entityitem);
- return entityitem;
+ entityitem.pickupDelay = 10;
+ this.world.addEntity(entityitem);
+ return entityitem;
+ }
}
public boolean isAlive() {
@@ -1288,7 +1289,7 @@ public abstract class Entity {
return false;
}
- public boolean a_(EntityHuman entityhuman) {
+ public boolean c(EntityHuman entityhuman) {
return false;
}
@@ -1354,12 +1355,6 @@ public abstract class Entity {
public void U() {
if (this.passenger != null) {
- if (!(this.passenger instanceof EntityHuman) || !((EntityHuman) this.passenger).cg()) {
- this.passenger.U = this.U;
- this.passenger.V = this.V + this.W() + this.passenger.V();
- this.passenger.W = this.W;
- }
-
this.passenger.setPosition(this.locX, this.locY + this.W() + this.passenger.V(), this.locZ);
}
}
@@ -1430,43 +1425,6 @@ public abstract class Entity {
}
}
- public void h(Entity entity) {
- double d0 = this.locX;
- double d1 = this.locY;
- double d2 = this.locZ;
-
- if (entity != null) {
- d0 = entity.locX;
- d1 = entity.boundingBox.b + (double) entity.length;
- d2 = entity.locZ;
- }
-
- for (double d3 = -1.5D; d3 < 2.0D; ++d3) {
- for (double d4 = -1.5D; d4 < 2.0D; ++d4) {
- if (d3 != 0.0D || d4 != 0.0D) {
- int i = (int) (this.locX + d3);
- int j = (int) (this.locZ + d4);
- AxisAlignedBB axisalignedbb = this.boundingBox.c(d3, 1.0D, d4);
-
- if (this.world.a(axisalignedbb).isEmpty()) {
- if (this.world.w(i, (int) this.locY, j)) {
- this.setPositionRotation(this.locX + d3, this.locY + 1.0D, this.locZ + d4, this.yaw, this.pitch);
- return;
- }
-
- if (this.world.w(i, (int) this.locY - 1, j) || this.world.getMaterial(i, (int) this.locY - 1, j) == Material.WATER) {
- d0 = this.locX + d3;
- d1 = this.locY + 1.0D;
- d2 = this.locZ + d4;
- }
- }
- }
- }
- }
-
- this.setPositionRotation(d0, d1, d2, this.yaw, this.pitch);
- }
-
public float X() {
return 0.1F;
}
@@ -1501,11 +1459,11 @@ public abstract class Entity {
public void setEquipment(int i, ItemStack itemstack) {}
public boolean isBurning() {
- return this.fireTicks > 0 || this.f(0);
+ return !this.fireProof && (this.fireTicks > 0 || this.f(0));
}
- public boolean af() {
- return this.vehicle != null || this.f(2);
+ public boolean ae() {
+ return this.vehicle != null;
}
public boolean isSneaking() {
@@ -1573,12 +1531,12 @@ public abstract class Entity {
}
}
- EntityDamageEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDamageEvent(entitylightning, this, EntityDamageEvent.DamageCause.LIGHTNING, 5);
+ EntityDamageEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDamageEvent(entitylightning, this, EntityDamageEvent.DamageCause.LIGHTNING, 5D);
if (event.isCancelled()) {
return;
}
- this.burn(event.getDamage());
+ this.burn((float) event.getDamage());
// CraftBukkit end
++this.fireTicks;
@@ -1671,7 +1629,7 @@ public abstract class Entity {
}
}
- public void al() {
+ public void ak() {
this.K = true;
this.fallDistance = 0.0F;
}
@@ -1686,11 +1644,11 @@ public abstract class Entity {
return LocaleI18n.get("entity." + s + ".name");
}
- public Entity[] an() {
+ public Entity[] am() {
return null;
}
- public boolean i(Entity entity) {
+ public boolean h(Entity entity) {
return this == entity;
}
@@ -1698,11 +1656,11 @@ public abstract class Entity {
return 0.0F;
}
- public boolean ap() {
+ public boolean ao() {
return true;
}
- public boolean j(Entity entity) {
+ public boolean i(Entity entity) {
return false;
}
@@ -1714,7 +1672,7 @@ public abstract class Entity {
return this.invulnerable;
}
- public void k(Entity entity) {
+ public void j(Entity entity) {
this.setPositionRotation(entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch);
}
@@ -1727,7 +1685,7 @@ public abstract class Entity {
this.as = entity.as;
}
- public void c(int i) {
+ public void b(int i) {
if (!this.world.isStatic && !this.dead) {
this.world.methodProfiler.a("changeDimension");
MinecraftServer minecraftserver = MinecraftServer.getServer();
@@ -1767,6 +1725,13 @@ public abstract class Entity {
// CraftBukkit end
this.dimension = i;
+ /* CraftBukkit start - TODO: Check if we need this
+ if (j == 1 && i == 1) {
+ worldserver1 = minecraftserver.getWorldServer(0);
+ this.dimension = 0;
+ }
+ // CraftBukkit end */
+
this.world.kill(this);
this.dead = false;
this.world.methodProfiler.a("reposition");
@@ -1782,6 +1747,14 @@ public abstract class Entity {
if (entity != null) {
entity.a(this, true);
+ /* CraftBukkit start - We need to do this...
+ if (j == 1 && i == 1) {
+ ChunkCoordinates chunkcoordinates = worldserver1.getSpawn();
+
+ chunkcoordinates.y = this.world.i(chunkcoordinates.x, chunkcoordinates.z);
+ entity.setPositionRotation((double) chunkcoordinates.x, (double) chunkcoordinates.y, (double) chunkcoordinates.z, entity.yaw, entity.pitch);
+ }
+ // CraftBukkit end */
worldserver1.addEntity(entity);
// CraftBukkit start - Forward the CraftEntity to the new entity
this.getBukkitEntity().setHandle(entity);
@@ -1805,15 +1778,15 @@ public abstract class Entity {
return true;
}
- public int ar() {
+ public int aq() {
return 3;
}
- public int as() {
+ public int ar() {
return this.as;
}
- public boolean at() {
+ public boolean as() {
return false;
}
@@ -1826,7 +1799,11 @@ public abstract class Entity {
crashreportsystemdetails.a("Entity\'s Momentum", String.format("%.2f, %.2f, %.2f", new Object[] { Double.valueOf(this.motX), Double.valueOf(this.motY), Double.valueOf(this.motZ)}));
}
- public boolean aw() {
+ public UUID getUniqueID() {
+ return this.uniqueID;
+ }
+
+ public boolean av() {
return true;
}