From 722c4f891e90f65e32ae6da46eb43d576dc6b847 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Wed, 25 Sep 2024 04:30:15 -0400 Subject: [PATCH] Improve MC-183518 fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Kobe ⑧ <102713261+HaHaWTH@users.noreply.github.com> --- patches/server/0086-Fix-MC-183518.patch | 52 +++++++++++++++++++------ 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/patches/server/0086-Fix-MC-183518.patch b/patches/server/0086-Fix-MC-183518.patch index 34af35fb3..05a41c29a 100644 --- a/patches/server/0086-Fix-MC-183518.patch +++ b/patches/server/0086-Fix-MC-183518.patch @@ -5,19 +5,47 @@ Subject: [PATCH] Fix-MC-183518 Related MC issue: https://bugs.mojang.com/browse/MC-183518 -diff --git a/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java b/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java -index f22fb84c7e7929d6c80c44b13179cf385d8a43f9..36ee0c16f5958204276057cbe582e8cb35a5296e 100644 ---- a/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java -+++ b/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java -@@ -142,8 +142,9 @@ public abstract class BlockableEventLoop implements Profiler - } +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +index 8f5cc10bbb3d88399358b34253d3e0b540a67c72..cfcc4ab30a03e04f7e4aa0970fbde99910c4d2d2 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -312,6 +312,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop entitiesWithScheduledTasks = java.util.concurrent.ConcurrentHashMap.newKeySet(); // SparklyPaper - skip EntityScheduler's executeTick checks if there isn't any tasks to be run (concurrent because plugins may schedule tasks async) ++ private boolean waitingForNextTick = false; // Leaf - Fix MC-183518 + + public static S spin(Function serverFactory) { + AtomicReference atomicreference = new AtomicReference(); +@@ -1486,9 +1487,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { +- return !this.canSleepForTickNoOversleep(); // Paper - move oversleep into full server tick +- }); + // Leaf start - Fix MC-183518 -+ LockSupport.parkNanos("waiting for tasks", 2000000L); -+ // Leaf end ++ this.waitingForNextTick = true; ++ try { ++ this.managedBlock(() -> { ++ return !this.canSleepForTickNoOversleep(); // Paper - move oversleep into full server tick ++ }); ++ } finally { ++ this.waitingForNextTick = false; ++ } ++ // Leaf end - Fix MC-183518 + lastTickOversleepTime = (System.nanoTime() - tickOversleepStart) / 1000000L; // Gale - YAPFA - last tick time } - protected void doRunTask(R task) { +@@ -1497,7 +1505,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop