geforkt von Mirrors/Paper
9dc4d6448b
While it wasn't really "broken" before, if plugins use NMS (which they really should't be) and mess with entity management themselves, and get it wrong, they could ultimately corrupt our state expectations. I've been unable to reproduce any issues locally, but these changes are the result of me analyzing the code pretty deeply and seeing about how to make it more durable to abnormal usage. Any servers seeing oddities, please run with -Ddebug.entities=true and send me any logs triggered.
45 Zeilen
2.0 KiB
Diff
45 Zeilen
2.0 KiB
Diff
From 3c966ef69587e91e36e7b83cc8d175ae73c91dfb Mon Sep 17 00:00:00 2001
|
|
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
|
|
index fb71879ac0..728319968b 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -1081,7 +1081,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) {
|
|
@@ -1577,7 +1577,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
this.getChunkAt(entity.chunkX, entity.chunkZ).a(entity, entity.chunkY);
|
|
}
|
|
|
|
- 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.21.0
|
|
|