From b3cf7a6f902bfcbe7ec688a63c5bb6056ad766d3 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Mon, 1 Nov 2021 12:27:59 -0700 Subject: [PATCH] Off-by-one desync --- .../create/foundation/utility/ServerSpeedProvider.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/simibubi/create/foundation/utility/ServerSpeedProvider.java b/src/main/java/com/simibubi/create/foundation/utility/ServerSpeedProvider.java index 28038851a..6bd293794 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ServerSpeedProvider.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ServerSpeedProvider.java @@ -68,7 +68,10 @@ public class ServerSpeedProvider { } float target = ((float) getSyncInterval()) / Math.max(clientTimer, 1); modifier.target(Math.min(target, 1)); - clientTimer = 0; + // Set this to -1 because packets are processed before ticks. + // ServerSpeedProvider#clientTick will increment it to 0 at the end of this tick. + // Setting it to 0 causes consistent desync, as the client ends up counting too many ticks. + clientTimer = -1; }); context.get()