PaperMC/Spigot-Server-Patches/0300-Mark-chunk-dirty-anytime-entities-change-to-guarante.patch
Aikar 9dc4d6448b
Numerous fixes to entity related changes
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.
2019-04-05 23:08:45 -04:00

30 lines
1.1 KiB
Diff

From 5db68f220944c579b43a082c9732005d4e2147f3 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 23 Jul 2018 22:18:31 -0400
Subject: [PATCH] Mark chunk dirty anytime entities change to guarantee it
saves
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index e8c06e01b4..5d187e5d7d 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -718,6 +718,7 @@ public class Chunk implements IChunkAccess {
entity.chunkZ = this.locZ;
this.entitySlices[k].add(entity);
// Paper start
+ this.markDirty();
if (entity instanceof EntityItem) {
itemCounts[k]++;
} else if (entity instanceof IInventory) {
@@ -748,6 +749,7 @@ public class Chunk implements IChunkAccess {
if (!this.entitySlices[i].remove(entity)) {
return;
}
+ this.markDirty();
if (entity instanceof EntityItem) {
itemCounts[i]--;
} else if (entity instanceof IInventory) {
--
2.21.0