From 772867eb51fc4137acceb7b9fb61b8bd742f9b8b Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Mon, 9 Dec 2013 13:43:02 -0600 Subject: [PATCH] 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. --- .../java/net/minecraft/server/EntityHanging.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/minecraft/server/EntityHanging.java b/src/main/java/net/minecraft/server/EntityHanging.java index 4de0b17b36..670ca65b24 100644 --- a/src/main/java/net/minecraft/server/EntityHanging.java +++ b/src/main/java/net/minecraft/server/EntityHanging.java @@ -237,7 +237,7 @@ public abstract class EntityHanging extends Entity { 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; } // CraftBukkit end @@ -253,7 +253,17 @@ public abstract class EntityHanging extends Entity { public void move(double d0, double d1, double d2) { 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.b((Entity) null);