-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Call HangingBreakByEntityEvent for collision with boats
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
patches/server/1046-Call-HangingBreakByEntityEvent-for-collision-with-bo.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) { |