Skip to content

Commit

Permalink
Call HangingBreakByEntityEvent for collision with boats
Browse files Browse the repository at this point in the history
  • Loading branch information
notTamion committed Feb 13, 2024
1 parent 31699ae commit 686ba81
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tamion <[email protected]>
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<Entity> 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()) {

0 comments on commit 686ba81

Please sign in to comment.