aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/1055-Avoid-issues-with-certain-tasks-not-processing-durin.patch
blob: ed38a062101c65758c6ce52d9aa39daa0777b07b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Sun, 27 Oct 2024 14:18:28 -0700
Subject: [PATCH] Avoid issues with certain tasks not processing during sleep

Execute processQueue tasks during sleep & unload chunks during sleep

diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index af7c6f56444c0e495fd39da872f8030199afc634..7933d6900dac67a24fb5f9378097dbde34be30b1 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1639,6 +1639,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
                 }
 
                 this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit
+                // Paper start - avoid issues with certain tasks not processing during sleep
+                Runnable task;
+                while ((task = this.processQueue.poll()) != null) {
+                    task.run();
+                }
+                for (final ServerLevel level : this.levels.values()) {
+                    // process unloads
+                    level.getChunkSource().tick(() -> true, false);
+                }
+                // Paper end - avoid issues with certain tasks not processing during sleep
                 this.server.spark.executeMainThreadTasks(); // Paper - spark
                 this.tickConnection();
                 this.server.spark.tickEnd(((double)(System.nanoTime() - lastTick) / 1000000D)); // Paper - spark