diff options
Diffstat (limited to 'patches/server/0233-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch')
-rw-r--r-- | patches/server/0233-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch | 82 |
1 files changed, 14 insertions, 68 deletions
diff --git a/patches/server/0233-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch b/patches/server/0233-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch index 67d0628018..28ff4b9a12 100644 --- a/patches/server/0233-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch +++ b/patches/server/0233-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch @@ -3,9 +3,6 @@ From: Aikar <[email protected]> Date: Sat, 21 Jul 2018 08:25:40 -0400 Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues -Add -Ddebug.entities=true to your JVM flags to gain more information - -1.17: Needs to be reworked for new entity storage system diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java index c9e3e104cd051a38e367653dc6c4f969665fc250..45ee0cd242271883412284625230822d9c8a5452 100644 @@ -29,101 +26,50 @@ index c9e3e104cd051a38e367653dc6c4f969665fc250..45ee0cd242271883412284625230822d 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 536f1380ae3387ac4d062fe2f8b934a8d49905fb..1e10d55962a7221e197723eb42434be052a7661a 100644 +index 536f1380ae3387ac4d062fe2f8b934a8d49905fb..5538e810ef0a68f00043d4e750eb735300d50664 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -222,6 +222,9 @@ public class ServerLevel extends Level implements WorldGenLevel { - public final LevelStorageSource.LevelStorageAccess convertable; - public final UUID uuid; - public boolean hasPhysicsEvent = true; // Paper -+ public static Throwable getAddToWorldStackTrace(Entity entity) { -+ return new Throwable(entity + " Added to world at " + new java.util.Date()); -+ } - - @Override public LevelChunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI - return this.chunkSource.getChunk(x, z, false); -@@ -1436,7 +1439,28 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1436,6 +1436,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 ++ // Paper start - extra debug info + if (entity.valid) { -+ MinecraftServer.LOGGER.error("Attempted Double World add on " + entity, new Throwable()); -+ -+ if (DEBUG_ENTITIES) { -+ Throwable thr = entity.addedToWorldStack; -+ if (thr == null) { -+ MinecraftServer.LOGGER.error("Double add entity has no add stacktrace"); -+ } else { -+ MinecraftServer.LOGGER.error("Double add stacktrace: ", thr); -+ } -+ } ++ MinecraftServer.LOGGER.error("Attempted Double World add on {}", entity, new Throwable()); + return true; + } -+ // Paper end ++ // Paper end - extra debug info if (entity.isRemoved()) { -+ // Paper start -+ if (DEBUG_ENTITIES) { -+ new Throwable("Tried to add entity " + entity + " but it was marked as removed already").printStackTrace(); // CraftBukkit -+ getAddToWorldStackTrace(entity).printStackTrace(); -+ } -+ // Paper end // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); // CraftBukkit return false; - } else { diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index bebbbf9a0bca8ab94dd269d19ebf55622a3c2ef8..6d04954493680bc4fbad67ff2e43411f970f78f5 100644 +index bebbbf9a0bca8ab94dd269d19ebf55622a3c2ef8..a906fda4d5d92054f5c0cea4a8167cdb29287cc3 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -241,6 +241,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -241,6 +241,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper private CraftEntity bukkitEntity; + public @org.jetbrains.annotations.Nullable net.minecraft.server.level.ChunkMap.TrackedEntity tracker; // Paper -+ public @Nullable Throwable addedToWorldStack; // Paper - entity debug 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/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 71c2f082091f452cfc74557cd599cf7f080b889b..14c963d507173dae6015a0c81e3a690768012bed 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -153,6 +153,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - public boolean pvpMode; - public boolean keepSpawnInMemory = true; - public org.bukkit.generator.ChunkGenerator generator; -+ public static final boolean DEBUG_ENTITIES = Boolean.getBoolean("debug.entities"); // Paper - - public boolean preventPoiUpdated = false; // CraftBukkit - SPIGOT-5710 - public boolean captureBlockStates = false; 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 21a2800db22f287b9c6a8290326fdf3b94ae94b1..d45d832232be5017dde53816191c2b1830a0da32 100644 +index 21a2800db22f287b9c6a8290326fdf3b94ae94b1..2e561ac90a8c91ea13cfc18d09f8e0abbcff9385 100644 --- a/src/main/java/net/minecraft/world/level/entity/EntityLookup.java +++ b/src/main/java/net/minecraft/world/level/entity/EntityLookup.java -@@ -34,6 +34,26 @@ public class EntityLookup<T extends EntityAccess> { +@@ -34,6 +34,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 entityCast) { -+ if (net.minecraft.server.level.ServerLevel.DEBUG_ENTITIES) { -+ entityCast.addedToWorldStack = net.minecraft.server.level.ServerLevel.getAddToWorldStackTrace(entityCast); -+ } -+ -+ T old = this.byUuid.get(entity.getUUID()); -+ if (old instanceof net.minecraft.world.entity.Entity oldCast && old != null && oldCast.getId() != entity.getId() && oldCast.valid) { -+ LOGGER.error("Overwrote an existing entity " + oldCast + " with " + entity); -+ if (net.minecraft.server.level.ServerLevel.DEBUG_ENTITIES) { -+ if (oldCast.addedToWorldStack != null) { -+ oldCast.addedToWorldStack.printStackTrace(); -+ } else { -+ LOGGER.error("Oddly, the old entity was not added to the world in the normal way. Plugins?"); -+ } -+ entityCast.addedToWorldStack.printStackTrace(); -+ } ++ 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 ++ // Paper end - extra debug info } else { this.byUuid.put(uUID, entity); this.byId.put(entity.getId(), entity); |