2022-12-03 23:46:38 +01:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Yannick Lamprecht <yannicklamprecht@live.de>
Date: Wed, 30 Mar 2022 18:16:52 +0200
Subject: [PATCH] Player Entity Tracking Events
2023-08-21 09:38:55 +02:00
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
index 43c8f6a0615f392cc560b2259b116cc9d5fba4e7..ca24463405f138deb882f319bf84696f52a1f606 100644
2023-08-21 09:38:55 +02:00
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
2024-01-24 22:13:08 +01:00
@@ -1749,7 +1749,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
2023-08-21 09:38:55 +02:00
// CraftBukkit end
if (flag) {
if (this.seenBy.add(player.connection)) {
+ // Paper start - entity tracking events
+ if (io.papermc.paper.event.player.PlayerTrackEntityEvent.getHandlerList().getRegisteredListeners().length == 0 || new io.papermc.paper.event.player.PlayerTrackEntityEvent(player.getBukkitEntity(), this.entity.getBukkitEntity()).callEvent()) {
this.serverEntity.addPairing(player);
+ }
2024-01-16 12:41:40 +01:00
+ // Paper end - entity tracking events
2023-08-21 09:38:55 +02:00
}
} else if (this.seenBy.remove(player.connection)) {
this.serverEntity.removePairing(player);
2024-01-04 05:57:49 +01:00
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
2024-04-12 21:14:06 +02:00
index 640d7f248e3696b73ef8d7668358a78037081320..96a1f1460daba1507659a8ed34b608ded7084c0f 100644
2024-01-04 05:57:49 +01:00
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
2024-02-23 23:13:37 +01:00
@@ -3837,7 +3837,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
2022-12-03 23:46:38 +01:00
2024-01-04 05:57:49 +01:00
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();
+ }
+ }
2024-01-16 12:41:40 +01:00
+ // Paper end - entity tracking events
2024-01-04 05:57:49 +01:00
public float rotate(Rotation rotation) {
float f = Mth.wrapDegrees(this.getYRot());