mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-27 02:02:03 -07:00
Fix untrack event not being called for all 'untracks' (#10110)
This commit is contained in:
@@ -23,6 +23,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ * Is called when a {@link Player} tracks an {@link Entity}.
|
||||
+ * <p>
|
||||
+ * If cancelled entity is not shown to the player and interaction in both directions is not possible.
|
||||
+ * <p>
|
||||
+ * Adding or removing entities from the world at the point in time this event is called is completely
|
||||
+ * unsupported and should be avoided.
|
||||
+ */
|
||||
+public class PlayerTrackEntityEvent extends PlayerEvent implements Cancellable {
|
||||
+
|
||||
@@ -82,6 +85,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+/**
|
||||
+ * Is called when a {@link Player} untracks an {@link Entity}.
|
||||
+ * <p>
|
||||
+ * Adding or removing entities from the world at the point in time this event is called is completely
|
||||
+ * unsupported and should be avoided.
|
||||
+ */
|
||||
+public class PlayerUntrackEntityEvent extends PlayerEvent {
|
||||
+
|
||||
|
@@ -19,11 +19,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // Paper end
|
||||
}
|
||||
} else if (this.seenBy.remove(player.connection)) {
|
||||
+ // Paper start - entity tracking events
|
||||
+ if (io.papermc.paper.event.player.PlayerUntrackEntityEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
+ new io.papermc.paper.event.player.PlayerUntrackEntityEvent(player.getBukkitEntity(), this.entity.getBukkitEntity()).callEvent();
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.serverEntity.removePairing(player);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
|
||||
public void startSeenByPlayer(ServerPlayer player) {}
|
||||
|
||||
- public void stopSeenByPlayer(ServerPlayer player) {}
|
||||
+ // Paper start - entity tracking events
|
||||
+ public void stopSeenByPlayer(ServerPlayer player) {
|
||||
+ // Since this event cannot be cancelled, we should call it here to catch all "un-tracks"
|
||||
+ if (io.papermc.paper.event.player.PlayerUntrackEntityEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
+ new io.papermc.paper.event.player.PlayerUntrackEntityEvent(player.getBukkitEntity(), this.getBukkitEntity()).callEvent();
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public float rotate(Rotation rotation) {
|
||||
float f = Mth.wrapDegrees(this.getYRot());
|
||||
|
Reference in New Issue
Block a user