From f02b4d200e92d7ff77b684635cb66b00b5df5f03 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 28 Sep 2018 22:39:20 -0400 Subject: [PATCH] Fix issues with entity loss due to unloaded chunks Vanilla has risk of losing entities by causing them to be removed from all chunks if they try to move into an unloaded chunk. This pretty much means high chance this entity will be lost in this scenario. There is another case that adding an entity to the world can fail if the chunk isn't loaded. Lots of the server is designed around addEntity never expecting to fail for these reasons, nor is it really logical. This change ensures the chunks are always loaded when entities are added to the world, or a valid entity moves between chunks. Hopefully will fix issues #1496 and #1434 --- ...h-entity-loss-due-to-unloaded-chunks.patch | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Spigot-Server-Patches/0381-Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch diff --git a/Spigot-Server-Patches/0381-Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch b/Spigot-Server-Patches/0381-Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch new file mode 100644 index 000000000..04c7f75a5 --- /dev/null +++ b/Spigot-Server-Patches/0381-Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch @@ -0,0 +1,44 @@ +From e37fa915dcd5af6254627ba1f05d5afe9692ee9b 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 + +Vanilla has risk of losing entities by causing them to be +removed from all chunks if they try to move into an unloaded chunk. + +This pretty much means high chance this entity will be lost in this scenario. + +There is another case that adding an entity to the world can fail if +the chunk isn't loaded. + +Lots of the server is designed around addEntity never expecting to fail for these reasons, +nor is it really logical. + +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/World.java b/src/main/java/net/minecraft/server/World.java +index 763401835d..3379b68acb 100644 +--- a/src/main/java/net/minecraft/server/World.java ++++ b/src/main/java/net/minecraft/server/World.java +@@ -1145,7 +1145,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc + + int i = MathHelper.floor(entity.locX / 16.0D); + int j = MathHelper.floor(entity.locZ / 16.0D); +- boolean flag = entity.attachedToPlayer; ++ boolean flag = true; // Paper - always load chunks for entity adds + + // Paper start - Set origin location when the entity is being added to the world + if (entity.origin == null) { +@@ -1649,7 +1649,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc + this.getChunkAt(entity.ae, entity.ag).a(entity, entity.af); + } + +- if (!entity.bN() && !this.isChunkLoaded(i, k, true)) { ++ if (!entity.valid && !entity.bN() && !this.isChunkLoaded(i, k, true)) { // Paper - always load chunks to register valid entities location + entity.inChunk = false; + } else { + this.getChunkAt(i, k).a(entity); +-- +2.19.0 +