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

@@ -55,8 +55,16 @@ public class PathfinderGoalTame extends PathfinderGoal {
this.entity.t(5);
}
if (this.entity.passenger != null) this.entity.passenger.mount((Entity) null); // CraftBukkit - Check for null
this.entity.passenger = null;
// CraftBukkit start - Handle dismounting to account for VehicleExitEvent being fired.
if (this.entity.passenger != null) {
this.entity.passenger.mount((Entity) null);
// If the entity still has a passenger, then a plugin cancelled the event.
if (this.entity.passenger != null) {
return;
}
}
// this.entity.passenger = null;
// CraftBukkit end
this.entity.cD();
this.entity.world.broadcastEntityEffect(this.entity, (byte) 6);
}