From 686ba81f83be622aa46de39ca1b5cfa5df91893d Mon Sep 17 00:00:00 2001 From: Tamion <70228790+notTamion@users.noreply.github.com> Date: Tue, 13 Feb 2024 13:51:57 +0100 Subject: [PATCH] Call HangingBreakByEntityEvent for collision with boats --- ...kByEntityEvent-for-collision-with-bo.patch | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 patches/server/1046-Call-HangingBreakByEntityEvent-for-collision-with-bo.patch diff --git a/patches/server/1046-Call-HangingBreakByEntityEvent-for-collision-with-bo.patch b/patches/server/1046-Call-HangingBreakByEntityEvent-for-collision-with-bo.patch new file mode 100644 index 0000000000000..d850945481fce --- /dev/null +++ b/patches/server/1046-Call-HangingBreakByEntityEvent-for-collision-with-bo.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tamion <70228790+notTamion@users.noreply.github.com> +Date: Tue, 13 Feb 2024 13:49:50 +0100 +Subject: [PATCH] Call HangingBreakByEntityEvent for collision with boats + + +diff --git a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java +index f88918b7c15b72f4cb1dd313734f550432fd5858..7472bf8688b9d6e6461691bb232a79d9922cf721 100644 +--- a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java ++++ b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java +@@ -125,14 +125,22 @@ public abstract class HangingEntity extends Entity { + BlockState material = this.level().getBlockState(this.blockPosition()); + HangingBreakEvent.RemoveCause cause; + +- if (!material.isAir()) { +- // TODO: This feels insufficient to catch 100% of suffocation cases +- cause = HangingBreakEvent.RemoveCause.OBSTRUCTION; ++ // Paper start - Call HangingBreakByEntityEvent for collision with boats ++ HangingBreakEvent event; ++ java.util.List collidingEntities = this.level().getHardCollidingEntities(this, this.getBoundingBox(), null); ++ if (!collidingEntities.isEmpty()) { ++ event = new HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), collidingEntities.get(0).getBukkitEntity()); + } else { +- cause = HangingBreakEvent.RemoveCause.PHYSICS; ++ // Paper end - Call HangingBreakByEntityEvent for collision with boats ++ if (!material.isAir()) { ++ // TODO: This feels insufficient to catch 100% of suffocation cases ++ cause = HangingBreakEvent.RemoveCause.OBSTRUCTION; ++ } else { ++ cause = HangingBreakEvent.RemoveCause.PHYSICS; ++ } ++ event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), cause); // Paper - Call HangingBreakByEntityEvent for collision with boats + } + +- HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), cause); + this.level().getCraftServer().getPluginManager().callEvent(event); + + if (this.isRemoved() || event.isCancelled()) {