diff --git a/Spigot-Server-Patches/Add-some-Debug-to-Chunk-Entity-slices.patch b/Spigot-Server-Patches/Add-some-Debug-to-Chunk-Entity-slices.patch index f3f25ad3b..19ff418b2 100644 --- a/Spigot-Server-Patches/Add-some-Debug-to-Chunk-Entity-slices.patch +++ b/Spigot-Server-Patches/Add-some-Debug-to-Chunk-Entity-slices.patch @@ -9,7 +9,7 @@ This should hopefully avoid duplicate entities ever being created if the entity was to end up in 2 different chunk slices diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 67e2158ca..e510940ab 100644 +index 67e2158ca1..17f19219f2 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { @@ -21,13 +21,14 @@ index 67e2158ca..e510940ab 100644 // Paper start + List entitySlice = this.entitySlices[k]; + boolean inThis = entitySlice.contains(entity); -+ if (entity.entitySlice != null || inThis) { -+ if (entity.entitySlice == entitySlice || inThis) { -+ LogManager.getLogger().warn(entity + " was already in this chunk section! Report this to https://github.com/PaperMC/Paper/issues/1223"); ++ List currentSlice = entity.entitySlice; ++ if ((currentSlice != null && currentSlice.contains(entity)) || inThis) { ++ if (currentSlice == entitySlice || inThis) { ++ LogManager.getLogger().warn(entity + " was already in this chunk section! Report this to https://github.com/PaperMC/Paper/issues/1302"); + new Throwable().printStackTrace(); + return; + } else { -+ LogManager.getLogger().warn(entity + " is still in another ChunkSection! Report this to https://github.com/PaperMC/Paper/issues/1223"); ++ LogManager.getLogger().warn(entity + " is still in another ChunkSection! Report this to https://github.com/PaperMC/Paper/issues/1302"); + + Chunk chunk = entity.getCurrentChunk(); + if (chunk != null) { @@ -48,15 +49,18 @@ index 67e2158ca..e510940ab 100644 if (entity instanceof EntityItem) { itemCounts[k]++; @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { - if (!this.entitySlices[i].remove(entity)) { - return; + i = this.entitySlices.length - 1; } + // Paper start +- if (!this.entitySlices[i].remove(entity)) { +- return; + if (entitySlices[i] == entity.entitySlice) { + entity.entitySlice = null; + } else { -+ LogManager.getLogger().warn(entity + " was removed from a entitySlice we did not expect. Report this to https://github.com/PaperMC/Paper/issues/1223"); ++ LogManager.getLogger().warn(entity + " was removed from a entitySlice we did not expect. Report this to https://github.com/PaperMC/Paper/issues/1302"); + new Throwable().printStackTrace(); -+ } + } ++ if (!this.entitySlices[i].remove(entity)) { return; } this.markDirty(); if (entity instanceof EntityItem) { itemCounts[i]--; @@ -69,14 +73,14 @@ index 67e2158ca..e510940ab 100644 // Do not pass along players, as doing so can get them stuck outside of time. // (which for example disables inventory icon updates and prevents block breaking) diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 4315804dd..785c31089 100644 +index 4315804ddb..166abea704 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke } } }; -+ Object entitySlice = null; ++ List entitySlice = null; // Paper end static boolean isLevelAtLeast(NBTTagCompound tag, int level) { return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; diff --git a/Spigot-Server-Patches/Entity-add-to-world-fixes.patch b/Spigot-Server-Patches/Entity-add-to-world-fixes.patch index 3d899fa21..0f80543ed 100644 --- a/Spigot-Server-Patches/Entity-add-to-world-fixes.patch +++ b/Spigot-Server-Patches/Entity-add-to-world-fixes.patch @@ -14,7 +14,7 @@ Fix this by differing entity add to world for all entities at the same time the original entity is dead, overwrite it as the logic does for unloaod queued entities. diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index e510940ab..db8fbc006 100644 +index 17f19219f2..bb193966b8 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { @@ -41,7 +41,7 @@ index e510940ab..db8fbc006 100644 // CraftBukkit start org.bukkit.Server server = this.world.getServer(); diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index b0053e5e6..004c3ec47 100644 +index b0053e5e63..004c3ec474 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose @@ -70,7 +70,7 @@ index b0053e5e6..004c3ec47 100644 } this.entityList.add(entity); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 6b5b2c825..f5911fbf0 100644 +index 6b5b2c8258..f5911fbf08 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler {