SPIGOT-2043: Ensure VehicleMoveEvent is always fired for boats

This commit is contained in:
Thinkofname 2016-04-20 11:12:14 +01:00
parent b5a4d07141
commit f060bba1ca

View File

@ -101,41 +101,47 @@
super.collide(entity); super.collide(entity);
} }
@@ -172,6 +228,10 @@ @@ -151,6 +207,8 @@
return this.getDirection().e();
}
+ private Location lastLocation; // CraftBukkit
+
public void m() {
this.aG = this.aF;
this.aF = this.t();
@@ -171,7 +229,6 @@
if (this.n() > 0.0F) {
this.setDamage(this.n() - 1.0F); this.setDamage(this.n() - 1.0F);
} }
-
+ // CraftBukkit start
+ float prevYaw = this.yaw;
+ float prevPitch = this.pitch;
+ // CraftBukkit end
this.lastX = this.locX; this.lastX = this.locX;
this.lastY = this.locY; this.lastY = this.locY;
this.lastZ = this.locZ; this.lastZ = this.locZ;
@@ -189,6 +249,22 @@ @@ -195,6 +252,22 @@
} this.motZ = 0.0D;
}
this.move(this.motX, this.motY, this.motZ); + // CraftBukkit start
+ // CraftBukkit start + org.bukkit.Server server = this.world.getServer();
+ // PAIL: CHECK ME + org.bukkit.World bworld = this.world.getWorld();
+ org.bukkit.Server server = this.world.getServer();
+ org.bukkit.World bworld = this.world.getWorld();
+ +
+ Location from = new Location(bworld, this.lastX, this.lastY, this.lastZ, prevYaw, prevPitch); + Location to = new Location(bworld, this.locX, this.locY, this.locZ, this.yaw, this.pitch);
+ Location to = new Location(bworld, this.locX, this.locY, this.locZ, this.yaw, this.pitch); + Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ +
+ server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); + server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
+ +
+ if (!from.equals(to)) { + if (lastLocation != null && !lastLocation.equals(to)) {
+ VehicleMoveEvent event = new VehicleMoveEvent(vehicle, from, to); + VehicleMoveEvent event = new VehicleMoveEvent(vehicle, lastLocation, to);
+ server.getPluginManager().callEvent(event); + server.getPluginManager().callEvent(event);
+ } + }
+ // CraftBukkit end + lastLocation = vehicle.getLocation();
} else { + // CraftBukkit end
this.motX = 0.0D; +
this.motY = 0.0D; for (int i = 0; i <= 1; ++i) {
@@ -591,6 +667,11 @@ if (this.a(i)) {
this.f[i] = (float) ((double) this.f[i] + 0.01D);
@@ -591,6 +664,11 @@
this.e(this.fallDistance, 1.0F); this.e(this.fallDistance, 1.0F);
if (!this.world.isClientSide && !this.dead) { if (!this.world.isClientSide && !this.dead) {
@ -147,7 +153,7 @@
this.die(); this.die();
if (this.world.getGameRules().getBoolean("doEntityDrops")) { if (this.world.getGameRules().getBoolean("doEntityDrops")) {
int i; int i;
@@ -604,6 +685,7 @@ @@ -604,6 +682,7 @@
} }
} }
} }