aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/1055-Avoid-issues-with-certain-tasks-not-processing-durin.patch
blob: 5a9072964b89bdcfaaf4112904a18d900372a193 (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 497c58f2050966d59e953fce14c589fd9d1b7a75..af2f2a1b6266390e3f334fa8a0b06cb4d0370ce1 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1640,6 +1640,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
 
                 ((io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler) Bukkit.getGlobalRegionScheduler()).tick(); // Folia scheduler API
                 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