geforkt von Mirrors/Paper
c5a10665b8
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.
28 Zeilen
1.5 KiB
Diff
28 Zeilen
1.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Tue, 8 Aug 2023 17:29:33 -0700
|
|
Subject: [PATCH] Fix race condition on UpgradeData.BlockFixers class init
|
|
|
|
The CHUNKY_FIXERS field is modified during the constructors
|
|
of the BlockFixers, but the code that uses CHUNKY_FIXERS does
|
|
not properly ensure that BlockFixers has been initialised before
|
|
using it, leading to a possible race condition where instances of
|
|
BlockFixers are accessed before they have initialised correctly.
|
|
|
|
We can force the class to initialise fully before accessing the
|
|
field by calling any method on the class, and for convenience
|
|
we use values().
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java b/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java
|
|
index 22b6d0851a51da180cd8fbbe6554c5370f5ac5bd..cd9b65f278a750a0177a3252271015d43172b2e9 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java
|
|
@@ -140,6 +140,7 @@ public class UpgradeData {
|
|
Fluid fluid = tick.type() == Fluids.EMPTY ? level.getFluidState(tick.pos()).getType() : tick.type();
|
|
level.scheduleTick(tick.pos(), fluid, tick.delay(), tick.priority());
|
|
});
|
|
+ UpgradeData.BlockFixers.values(); // Paper - force the class init so that we don't access CHUNKY_FIXERS before all BlockFixers are initialised
|
|
CHUNKY_FIXERS.forEach(logic -> logic.processChunk(level));
|
|
}
|
|
|