From 961fe9cd0ea9f648b4c04b2426c5fa63c1ce0110 Mon Sep 17 00:00:00 2001 From: LostLuma Date: Mon, 30 Oct 2023 14:32:41 +0100 Subject: [PATCH] Always run state change checks and tasks on main thread As far as I'm aware this has not caused any issues, but I'd like the implementation to be correct just in case. --- src/main/java/dynamic_fps/impl/DynamicFPSMod.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/dynamic_fps/impl/DynamicFPSMod.java b/src/main/java/dynamic_fps/impl/DynamicFPSMod.java index 8acbdaa0..558b95ac 100644 --- a/src/main/java/dynamic_fps/impl/DynamicFPSMod.java +++ b/src/main/java/dynamic_fps/impl/DynamicFPSMod.java @@ -176,6 +176,15 @@ private static void checkForStateChanges() { minecraft = Minecraft.getInstance(); } + if (minecraft.isSameThread()) { + checkForStateChanges0(); + } else { + // Schedule check for the beginning of the next frame + minecraft.tell(DynamicFPSMod::checkForStateChanges0); + } + } + + private static void checkForStateChanges0() { PowerState current; if (isDisabledInternal()) {