This commit is contained in:
Tamion 2024-04-29 08:33:37 +02:00 committed by GitHub
commit b8ff015be0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,34 @@
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 bf2d91bbb4bf401696f5f5d14a67e3920a179084..ba01794f26914afe0fb922b99404578574592992 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
@@ -127,14 +127,22 @@ public abstract class HangingEntity extends Entity {
BlockState material = this.level().getBlockState(this.blockPosition());
HangingBreakEvent.RemoveCause cause;
+ // 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 {
+ // 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()) {