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.java141
1 files changed, 73 insertions, 68 deletions
diff --git a/src/main/java/net/minecraft/server/EntityMinecart.java b/src/main/java/net/minecraft/server/EntityMinecart.java
index 044c91a4..54c3584a 100644
--- a/src/main/java/net/minecraft/server/EntityMinecart.java
+++ b/src/main/java/net/minecraft/server/EntityMinecart.java
@@ -95,7 +95,7 @@ public class EntityMinecart extends Entity implements IInventory {
}
public AxisAlignedBB g(Entity entity) {
- return entity.boundingBox;
+ return entity.M() ? entity.boundingBox : null;
}
public AxisAlignedBB E() {
@@ -125,86 +125,90 @@ public class EntityMinecart extends Entity implements IInventory {
}
public boolean damageEntity(DamageSource damagesource, int i) {
- if (!this.world.isStatic && !this.dead) {
- // CraftBukkit start
- Vehicle vehicle = (Vehicle) this.getBukkitEntity();
- org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();
-
- VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, i);
- this.world.getServer().getPluginManager().callEvent(event);
+ if (this.isInvulnerable()) {
+ return false;
+ } else {
+ if (!this.world.isStatic && !this.dead) {
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();
- if (event.isCancelled()) {
- return true;
- }
+ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, i);
+ this.world.getServer().getPluginManager().callEvent(event);
- i = event.getDamage();
- // CraftBukkit end
+ if (event.isCancelled()) {
+ return true;
+ }
- this.i(-this.k());
- this.h(10);
- this.K();
- this.setDamage(this.getDamage() + i * 10);
- if (damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild) {
- this.setDamage(100);
- }
+ i = event.getDamage();
+ // CraftBukkit end
- if (this.getDamage() > 40) {
- if (this.passenger != null) {
- this.passenger.mount(this);
+ this.i(-this.k());
+ this.h(10);
+ this.K();
+ this.setDamage(this.getDamage() + i * 10);
+ if (damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild) {
+ this.setDamage(100);
}
- // CraftBukkit start
- VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
- this.world.getServer().getPluginManager().callEvent(destroyEvent);
+ if (this.getDamage() > 40) {
+ if (this.passenger != null) {
+ this.passenger.mount(this);
+ }
- if (destroyEvent.isCancelled()) {
- this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
- return true;
- }
- // CraftBukkit end
+ // CraftBukkit start
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
- this.die();
- this.a(Item.MINECART.id, 1, 0.0F);
- if (this.type == 1) {
- EntityMinecart entityminecart = this;
+ if (destroyEvent.isCancelled()) {
+ this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
+ return true;
+ }
+ // CraftBukkit end
- for (int j = 0; j < entityminecart.getSize(); ++j) {
- ItemStack itemstack = entityminecart.getItem(j);
+ this.die();
+ this.a(Item.MINECART.id, 1, 0.0F);
+ if (this.type == 1) {
+ EntityMinecart entityminecart = this;
- 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;
+ for (int j = 0; j < entityminecart.getSize(); ++j) {
+ ItemStack itemstack = entityminecart.getItem(j);
- while (itemstack.count > 0) {
- int k = this.random.nextInt(21) + 10;
+ 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;
- if (k > itemstack.count) {
- k = itemstack.count;
- }
+ while (itemstack.count > 0) {
+ int k = this.random.nextInt(21) + 10;
- itemstack.count -= k;
- // CraftBukkit - include enchantments in the new itemstack
- EntityItem entityitem = new EntityItem(this.world, this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, new ItemStack(itemstack.id, k, itemstack.getData(), itemstack.getEnchantments()));
- float f3 = 0.05F;
+ if (k > itemstack.count) {
+ k = itemstack.count;
+ }
- 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.addEntity(entityitem);
+ itemstack.count -= k;
+ // CraftBukkit - include enchantments in the new itemstack
+ EntityItem entityitem = new EntityItem(this.world, this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, new ItemStack(itemstack.id, k, itemstack.getData(), itemstack.getEnchantments()));
+ float f3 = 0.05F;
+
+ 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.addEntity(entityitem);
+ }
}
}
- }
- this.a(Block.CHEST.id, 1, 0.0F);
- } else if (this.type == 2) {
- this.a(Block.FURNACE.id, 1, 0.0F);
+ this.a(Block.CHEST.id, 1, 0.0F);
+ } else if (this.type == 2) {
+ this.a(Block.FURNACE.id, 1, 0.0F);
+ }
}
- }
- return true;
- } else {
- return true;
+ return true;
+ } else {
+ return true;
+ }
}
}
@@ -322,6 +326,7 @@ public class EntityMinecart extends Entity implements IInventory {
int l = this.world.getTypeId(i, j, k);
if (BlockMinecartTrack.d(l)) {
+ this.fallDistance = 0.0F;
Vec3D vec3d = this.a(this.locX, this.locY, this.locZ);
int i1 = this.world.getData(i, j, k);
@@ -536,15 +541,15 @@ public class EntityMinecart extends Entity implements IInventory {
this.motX += this.motX / d21 * d22;
this.motZ += this.motZ / d21 * d22;
} else if (i1 == 1) {
- if (this.world.s(i - 1, j, k)) {
+ if (this.world.t(i - 1, j, k)) {
this.motX = 0.02D;
- } else if (this.world.s(i + 1, j, k)) {
+ } else if (this.world.t(i + 1, j, k)) {
this.motX = -0.02D;
}
} else if (i1 == 0) {
- if (this.world.s(i, j, k - 1)) {
+ if (this.world.t(i, j, k - 1)) {
this.motZ = 0.02D;
- } else if (this.world.s(i, j, k + 1)) {
+ } else if (this.world.t(i, j, k + 1)) {
this.motZ = -0.02D;
}
}
@@ -904,7 +909,7 @@ public class EntityMinecart extends Entity implements IInventory {
public void update() {}
- public boolean c(EntityHuman entityhuman) {
+ public boolean a(EntityHuman entityhuman) {
if (this.type == 0) {
if (this.passenger != null && this.passenger instanceof EntityHuman && this.passenger != entityhuman) {
return true;
@@ -935,7 +940,7 @@ public class EntityMinecart extends Entity implements IInventory {
return true;
}
- public boolean a(EntityHuman entityhuman) {
+ public boolean a_(EntityHuman entityhuman) {
return this.dead ? false : entityhuman.e(this) <= 64.0D;
}