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:
@@ -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) {}
|
||||
|
||||
Reference in New Issue
Block a user