aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0226-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0226-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch')
-rw-r--r--patches/server/0226-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch75
1 files changed, 75 insertions, 0 deletions
diff --git a/patches/server/0226-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch b/patches/server/0226-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch
new file mode 100644
index 0000000000..dcfb0130df
--- /dev/null
+++ b/patches/server/0226-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch
@@ -0,0 +1,75 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar <[email protected]>
+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 fdd1b0a02eb90d39ad3324808d088705ab5651c0..bdaef11e9f8a78c7777b6a98fcca881c8f253bda 100644
+--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
++++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
+@@ -1258,6 +1258,7 @@ 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) {
+@@ -1298,7 +1299,7 @@ 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 4f777c9d8c3052f68bc0465c8a7386b8fb486c83..e9d08662c065d04a67918f0aa2cd4fde5798f2a6 100644
+--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
+@@ -1201,6 +1201,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
+ // CraftBukkit start
+ private boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
+ org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot
++ // Paper start - extra debug info
++ if (entity.valid) {
++ MinecraftServer.LOGGER.error("Attempted Double World add on {}", entity, new Throwable());
++ return true;
++ }
++ // Paper end - extra debug info
+ 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 f431c5a17bfc3bdf2a464470af4ec5e226b0d13e..131eda47e7a9f90a4057607870acbcb8fecfbf0b 100644
+--- a/src/main/java/net/minecraft/world/entity/Entity.java
++++ b/src/main/java/net/minecraft/world/entity/Entity.java
+@@ -250,6 +250,7 @@ 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 38df704dca30ef08f4d0831dc1cc48c6d6f71a4d..ed6aea7a38ef6e80c300ff9b012dcdbc390ad2c7 100644
+--- a/src/main/java/net/minecraft/world/level/entity/EntityLookup.java
++++ b/src/main/java/net/minecraft/world/level/entity/EntityLookup.java
+@@ -33,6 +33,14 @@ public class EntityLookup<T extends EntityAccess> {
+ UUID uUID = entity.getUUID();
+ if (this.byUuid.containsKey(uUID)) {
+ LOGGER.warn("Duplicate entity UUID {}: {}", uUID, entity);
++ // Paper start - extra debug info
++ if (entity instanceof net.minecraft.world.entity.Entity) {
++ final T old = this.byUuid.get(entity.getUUID());
++ if (old instanceof net.minecraft.world.entity.Entity oldCast && oldCast.getId() != entity.getId() && oldCast.valid) {
++ LOGGER.error("Overwrote an existing entity {} with {}", oldCast, entity);
++ }
++ }
++ // Paper end - extra debug info
+ } else {
+ this.byUuid.put(uUID, entity);
+ this.byId.put(entity.getId(), entity);