2011-01-07 22:05:25 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
import java.util.Iterator;
|
2011-01-07 22:05:25 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-01-07 22:05:25 +01:00
|
|
|
import org.bukkit.Location;
|
2011-01-17 01:53:42 +01:00
|
|
|
import org.bukkit.entity.Vehicle;
|
2011-01-07 22:05:25 +01:00
|
|
|
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
2011-03-16 12:49:37 +01:00
|
|
|
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
2011-01-07 22:05:25 +01:00
|
|
|
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
|
|
|
|
import org.bukkit.event.vehicle.VehicleMoveEvent;
|
2011-03-31 22:40:00 +02:00
|
|
|
// CraftBukkit end
|
2011-01-07 22:05:25 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public class EntityBoat extends Entity {
|
2011-01-07 22:05:25 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
private boolean a;
|
2011-11-20 09:01:14 +01:00
|
|
|
private double b;
|
2012-07-29 09:33:13 +02:00
|
|
|
private int c;
|
2011-11-20 09:01:14 +01:00
|
|
|
private double d;
|
2011-01-07 22:05:25 +01:00
|
|
|
private double e;
|
|
|
|
private double f;
|
2012-07-29 09:33:13 +02:00
|
|
|
private double g;
|
|
|
|
private double h;
|
2011-01-07 22:05:25 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-03-31 22:40:00 +02:00
|
|
|
public double maxSpeed = 0.4D;
|
2011-09-25 20:20:51 +02:00
|
|
|
public double occupiedDeceleration = 0.2D;
|
|
|
|
public double unoccupiedDeceleration = -1;
|
|
|
|
public boolean landBoats = false;
|
2011-03-31 22:40:00 +02:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
@Override
|
|
|
|
public void collide(Entity entity) {
|
2011-01-29 22:50:29 +01:00
|
|
|
org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity();
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), hitEntity);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
super.collide(entity);
|
2011-01-07 23:01:37 +01:00
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-07 23:01:37 +01:00
|
|
|
|
2011-01-07 22:05:25 +01:00
|
|
|
public EntityBoat(World world) {
|
|
|
|
super(world);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a = true;
|
|
|
|
this.b = 0.07D;
|
|
|
|
this.m = true;
|
|
|
|
this.a(1.5F, 0.6F);
|
2011-11-30 00:17:43 +01:00
|
|
|
this.height = this.length / 2.0F;
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected boolean e_() {
|
2011-03-31 22:40:00 +02:00
|
|
|
return false;
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void a() {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.datawatcher.a(17, new Integer(0));
|
|
|
|
this.datawatcher.a(18, new Integer(1));
|
|
|
|
this.datawatcher.a(19, new Integer(0));
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public AxisAlignedBB g(Entity entity) {
|
2011-01-29 22:50:29 +01:00
|
|
|
return entity.boundingBox;
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public AxisAlignedBB E() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return this.boundingBox;
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean M() {
|
2011-01-07 22:05:25 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public EntityBoat(World world, double d0, double d1, double d2) {
|
2011-01-07 22:05:25 +01:00
|
|
|
this(world);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.setPosition(d0, d1 + (double) this.height, d2);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motX = 0.0D;
|
|
|
|
this.motY = 0.0D;
|
|
|
|
this.motZ = 0.0D;
|
|
|
|
this.lastX = d0;
|
|
|
|
this.lastY = d1;
|
|
|
|
this.lastZ = d2;
|
2011-01-07 22:05:25 +01:00
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public double X() {
|
2011-11-30 00:17:43 +01:00
|
|
|
return (double) this.length * 0.0D - 0.30000001192092896D;
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
public boolean damageEntity(DamageSource damagesource, int i) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (!this.world.isStatic && !this.dead) {
|
|
|
|
// CraftBukkit start
|
|
|
|
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
2011-09-15 18:36:27 +02:00
|
|
|
org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, i);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
return true;
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
2011-06-27 00:25:01 +02:00
|
|
|
// i = event.getDamage(); // TODO Why don't we do this?
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c(-this.i());
|
|
|
|
this.b(10);
|
2011-11-20 09:01:14 +01:00
|
|
|
this.setDamage(this.getDamage() + i * 10);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.K();
|
|
|
|
if (damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild) {
|
|
|
|
this.setDamage(100);
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (this.getDamage() > 40) {
|
2011-03-16 12:49:37 +01:00
|
|
|
// CraftBukkit start
|
2012-03-27 17:37:00 +02:00
|
|
|
VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.world.getServer().getPluginManager().callEvent(destroyEvent);
|
2011-03-16 12:49:37 +01:00
|
|
|
|
|
|
|
if (destroyEvent.isCancelled()) {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
|
2011-03-16 12:49:37 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-05-31 15:55:45 +02:00
|
|
|
if (this.passenger != null) {
|
|
|
|
this.passenger.mount(this);
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(Item.BOAT.id, 1, 0.0F);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.die();
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return true;
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean L() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return !this.dead;
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void h_() {
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-01-29 22:50:29 +01:00
|
|
|
double prevX = this.locX;
|
|
|
|
double prevY = this.locY;
|
|
|
|
double prevZ = this.locZ;
|
|
|
|
float prevYaw = this.yaw;
|
|
|
|
float prevPitch = this.pitch;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
super.h_();
|
|
|
|
if (this.h() > 0) {
|
|
|
|
this.b(this.h() - 1);
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (this.getDamage() > 0) {
|
|
|
|
this.setDamage(this.getDamage() - 1);
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
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;
|
2012-07-29 09:33:13 +02:00
|
|
|
AxisAlignedBB axisalignedbb = AxisAlignedBB.a().a(this.boundingBox.a, d1, this.boundingBox.c, this.boundingBox.d, d2, this.boundingBox.f);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (this.world.b(axisalignedbb, Material.WATER)) {
|
|
|
|
d0 += 1.0D / (double) b0;
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
double d3 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
|
2011-01-29 22:50:29 +01:00
|
|
|
double d4;
|
|
|
|
double d5;
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (d3 > 0.26249999999999996D) {
|
2011-11-20 09:01:14 +01:00
|
|
|
d4 = Math.cos((double) this.yaw * 3.141592653589793D / 180.0D);
|
|
|
|
d5 = Math.sin((double) this.yaw * 3.141592653589793D / 180.0D);
|
|
|
|
|
|
|
|
for (int j = 0; (double) j < 1.0D + d3 * 60.0D; ++j) {
|
|
|
|
double d6 = (double) (this.random.nextFloat() * 2.0F - 1.0F);
|
|
|
|
double d7 = (double) (this.random.nextInt(2) * 2 - 1) * 0.7D;
|
|
|
|
double d8;
|
|
|
|
double d9;
|
|
|
|
|
|
|
|
if (this.random.nextBoolean()) {
|
|
|
|
d8 = this.locX - d4 * d6 * 0.8D + d5 * d7;
|
|
|
|
d9 = this.locZ - d5 * d6 * 0.8D - d4 * d7;
|
|
|
|
this.world.a("splash", d8, this.locY - 0.125D, d9, this.motX, this.motY, this.motZ);
|
|
|
|
} else {
|
|
|
|
d8 = this.locX + d4 + d5 * d6 * 0.7D;
|
|
|
|
d9 = this.locZ + d5 - d4 * d6 * 0.7D;
|
|
|
|
this.world.a("splash", d8, this.locY - 0.125D, d9, this.motX, this.motY, this.motZ);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double d10;
|
|
|
|
double d11;
|
2011-01-07 22:05:25 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.world.isStatic && this.a) {
|
|
|
|
if (this.c > 0) {
|
|
|
|
d4 = this.locX + (this.d - this.locX) / (double) this.c;
|
|
|
|
d5 = this.locY + (this.e - this.locY) / (double) this.c;
|
|
|
|
d10 = this.locZ + (this.f - this.locZ) / (double) this.c;
|
|
|
|
d11 = MathHelper.g(this.g - (double) this.yaw);
|
|
|
|
this.yaw = (float) ((double) this.yaw + d11 / (double) this.c);
|
|
|
|
this.pitch = (float) ((double) this.pitch + (this.h - (double) this.pitch) / (double) this.c);
|
|
|
|
--this.c;
|
2011-11-20 09:01:14 +01:00
|
|
|
this.setPosition(d4, d5, d10);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b(this.yaw, this.pitch);
|
2011-01-07 22:05:25 +01:00
|
|
|
} else {
|
2011-11-20 09:01:14 +01:00
|
|
|
d4 = this.locX + this.motX;
|
|
|
|
d5 = this.locY + this.motY;
|
|
|
|
d10 = this.locZ + this.motZ;
|
|
|
|
this.setPosition(d4, d5, d10);
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.onGround) {
|
|
|
|
this.motX *= 0.5D;
|
|
|
|
this.motY *= 0.5D;
|
|
|
|
this.motZ *= 0.5D;
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motX *= 0.9900000095367432D;
|
|
|
|
this.motY *= 0.949999988079071D;
|
|
|
|
this.motZ *= 0.9900000095367432D;
|
|
|
|
}
|
|
|
|
} else {
|
2011-05-26 14:48:22 +02:00
|
|
|
if (d0 < 1.0D) {
|
2011-11-20 09:01:14 +01:00
|
|
|
d4 = d0 * 2.0D - 1.0D;
|
|
|
|
this.motY += 0.03999999910593033D * d4;
|
2011-05-26 14:48:22 +02:00
|
|
|
} else {
|
2011-05-31 15:55:45 +02:00
|
|
|
if (this.motY < 0.0D) {
|
|
|
|
this.motY /= 2.0D;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.motY += 0.007000000216066837D;
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.passenger != null) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.motX += this.passenger.motX * this.b;
|
|
|
|
this.motZ += this.passenger.motZ * this.b;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-09-25 20:20:51 +02:00
|
|
|
// CraftBukkit start - block not in vanilla
|
|
|
|
else if (unoccupiedDeceleration >= 0) {
|
|
|
|
this.motX *= unoccupiedDeceleration;
|
|
|
|
this.motZ *= unoccupiedDeceleration;
|
|
|
|
// Kill lingering speed
|
|
|
|
if (motX <= 0.00001) {
|
|
|
|
motX = 0;
|
|
|
|
}
|
|
|
|
if (motZ <= 0.00001) {
|
|
|
|
motZ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-01-07 22:05:25 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
d4 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
|
|
|
|
if (d4 > 0.35D) {
|
|
|
|
d5 = 0.35D / d4;
|
|
|
|
this.motX *= d5;
|
|
|
|
this.motZ *= d5;
|
|
|
|
d4 = 0.35D;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-01-07 22:05:25 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (d4 > d3 && this.b < 0.35D) {
|
|
|
|
this.b += (0.35D - this.b) / 35.0D;
|
|
|
|
if (this.b > 0.35D) {
|
|
|
|
this.b = 0.35D;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.b -= (this.b - 0.07D) / 35.0D;
|
|
|
|
if (this.b < 0.07D) {
|
|
|
|
this.b = 0.07D;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-01-07 22:05:25 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.onGround && !this.landBoats) { // CraftBukkit
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motX *= 0.5D;
|
|
|
|
this.motY *= 0.5D;
|
|
|
|
this.motZ *= 0.5D;
|
|
|
|
}
|
2011-01-07 22:05:25 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.move(this.motX, this.motY, this.motZ);
|
2011-11-20 09:01:14 +01:00
|
|
|
if (this.positionChanged && d3 > 0.2D) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (!this.world.isStatic) {
|
2012-03-05 20:21:43 +01:00
|
|
|
// CraftBukkit start
|
2011-10-13 10:16:22 +02:00
|
|
|
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
2012-03-27 17:37:00 +02:00
|
|
|
VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
|
2011-10-13 10:16:22 +02:00
|
|
|
this.world.getServer().getPluginManager().callEvent(destroyEvent);
|
|
|
|
if (!destroyEvent.isCancelled()) {
|
2012-02-13 06:40:32 +01:00
|
|
|
this.die();
|
2012-03-27 17:37:00 +02:00
|
|
|
|
|
|
|
int k;
|
|
|
|
|
|
|
|
for (k = 0; k < 3; ++k) {
|
|
|
|
this.a(Block.WOOD.id, 1, 0.0F);
|
2012-02-13 06:40:32 +01:00
|
|
|
}
|
2012-03-27 17:37:00 +02:00
|
|
|
|
|
|
|
for (k = 0; k < 2; ++k) {
|
|
|
|
this.a(Item.STICK.id, 1, 0.0F);
|
|
|
|
}
|
2012-07-22 08:18:00 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
|
|
|
this.motX *= 0.9900000095367432D;
|
|
|
|
this.motY *= 0.949999988079071D;
|
|
|
|
this.motZ *= 0.9900000095367432D;
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.pitch = 0.0F;
|
2011-05-26 14:48:22 +02:00
|
|
|
d5 = (double) this.yaw;
|
2011-11-20 09:01:14 +01:00
|
|
|
d10 = this.lastX - this.locX;
|
|
|
|
d11 = this.lastZ - this.locZ;
|
2012-07-29 09:33:13 +02:00
|
|
|
if (d10 * d10 + d11 * d11 > 0.001D) {
|
2011-11-20 09:01:14 +01:00
|
|
|
d5 = (double) ((float) (Math.atan2(d11, d10) * 180.0D / 3.141592653589793D));
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
double d12 = MathHelper.g(d5 - (double) this.yaw);
|
2011-01-07 22:05:25 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (d12 > 20.0D) {
|
|
|
|
d12 = 20.0D;
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (d12 < -20.0D) {
|
|
|
|
d12 = -20.0D;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-01-07 22:05:25 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.yaw = (float) ((double) this.yaw + d12);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b(this.yaw, this.pitch);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
org.bukkit.Server server = this.world.getServer();
|
|
|
|
org.bukkit.World bworld = this.world.getWorld();
|
|
|
|
|
|
|
|
Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch);
|
|
|
|
Location to = new Location(bworld, this.locX, this.locY, this.locZ, this.yaw, this.pitch);
|
2011-02-01 11:20:18 +01:00
|
|
|
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-02-01 11:14:59 +01:00
|
|
|
if (!from.equals(to)) {
|
2011-03-26 22:32:56 +01:00
|
|
|
VehicleMoveEvent event = new VehicleMoveEvent(vehicle, from, to);
|
2011-02-01 11:14:59 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (!this.world.isStatic) {
|
|
|
|
List list = this.world.getEntities(this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D));
|
|
|
|
|
|
|
|
if (list != null && !list.isEmpty()) {
|
|
|
|
Iterator iterator = list.iterator();
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
while (iterator.hasNext()) {
|
|
|
|
Entity entity = (Entity) iterator.next();
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (entity != this.passenger && entity.M() && entity instanceof EntityBoat) {
|
|
|
|
entity.collide(this);
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
for (int l = 0; l < 4; ++l) {
|
|
|
|
int i1 = MathHelper.floor(this.locX + ((double) (l % 2) - 0.5D) * 0.8D);
|
|
|
|
int j1 = MathHelper.floor(this.locZ + ((double) (l / 2) - 0.5D) * 0.8D);
|
|
|
|
|
|
|
|
for (int k1 = 0; k1 < 2; ++k1) {
|
|
|
|
int l1 = MathHelper.floor(this.locY) + k1;
|
|
|
|
int i2 = this.world.getTypeId(i1, l1, j1);
|
|
|
|
int j2 = this.world.getData(i1, l1, j1);
|
2011-05-26 14:48:22 +02:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (i2 == Block.SNOW.id) {
|
|
|
|
this.world.setTypeId(i1, l1, j1, 0);
|
|
|
|
} else if (i2 == Block.WATER_LILY.id) {
|
|
|
|
Block.WATER_LILY.dropNaturally(this.world, i1, l1, j1, j2, 0.3F, 0);
|
|
|
|
this.world.setTypeId(i1, l1, j1, 0);
|
|
|
|
}
|
|
|
|
}
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.passenger != null && this.passenger.dead) {
|
|
|
|
this.passenger.vehicle = null; // CraftBukkit
|
|
|
|
this.passenger = null;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void V() {
|
2011-01-29 22:50:29 +01:00
|
|
|
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;
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.passenger.setPosition(this.locX + d0, this.locY + this.X() + this.passenger.W(), this.locZ + d1);
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void b(NBTTagCompound nbttagcompound) {}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected void a(NBTTagCompound nbttagcompound) {}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean c(EntityHuman entityhuman) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.passenger != null && this.passenger instanceof EntityHuman && this.passenger != entityhuman) {
|
2011-01-07 22:05:25 +01:00
|
|
|
return true;
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
|
|
|
if (!this.world.isStatic) {
|
2011-04-20 19:05:14 +02:00
|
|
|
entityhuman.mount(this);
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
return true;
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
|
|
|
public void setDamage(int i) {
|
|
|
|
this.datawatcher.watch(19, Integer.valueOf(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getDamage() {
|
|
|
|
return this.datawatcher.getInt(19);
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void b(int i) {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.datawatcher.watch(17, Integer.valueOf(i));
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public int h() {
|
2011-11-20 09:01:14 +01:00
|
|
|
return this.datawatcher.getInt(17);
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void c(int i) {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.datawatcher.watch(18, Integer.valueOf(i));
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public int i() {
|
2011-11-20 09:01:14 +01:00
|
|
|
return this.datawatcher.getInt(18);
|
|
|
|
}
|
2011-01-07 22:05:25 +01:00
|
|
|
}
|