From 4f95a20c5e9d5719ce5958c8de39f76f4409504d Mon Sep 17 00:00:00 2001 From: sciwhiz12 Date: Fri, 17 Jun 2022 15:31:45 +0800 Subject: [PATCH] Change ConfigValue#get() to throw if called before config loaded (#8236) This prevents silent issues where a mod gets the value of the setting before configs are loaded, which means the default value is always returned. As there may be situations where the getting the config setting before configs are loaded is needed, and it is not preferable to hardcode the default value, the original behavior is made available through #getRaw. Implements and closes #7716 * Remove getRaw() method This is effectively replaced with the expression `spec.isLoaded() ? configValue.get() : configValue.getDefault()`. * Remove forceSystemNanoTime config setting As implemented, it never had any effect as any place where the config value would be queried happens before the configs are loaded. --- .../net/minecraft/client/Minecraft.java.patch | 8 ------ .../minecraftforge/common/ForgeConfig.java | 7 ----- .../common/ForgeConfigSpec.java | 28 +++++++++++++++++++ 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 5b0c81c6da..984363caae 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -26,14 +26,6 @@ this.f_91033_ = p_91084_.f_101908_.f_101926_; this.f_91034_ = !p_91084_.f_101908_.f_101929_; this.f_91035_ = !p_91084_.f_101908_.f_101930_; -@@ -426,6 +_,7 @@ - } - - Util.f_137440_ = RenderSystem.m_69576_(); -+ if (net.minecraftforge.common.ForgeConfig.CLIENT.forceSystemNanoTime.get()) Util.f_137440_ = System::nanoTime; - this.f_90989_ = new VirtualScreen(this); - this.f_90990_ = this.f_90989_.m_110872_(displaydata, this.f_91066_.f_92123_, this.m_91270_()); - this.m_7440_(true); @@ -445,7 +_,6 @@ this.f_90990_.m_85380_(this.f_91066_.m_232035_().m_231551_()); diff --git a/src/main/java/net/minecraftforge/common/ForgeConfig.java b/src/main/java/net/minecraftforge/common/ForgeConfig.java index fc9663d6dd..cafabcb8f1 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfig.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfig.java @@ -126,8 +126,6 @@ public class ForgeConfig { public final BooleanValue useCombinedDepthStencilAttachment; - public final BooleanValue forceSystemNanoTime; - Client(ForgeConfigSpec.Builder builder) { builder.comment("Client only settings, mostly things related to rendering") .push("client"); @@ -154,11 +152,6 @@ public class ForgeConfig { .translation("forge.configgui.useCombinedDepthStencilAttachment") .define("useCombinedDepthStencilAttachment", false); - forceSystemNanoTime = builder - .comment("Forces the use of System.nanoTime instead of glfwGetTime, as the main Util time provider") - .translation("forge.configgui.forceSystemNanoTime") - .define("forceSystemNanoTime", false); - builder.pop(); } } diff --git a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java index 37450f7fc7..935747c003 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java @@ -834,9 +834,29 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper