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

@ -1553,10 +1553,10 @@ index 0000000000000000000000000000000000000000..badff5d6ae6dd8d209c82bc7e8afe370
+ }
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 91800791427e9362baf68ca3cffda5bfa58de2b8..5a4cdbc4b92a48c614564e4e421f05a9eb5b072b 100644
index b334cfc9b98d96f9bfba1d5b14c03c336d30ff23..e880543e94189fea3ba62eb7fb05ff48bc425299 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -643,6 +643,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -642,6 +642,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD);
@ -1564,7 +1564,7 @@ index 91800791427e9362baf68ca3cffda5bfa58de2b8..5a4cdbc4b92a48c614564e4e421f05a9
this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP));
this.connection.acceptConnections();
}
@@ -916,6 +917,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -915,6 +916,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.server.disablePlugins();
}
// CraftBukkit end
@ -1904,7 +1904,7 @@ index 0000000000000000000000000000000000000000..73b20a92f330311e3fef8f03b51a0985
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index b532c72ec2c048554e496b4b63afa0e9f9932416..7839e34cbd42e1b77c533b0dede42e0a19daf2a4 100644
index 69175337d14e0b14ddbc2a01a1deb860ae488d36..25a03307a576368f417f1ec3f44213ed469dcd71 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1000,6 +1000,7 @@ public final class CraftServer implements Server {