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 committed 2013-07-13 13:29:32 -06:00
1 parent 67f15266da
commit cebc247b78
4 files changed
+52 -6

No files matched your search

@@ -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) {}