mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-06 15:51:31 +00:00
[ci skip] Format patches
This commit is contained in:
51
patches/server/0096-Fix-MC-183518.patch
Normal file
51
patches/server/0096-Fix-MC-183518.patch
Normal file
@@ -0,0 +1,51 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Fri, 14 Jun 2024 17:34:17 -0400
|
||||
Subject: [PATCH] Fix-MC-183518
|
||||
|
||||
Related MC issue: https://bugs.mojang.com/browse/MC-183518
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 705becd8d234ff6b73c1a1e88d2d0b0633a3479b..37c377761b45eefab39164a7e714e585a02a4447 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<TickTa
|
||||
|
||||
public gg.pufferfish.pufferfish.util.AsyncExecutor mobSpawnExecutor = new gg.pufferfish.pufferfish.util.AsyncExecutor("Leaf Async Mob Spawn Thread"); // Pufferfish - optimize mob spawning // Leaf - Unify thread name
|
||||
public final Set<Entity> 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 extends MinecraftServer> S spin(Function<Thread, S> serverFactory) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
@@ -1495,9 +1496,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
protected void waitUntilNextTick() {
|
||||
long tickOversleepStart = System.nanoTime(); // Gale - YAPFA - last tick time
|
||||
- this.managedBlock(() -> {
|
||||
- return !this.canSleepForTickNoOversleep(); // Paper - move oversleep into full server tick
|
||||
- });
|
||||
+ // Leaf start - Fix MC-183518
|
||||
+ 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
|
||||
}
|
||||
|
||||
@@ -1506,7 +1514,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
boolean flag = this.isTickTimeLoggingEnabled();
|
||||
long i = flag ? Util.getNanos() : 0L;
|
||||
|
||||
- super.waitForTasks();
|
||||
+ // Leaf start - Fix MC-183518
|
||||
+ long ms = this.waitingForNextTick ? this.nextTickTimeNanos - Util.getNanos() : 100_000L;
|
||||
+ java.util.concurrent.locks.LockSupport.parkNanos("waiting for tasks", ms);
|
||||
+ // Leaf end - Fix MC-183518
|
||||
if (flag) {
|
||||
this.idleTimeNanos += Util.getNanos() - i;
|
||||
}
|
||||
Reference in New Issue
Block a user