From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sat, 5 Mar 2022 17:12:52 -0800 Subject: [PATCH] Fix save problems on shutdown - Save level.dat first, in case the shutdown is killed later - Force run minecraftserver tasks and the chunk source tasks while waiting for the chunk system to empty, as there's simply too much trash that could prevent them from executing during the chunk source tick (i.e "time left in tick" logic). - Set forceTicks to true, so that player packets are always processed so that the main process queue can be drained diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index df08b7afcf19ce694a87c25e8589c0c72521c5db..4d920031300a9801debc2eb39a4d3cb9d8fbb330 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -957,6 +957,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { return worldserver1.getChunkSource().chunkMap.hasWork(); })) { @@ -969,9 +976,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { return true; }, false); + while (worldserver.getChunkSource().pollTask()); // Paper - drain tasks } - this.waitUntilNextTick(); + this.forceTicks = true; // Paper + while (this.pollTask()); // Paper - drain tasks } this.saveAllChunks(false, true, false); @@ -1266,6 +1275,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop