Remove wall-time / unused skip tick protection (#11412)

Spigot still maintains some partial implementation of "tick skipping", a
practice in which the MinecraftServer.currentTick field is updated not
by an increment of one per actual tick, but instead set to
System.currentTimeMillis() / 50. This behaviour means that the tracked
tick may "skip" a tick value in case a previous tick took more than the
expected 50ms.

To compensate for this in important paths, spigot/craftbukkit
implements "wall-time". Instead of incrementing/decrementing ticks on
block entities/entities by one for each call to their tick() method,
they instead increment/decrement important values, like
an ItemEntity's age or pickupDelay, by the difference of
`currentTick - lastTick`, where `lastTick` is the value of
`currentTick` during the last tick() call.

These "fixes" however do not play nicely with minecraft's simulation
distance as entities/block entities implementing the above behaviour
would "catch up" their values when moving from a non-ticking chunk to a
ticking one as their `lastTick` value remains stuck on the last tick in
a ticking chunk and hence lead to a large "catch up" once ticked again.

Paper completely removes the "tick skipping" behaviour (See patch
"Further-improve-server-tick-loop"), making the above precautions
completely unnecessary, which also rids paper of the previous described
incompatibility with non-ticking chunks.
This commit is contained in:
Bjarne Koll 2024-09-19 16:36:07 +02:00 committed by GitHub
parent 5c82955733
commit c5a10665b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
794 changed files with 402 additions and 282 deletions

View file

@ -260,7 +260,7 @@ index 8323f135d6bf2e1f12525e05094ffa3f2420e7e1..a143ea1e58464a3122fbd8ccafe417bd
}
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index e0b2d474e8d6f2d573d2c1f63e68ba931ecf4eb6..91800791427e9362baf68ca3cffda5bfa58de2b8 100644
index 387552877ac82baa3af0da723dbb7c331fad6cf4..b334cfc9b98d96f9bfba1d5b14c03c336d30ff23 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -154,7 +154,7 @@ import com.mojang.serialization.Dynamic;
@ -280,7 +280,7 @@ index e0b2d474e8d6f2d573d2c1f63e68ba931ecf4eb6..91800791427e9362baf68ca3cffda5bf
public static int currentTick = (int) (System.currentTimeMillis() / 50);
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
public int autosavePeriod;
@@ -384,7 +383,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -383,7 +382,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.options = options;
this.worldLoader = worldLoader;
this.vanillaCommandDispatcher = worldstem.dataPackResources().commands; // CraftBukkit
@ -290,7 +290,7 @@ index e0b2d474e8d6f2d573d2c1f63e68ba931ecf4eb6..91800791427e9362baf68ca3cffda5bf
if (System.console() == null && System.getProperty("jline.terminal") == null) {
System.setProperty("jline.terminal", "jline.UnsupportedTerminal");
Main.useJline = false;
@@ -405,6 +406,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -404,6 +405,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
MinecraftServer.LOGGER.warn((String) null, ex);
}
}
@ -299,7 +299,7 @@ index e0b2d474e8d6f2d573d2c1f63e68ba931ecf4eb6..91800791427e9362baf68ca3cffda5bf
Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
// CraftBukkit end
this.paperConfigurations = services.paperConfigurations(); // Paper - add paper configuration files
@@ -1120,7 +1123,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1118,7 +1121,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
org.spigotmc.WatchdogThread.doStop(); // Spigot
// CraftBukkit start - Restore terminal to original settings
try {
@ -308,7 +308,7 @@ index e0b2d474e8d6f2d573d2c1f63e68ba931ecf4eb6..91800791427e9362baf68ca3cffda5bf
} catch (Exception ignored) {
}
// CraftBukkit end
@@ -1658,7 +1661,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1656,7 +1659,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@Override
public void sendSystemMessage(Component message) {
@ -396,7 +396,7 @@ index e9109526880159e2341cc97b53939ba2bcfaeaf9..9dcfcea63f57f45a5584bb80c34fe445
this.bans = new UserBanList(PlayerList.USERBANLIST_FILE);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index bec1fdabbc3727c1f7297b2d23914a5179f4adcb..17df1085e29429b202a6f9003343b15b15e2f8f7 100644
index ee0fbba1ae29bb809303ccc09f64d48c54d426cb..c6cc48c955f052d8f98e3b28c80910b299467480 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -43,7 +43,7 @@ import java.util.logging.Level;