From 700a664981f8711a0de3773c36a5e664842211ff Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Wed, 14 Aug 2019 19:37:07 -0700 Subject: [PATCH] Print entity debug stacktrace on entity double add (#2438) --- ...ies-option-to-debug-dupe-uuid-issues.patch | 27 +++++++++++++++---- ...ead-Entities-in-entityList-iteration.patch | 10 +++---- ...ets-from-world-player-list-not-serve.patch | 10 +++---- ...mit-lightning-strike-effect-distance.patch | 6 ++--- .../0366-Entity-getEntitySpawnReason.patch | 10 +++---- ...h-entity-loss-due-to-unloaded-chunks.patch | 6 ++--- .../0385-Duplicate-UUID-Resolve-Option.patch | 8 +++--- ...le-Keep-Spawn-Loaded-range-per-world.patch | 6 ++--- ...-being-ticked-when-notifying-navigat.patch | 8 +++--- 9 files changed, 54 insertions(+), 37 deletions(-) diff --git a/Spigot-Server-Patches/0254-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch b/Spigot-Server-Patches/0254-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch index d22869187a..380d88e341 100644 --- a/Spigot-Server-Patches/0254-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch +++ b/Spigot-Server-Patches/0254-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch @@ -1,4 +1,4 @@ -From e1dc1fc92f1d4e46ea41c274074713de49976a3c Mon Sep 17 00:00:00 2001 +From 25dd8434749412dffeb0e19d91868e66355c0f78 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 21 Jul 2018 08:25:40 -0400 Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues @@ -52,7 +52,7 @@ index e780f7af40..627fec10a8 100644 public boolean captureBlockStates = false; public boolean captureTreeGeneration = false; diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index d8c49d95e1..93d1cf0683 100644 +index d8c49d95e1..97049aba9d 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -72,6 +72,9 @@ public class WorldServer extends World { @@ -65,9 +65,26 @@ index d8c49d95e1..93d1cf0683 100644 // Add env and gen to constructor public WorldServer(MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, WorldData worlddata, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { -@@ -942,6 +945,12 @@ public class WorldServer extends World { +@@ -940,8 +943,28 @@ public class WorldServer extends World { + // CraftBukkit start + private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot - if (entity.valid) { MinecraftServer.LOGGER.error("Attempted Double World add on " + entity, new Throwable()); return true; } // Paper +- if (entity.valid) { MinecraftServer.LOGGER.error("Attempted Double World add on " + entity, new Throwable()); return true; } // Paper ++ // Paper start ++ 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); ++ } ++ } ++ return true; ++ } ++ // Paper end if (entity.dead) { + // Paper start + if (DEBUG_ENTITIES) { @@ -78,7 +95,7 @@ index d8c49d95e1..93d1cf0683 100644 // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType())); // CraftBukkit return false; } else if (this.isUUIDTaken(entity)) { -@@ -1107,7 +1116,24 @@ public class WorldServer extends World { +@@ -1107,7 +1130,24 @@ public class WorldServer extends World { } } diff --git a/Spigot-Server-Patches/0268-Ignore-Dead-Entities-in-entityList-iteration.patch b/Spigot-Server-Patches/0268-Ignore-Dead-Entities-in-entityList-iteration.patch index ccb1fea466..f2f6d54513 100644 --- a/Spigot-Server-Patches/0268-Ignore-Dead-Entities-in-entityList-iteration.patch +++ b/Spigot-Server-Patches/0268-Ignore-Dead-Entities-in-entityList-iteration.patch @@ -1,4 +1,4 @@ -From 711732dece46935958e265cecf83aa9e2a70417d Mon Sep 17 00:00:00 2001 +From e34810a399ed8289a4615e526122c360569ca345 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 28 Jul 2018 12:18:27 -0400 Subject: [PATCH] Ignore Dead Entities in entityList iteration @@ -63,7 +63,7 @@ index 701090c11e..7d579c119b 100644 private float av; private float aw; diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 93d1cf0683..20fb20c2e7 100644 +index 97049aba9d..24f1a64420 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -851,7 +851,7 @@ public class WorldServer extends World { @@ -75,7 +75,7 @@ index 93d1cf0683..20fb20c2e7 100644 if (entity instanceof EntityInsentient) { EntityInsentient entityinsentient = (EntityInsentient) entity; -@@ -1144,6 +1144,7 @@ public class WorldServer extends World { +@@ -1158,6 +1158,7 @@ public class WorldServer extends World { entity.origin = entity.getBukkitEntity().getLocation(); } // Paper end @@ -83,7 +83,7 @@ index 93d1cf0683..20fb20c2e7 100644 new com.destroystokyo.paper.event.entity.EntityAddToWorldEvent(entity.getBukkitEntity()).callEvent(); // Paper - fire while valid } -@@ -1157,6 +1158,7 @@ public class WorldServer extends World { +@@ -1171,6 +1172,7 @@ public class WorldServer extends World { this.removeEntityFromChunk(entity); this.entitiesById.remove(entity.getId()); this.unregisterEntity(entity); @@ -92,7 +92,7 @@ index 93d1cf0683..20fb20c2e7 100644 } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 62240fbf92..a4df908bb9 100644 +index ced1ab2a3a..6a32480663 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -931,6 +931,7 @@ public class CraftWorld implements World { diff --git a/Spigot-Server-Patches/0286-Send-nearby-packets-from-world-player-list-not-serve.patch b/Spigot-Server-Patches/0286-Send-nearby-packets-from-world-player-list-not-serve.patch index e85bbe5213..4882ba3747 100644 --- a/Spigot-Server-Patches/0286-Send-nearby-packets-from-world-player-list-not-serve.patch +++ b/Spigot-Server-Patches/0286-Send-nearby-packets-from-world-player-list-not-serve.patch @@ -1,4 +1,4 @@ -From dd89fe6e7813bf8bb59dc7e9df0ea17cd5ad6218 Mon Sep 17 00:00:00 2001 +From a2ec2aff517ee056460a4c687877ec5589cf80dd Mon Sep 17 00:00:00 2001 From: Mystiflow Date: Fri, 6 Jul 2018 13:21:30 +0100 Subject: [PATCH] Send nearby packets from world player list not server list @@ -46,10 +46,10 @@ index 9e5cd22d7d..049d702cb9 100644 double d5 = d1 - entityplayer.locY; double d6 = d2 - entityplayer.locZ; diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 20fb20c2e7..9172d08001 100644 +index 24f1a64420..0025e4ecfc 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -1191,7 +1191,7 @@ public class WorldServer extends World { +@@ -1205,7 +1205,7 @@ public class WorldServer extends World { } // CraftBukkit end this.globalEntityList.add(entitylightning); @@ -58,7 +58,7 @@ index 20fb20c2e7..9172d08001 100644 } @Override -@@ -1323,7 +1323,7 @@ public class WorldServer extends World { +@@ -1337,7 +1337,7 @@ public class WorldServer extends World { BlockActionData blockactiondata = (BlockActionData) this.I.removeFirst(); if (this.a(blockactiondata)) { @@ -68,7 +68,7 @@ index 20fb20c2e7..9172d08001 100644 } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index a4df908bb9..9a7b0076fc 100644 +index 6a32480663..267402c0d8 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1998,7 +1998,7 @@ public class CraftWorld implements World { diff --git a/Spigot-Server-Patches/0322-Limit-lightning-strike-effect-distance.patch b/Spigot-Server-Patches/0322-Limit-lightning-strike-effect-distance.patch index 1728e24c37..393a2e38c0 100644 --- a/Spigot-Server-Patches/0322-Limit-lightning-strike-effect-distance.patch +++ b/Spigot-Server-Patches/0322-Limit-lightning-strike-effect-distance.patch @@ -1,4 +1,4 @@ -From e5cd8b14861c5e1e592df865cf45603cf7ed42bc Mon Sep 17 00:00:00 2001 +From c05bb2b751ecc6bc634dce146db5724df08e139b Mon Sep 17 00:00:00 2001 From: Trigary Date: Fri, 14 Sep 2018 17:42:08 +0200 Subject: [PATCH] Limit lightning strike effect distance @@ -69,10 +69,10 @@ index 2ceee79cf2..27bf271bb5 100644 --this.lifeTicks; diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 9172d08001..9d92fb2a3f 100644 +index 0025e4ecfc..b01af00c86 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -1191,7 +1191,7 @@ public class WorldServer extends World { +@@ -1205,7 +1205,7 @@ public class WorldServer extends World { } // CraftBukkit end this.globalEntityList.add(entitylightning); diff --git a/Spigot-Server-Patches/0366-Entity-getEntitySpawnReason.patch b/Spigot-Server-Patches/0366-Entity-getEntitySpawnReason.patch index b76a45cb7b..24d354a73b 100644 --- a/Spigot-Server-Patches/0366-Entity-getEntitySpawnReason.patch +++ b/Spigot-Server-Patches/0366-Entity-getEntitySpawnReason.patch @@ -1,4 +1,4 @@ -From 8bdc3180009870d13123a44e540b385344e94458 Mon Sep 17 00:00:00 2001 +From 96966a820a0d86cf65fd11ce4d01850e23d8106a Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 24 Mar 2019 00:24:52 -0400 Subject: [PATCH] Entity#getEntitySpawnReason @@ -72,7 +72,7 @@ index 65df0e7c8c..abddc8895e 100644 }); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 9d92fb2a3f..c791ab686e 100644 +index b01af00c86..192b3be1f0 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -943,6 +943,7 @@ public class WorldServer extends World { @@ -80,9 +80,9 @@ index 9d92fb2a3f..c791ab686e 100644 private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot + if (entity.spawnReason == null) entity.spawnReason = spawnReason; // Paper - if (entity.valid) { MinecraftServer.LOGGER.error("Attempted Double World add on " + entity, new Throwable()); return true; } // Paper - if (entity.dead) { - // Paper start + // Paper start + if (entity.valid) { + MinecraftServer.LOGGER.error("Attempted Double World add on " + entity, new Throwable()); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 1cd3448e57..15042943c9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java diff --git a/Spigot-Server-Patches/0384-Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch b/Spigot-Server-Patches/0384-Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch index 61febec985..3af35ba8bc 100644 --- a/Spigot-Server-Patches/0384-Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch +++ b/Spigot-Server-Patches/0384-Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch @@ -1,4 +1,4 @@ -From d975ee9db6feb4d152164a06a70ba7c3b7154c4a Mon Sep 17 00:00:00 2001 +From 0e9dbe2c59db9edfc72829af874179d9852437d3 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 28 Sep 2018 21:49:53 -0400 Subject: [PATCH] Fix issues with entity loss due to unloaded chunks @@ -19,7 +19,7 @@ This change ensures the chunks are always loaded when entities are added to the world, or a valid entity moves between chunks. diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index c791ab686e..51f697b2c9 100644 +index 192b3be1f0..82c3bc60d0 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -640,7 +640,7 @@ public class WorldServer extends World { @@ -31,7 +31,7 @@ index c791ab686e..51f697b2c9 100644 entity.inChunk = false; } else { this.getChunkAt(i, k).a(entity); -@@ -961,7 +961,7 @@ public class WorldServer extends World { +@@ -975,7 +975,7 @@ public class WorldServer extends World { return false; } // CraftBukkit end diff --git a/Spigot-Server-Patches/0385-Duplicate-UUID-Resolve-Option.patch b/Spigot-Server-Patches/0385-Duplicate-UUID-Resolve-Option.patch index 3b3edd7e7c..9e21e1967c 100644 --- a/Spigot-Server-Patches/0385-Duplicate-UUID-Resolve-Option.patch +++ b/Spigot-Server-Patches/0385-Duplicate-UUID-Resolve-Option.patch @@ -1,4 +1,4 @@ -From 8c38c2390cee11240ea12602dbbd440aeb5e0477 Mon Sep 17 00:00:00 2001 +From 0330cf125621b330638b4ecb80560a26fc409200 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 21 Jul 2018 14:27:34 -0400 Subject: [PATCH] Duplicate UUID Resolve Option @@ -196,7 +196,7 @@ index 6379d2d84f..67d011745f 100644 if (list != null) { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 51f697b2c9..e474237c24 100644 +index 82c3bc60d0..a6d0635ec1 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -2,6 +2,8 @@ package net.minecraft.server; @@ -208,7 +208,7 @@ index 51f697b2c9..e474237c24 100644 import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Queues; -@@ -988,8 +990,23 @@ public class WorldServer extends World { +@@ -1002,8 +1004,23 @@ public class WorldServer extends World { if (entity1 == null) { return false; } else { @@ -234,7 +234,7 @@ index 51f697b2c9..e474237c24 100644 return true; } } -@@ -1122,7 +1139,7 @@ public class WorldServer extends World { +@@ -1136,7 +1153,7 @@ public class WorldServer extends World { } Entity old = this.entitiesByUUID.put(entity.getUniqueID(), entity); diff --git a/Spigot-Server-Patches/0387-Configurable-Keep-Spawn-Loaded-range-per-world.patch b/Spigot-Server-Patches/0387-Configurable-Keep-Spawn-Loaded-range-per-world.patch index 97bc9a870a..19ac8fba20 100644 --- a/Spigot-Server-Patches/0387-Configurable-Keep-Spawn-Loaded-range-per-world.patch +++ b/Spigot-Server-Patches/0387-Configurable-Keep-Spawn-Loaded-range-per-world.patch @@ -1,4 +1,4 @@ -From 4848ceac96873ad5395abff0990c6e1238496749 Mon Sep 17 00:00:00 2001 +From e7c28cec58c772e07bd9ddb778afd32f1c9c41c5 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 13 Sep 2014 23:14:43 -0400 Subject: [PATCH] Configurable Keep Spawn Loaded range per world @@ -103,10 +103,10 @@ index 3868572aed..ae77805f71 100644 @Override public void a(ChunkCoordIntPair chunkcoordintpair) { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index e474237c24..1003ea50d3 100644 +index a6d0635ec1..8ac49d8b91 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -1499,13 +1499,85 @@ public class WorldServer extends World { +@@ -1513,13 +1513,85 @@ public class WorldServer extends World { return ((PersistentIdCounts) this.getMinecraftServer().getWorldServer(DimensionManager.OVERWORLD).getWorldPersistentData().a(PersistentIdCounts::new, "idcounts")).a(); } diff --git a/Spigot-Server-Patches/0404-Mark-entities-as-being-ticked-when-notifying-navigat.patch b/Spigot-Server-Patches/0404-Mark-entities-as-being-ticked-when-notifying-navigat.patch index 70926cefc8..24f64d14ff 100644 --- a/Spigot-Server-Patches/0404-Mark-entities-as-being-ticked-when-notifying-navigat.patch +++ b/Spigot-Server-Patches/0404-Mark-entities-as-being-ticked-when-notifying-navigat.patch @@ -1,14 +1,14 @@ -From 57c0b62fe62dee94a1677e7882991f2f86b3536e Mon Sep 17 00:00:00 2001 +From c9ebdc9e0b94a5c9a4f56cd940ce9c99ac7230e5 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sun, 28 Jul 2019 00:51:11 +0100 Subject: [PATCH] Mark entities as being ticked when notifying navigation diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 7faa5dd84a..451ad4f32b 100644 +index 1e5b15c2e2..84c16e2750 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -1311,6 +1311,7 @@ public class WorldServer extends World { +@@ -1325,6 +1325,7 @@ public class WorldServer extends World { VoxelShape voxelshape1 = iblockdata1.getCollisionShape(this, blockposition); if (VoxelShapes.c(voxelshape, voxelshape1, OperatorBoolean.NOT_SAME)) { @@ -16,7 +16,7 @@ index 7faa5dd84a..451ad4f32b 100644 Iterator iterator = this.H.iterator(); while (iterator.hasNext()) { -@@ -1321,6 +1322,7 @@ public class WorldServer extends World { +@@ -1335,6 +1336,7 @@ public class WorldServer extends World { } }