mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 20:50:41 +01:00
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.
This commit is contained in:
parent
305e5f4f08
commit
772867eb51
1 changed files with 12 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue