Call event when pistons push an item frame/painting. Fixes BUKKIT-5110

When pistons push/pull blocks they call Entity.move(float, float) to move
entities out of their path. For hanging entities this code path makes them
simply die and drop as an item. We now call an event in this scenario so
plugins can control this behavior.
Dieser Commit ist enthalten in:
Travis Watkins 2013-12-09 13:43:02 -06:00
Ursprung 305e5f4f08
Commit 772867eb51

Datei anzeigen

@ -237,7 +237,7 @@ public abstract class EntityHanging extends Entity {
this.world.getServer().getPluginManager().callEvent(paintingEvent); this.world.getServer().getPluginManager().callEvent(paintingEvent);
} }
if (dead || event.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) { if (this.dead || event.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) {
return true; return true;
} }
// CraftBukkit end // CraftBukkit end
@ -253,7 +253,17 @@ public abstract class EntityHanging extends Entity {
public void move(double d0, double d1, double d2) { public void move(double d0, double d1, double d2) {
if (!this.world.isStatic && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { if (!this.world.isStatic && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
if (dead) return; // CraftBukkit if (this.dead) return; // CraftBukkit
// CraftBukkit start
// TODO - Does this need its own cause? Seems to only be triggered by pistons
HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS);
this.world.getServer().getPluginManager().callEvent(event);
if (this.dead || event.isCancelled()) {
return;
}
// CraftBukkit end
this.die(); this.die();
this.b((Entity) null); this.b((Entity) null);