2018-12-03 00:31:09 +01:00
|
|
|
From 02e6b94c373272fc2104380efa085fba07e0802d Mon Sep 17 00:00:00 2001
|
2018-09-29 04:39:20 +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/World.java b/src/main/java/net/minecraft/server/World.java
|
2018-12-03 00:31:09 +01:00
|
|
|
index 7e7b62b1d..23529954b 100644
|
2018-09-29 04:39:20 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2018-10-07 20:58:53 +02:00
|
|
|
@@ -1147,7 +1147,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-09-29 04:39:20 +02:00
|
|
|
|
|
|
|
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) {
|
2018-10-07 20:58:53 +02:00
|
|
|
@@ -1651,7 +1651,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-09-29 04:39:20 +02:00
|
|
|
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);
|
|
|
|
--
|
2018-10-21 21:27:53 +02:00
|
|
|
2.19.1
|
2018-09-29 04:39:20 +02:00
|
|
|
|