2020-05-02 00:03:47 +02:00
|
|
|
From b8287f99f5ee5e93683367ffa43fdd4fe1e48f1f Mon Sep 17 00:00:00 2001
|
2019-05-18 07:01:44 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
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/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
2020-05-02 00:03:47 +02:00
|
|
|
index f7a1fad9c1..e34ea3d098 100644
|
2019-05-18 07:01:44 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
2020-03-19 07:03:32 +01:00
|
|
|
@@ -707,7 +707,7 @@ public class WorldServer extends World {
|
2019-05-18 07:01:44 +02:00
|
|
|
this.getChunkAt(entity.chunkX, entity.chunkZ).a(entity, entity.chunkY);
|
|
|
|
}
|
|
|
|
|
2019-12-12 17:20:43 +01:00
|
|
|
- if (!entity.cc() && !this.isChunkLoaded(i, k)) {
|
|
|
|
+ if (!entity.valid && !entity.cc() && !this.isChunkLoaded(i, k)) { // Paper - always load chunks to register valid entities location
|
2019-05-18 07:01:44 +02:00
|
|
|
entity.inChunk = false;
|
|
|
|
} else {
|
|
|
|
this.getChunkAt(i, k).a(entity);
|
2020-03-19 07:03:32 +01:00
|
|
|
@@ -1033,7 +1033,7 @@ public class WorldServer extends World {
|
2019-05-18 07:01:44 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2019-12-12 17:20:43 +01:00
|
|
|
- IChunkAccess ichunkaccess = this.getChunkAt(MathHelper.floor(entity.locX() / 16.0D), MathHelper.floor(entity.locZ() / 16.0D), ChunkStatus.FULL, entity.attachedToPlayer);
|
|
|
|
+ IChunkAccess ichunkaccess = this.getChunkAt(MathHelper.floor(entity.locX() / 16.0D), MathHelper.floor(entity.locZ() / 16.0D), ChunkStatus.FULL, true); // Paper - always load chunks for entity adds
|
2019-05-18 07:01:44 +02:00
|
|
|
|
|
|
|
if (!(ichunkaccess instanceof Chunk)) {
|
|
|
|
return false;
|
|
|
|
--
|
2020-05-02 00:03:47 +02:00
|
|
|
2.26.2
|
2019-05-18 07:01:44 +02:00
|
|
|
|