From 08e9cfb799da1dd34c4c39396724ec43913974b8 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sun, 28 Jul 2024 15:28:28 -0700 Subject: [PATCH] Remove Entity tracker field Now the only tracker field is from the entity tracker optimisations. --- ...ies-option-to-debug-dupe-uuid-issues.patch | 33 ------------------- patches/server/Expose-Tracked-Players.patch | 8 +++-- ...Folia-scheduler-and-owned-region-API.patch | 2 +- .../Moonrise-optimisation-patches.patch | 4 +-- ...ptimize-Collision-to-not-load-chunks.patch | 2 +- patches/server/Properly-resend-entities.patch | 8 ++--- 6 files changed, 12 insertions(+), 45 deletions(-) diff --git a/patches/server/Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch b/patches/server/Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch index 689ba5fa19..20b6e07f24 100644 --- a/patches/server/Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch +++ b/patches/server/Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch @@ -4,27 +4,6 @@ Date: Sat, 21 Jul 2018 08:25:40 -0400 Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues -diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - } else { - ChunkMap.TrackedEntity playerchunkmap_entitytracker = new ChunkMap.TrackedEntity(entity, i, j, entitytypes.trackDeltas()); - -+ entity.tracker = playerchunkmap_entitytracker; // Paper - Fast access to tracker - this.entityMap.put(entity.getId(), playerchunkmap_entitytracker); - playerchunkmap_entitytracker.updatePlayers(this.level.players()); - if (entity instanceof ServerPlayer) { -@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - if (playerchunkmap_entitytracker1 != null) { - playerchunkmap_entitytracker1.broadcastRemoved(); - } -- -+ entity.tracker = null; // Paper - We're no longer tracked - } - - protected void tick() { diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -42,18 +21,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (entity.isRemoved()) { // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); // CraftBukkit return false; -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 SyncedDataHolder, Nameable, EntityAccess - - private CraftEntity bukkitEntity; - -+ public @org.jetbrains.annotations.Nullable net.minecraft.server.level.ChunkMap.TrackedEntity tracker; // Paper - public CraftEntity getBukkitEntity() { - if (this.bukkitEntity == null) { - this.bukkitEntity = CraftEntity.getEntity(this.level.getCraftServer(), this); diff --git a/src/main/java/net/minecraft/world/level/entity/EntityLookup.java b/src/main/java/net/minecraft/world/level/entity/EntityLookup.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/entity/EntityLookup.java diff --git a/patches/server/Expose-Tracked-Players.patch b/patches/server/Expose-Tracked-Players.patch index d0b7c5a510..c43e8a6d7a 100644 --- a/patches/server/Expose-Tracked-Players.patch +++ b/patches/server/Expose-Tracked-Players.patch @@ -16,12 +16,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - tracked players API + @Override + public Set getTrackedPlayers() { -+ if (this.entity.tracker == null) { ++ ServerLevel world = (net.minecraft.server.level.ServerLevel)this.entity.level(); ++ ChunkMap.TrackedEntity tracker = world == null ? null : world.getChunkSource().chunkMap.entityMap.get(this.entity.getId()); ++ if (tracker == null) { + return java.util.Collections.emptySet(); + } + -+ Set set = new java.util.HashSet<>(this.entity.tracker.seenBy.size()); -+ for (net.minecraft.server.network.ServerPlayerConnection connection : this.entity.tracker.seenBy) { ++ Set set = new java.util.HashSet<>(tracker.seenBy.size()); ++ for (net.minecraft.server.network.ServerPlayerConnection connection : tracker.seenBy) { + set.add(connection.getPlayer().getBukkitEntity().getPlayer()); + } + return set; diff --git a/patches/server/Folia-scheduler-and-owned-region-API.patch b/patches/server/Folia-scheduler-and-owned-region-API.patch index c8146e25c4..1e35e43f6d 100644 --- a/patches/server/Folia-scheduler-and-owned-region-API.patch +++ b/patches/server/Folia-scheduler-and-owned-region-API.patch @@ -1189,7 +1189,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- 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 SyncedDataHolder, Nameable, EntityAccess - public @org.jetbrains.annotations.Nullable net.minecraft.server.level.ChunkMap.TrackedEntity tracker; // Paper + public CraftEntity getBukkitEntity() { if (this.bukkitEntity == null) { - this.bukkitEntity = CraftEntity.getEntity(this.level.getCraftServer(), this); diff --git a/patches/server/Moonrise-optimisation-patches.patch b/patches/server/Moonrise-optimisation-patches.patch index 6ba8413e58..c6bf9b2851 100644 --- a/patches/server/Moonrise-optimisation-patches.patch +++ b/patches/server/Moonrise-optimisation-patches.patch @@ -24105,8 +24105,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void addEntity(Entity entity) { @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + ChunkMap.TrackedEntity playerchunkmap_entitytracker = new ChunkMap.TrackedEntity(entity, i, j, entitytypes.trackDeltas()); - entity.tracker = playerchunkmap_entitytracker; // Paper - Fast access to tracker this.entityMap.put(entity.getId(), playerchunkmap_entitytracker); + // Paper start - optimise entity tracker + if (((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity)entity).moonrise$getTrackedEntity() != null) { @@ -24120,7 +24120,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider playerchunkmap_entitytracker1.broadcastRemoved(); } - entity.tracker = null; // Paper - We're no longer tracked + + ((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity)entity).moonrise$setTrackedEntity(null); // Paper - optimise entity tracker } diff --git a/patches/server/Optimize-Collision-to-not-load-chunks.patch b/patches/server/Optimize-Collision-to-not-load-chunks.patch index ce315b5972..3d4f5503e4 100644 --- a/patches/server/Optimize-Collision-to-not-load-chunks.patch +++ b/patches/server/Optimize-Collision-to-not-load-chunks.patch @@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public boolean collisionLoadChunks = false; // Paper private CraftEntity bukkitEntity; - public @org.jetbrains.annotations.Nullable net.minecraft.server.level.ChunkMap.TrackedEntity tracker; // Paper + public CraftEntity getBukkitEntity() { diff --git a/src/main/java/net/minecraft/world/level/BlockCollisions.java b/src/main/java/net/minecraft/world/level/BlockCollisions.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/BlockCollisions.java diff --git a/patches/server/Properly-resend-entities.patch b/patches/server/Properly-resend-entities.patch index f2a3829e25..d7eb9b135e 100644 --- a/patches/server/Properly-resend-entities.patch +++ b/patches/server/Properly-resend-entities.patch @@ -135,12 +135,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // This method should only be used if the data of an entity could have become desynced + // due to interactions on the client. + public void resendPossiblyDesyncedEntityData(net.minecraft.server.level.ServerPlayer player) { -+ if (this.tracker == null) { -+ return; -+ } -+ + if (player.getBukkitEntity().canSee(this.getBukkitEntity())) { -+ final net.minecraft.server.level.ServerEntity serverEntity = this.tracker.serverEntity; ++ ServerLevel world = (net.minecraft.server.level.ServerLevel)this.level(); ++ net.minecraft.server.level.ChunkMap.TrackedEntity tracker = world == null ? null : world.getChunkSource().chunkMap.entityMap.get(this.getId()); ++ final net.minecraft.server.level.ServerEntity serverEntity = tracker.serverEntity; + final List> list = new java.util.ArrayList<>(); + serverEntity.sendPairingData(player, list::add); + player.connection.send(new net.minecraft.network.protocol.game.ClientboundBundlePacket(list));