Correctly fire VehicleExitEvent. Fixes BUKKIT-3761

This change makes it so that EntityHuman#setPassengerOf(Entity) invokes
its parent method when leaving vehicles so that VehicleExitEvent is fired
for players leaving vehicles.

This change also fixes BUKKIT-2110, making it so VehicleExitEvent
correctly handles cancellation. The implementation of VehicleExitEvent
completely ignored the cancellation state of the event, making it so that
cancelling the event had no effect.  Cancelling a VehicleExitEvent now
causes the entity to remain inside of the vehicle, with no visual stutter.
This commit is contained in:
Nate Mortensen
2013-07-12 16:45:42 -06:00
parent 67f15266da
commit cebc247b78
4 changed files with 52 additions and 6 deletions

View File

@@ -461,12 +461,16 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void setPassengerOf(Entity entity) {
// mount(null) doesn't really fly for overloaded methods,
// so this method is needed
Entity currentVehicle = this.vehicle;
super.setPassengerOf(entity);
// CraftBukkit end
this.playerConnection.sendPacket(new Packet39AttachEntity(0, this, this.vehicle));
this.playerConnection.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
// Check if the vehicle actually changed.
if (currentVehicle != this.vehicle) {
this.playerConnection.sendPacket(new Packet39AttachEntity(0, this, this.vehicle));
this.playerConnection.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
}
// CraftBukkit end
}
protected void a(double d0, boolean flag) {}