From fd3a8f7ddfb3674d7e9af4b5d40efaad85340320 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Fri, 15 May 2026 07:44:00 -0500 Subject: [PATCH] Add MC Version locking to the config --- .../core/config/types/ConfigEntry.java | 25 ++++++++++++++++++- .../assets/distanthorizons/lang/en_us.json | 5 +++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java index 8d4cb35ca..0243e8a65 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java @@ -55,6 +55,16 @@ public class ConfigEntry extends AbstractConfigBase @Nullable private T apiValue; + /** + * Will be null if un-set.

+ * + * Some options aren't supported on all Minecraft versions, + * in those cases this value will be set to override the + * config file option. + */ + @Nullable + private T mcVersionOverrideValue; + //=============// @@ -127,7 +137,14 @@ public class ConfigEntry extends AbstractConfigBase return this.allowApiOverride && this.apiValue != null; } - + + /** setting to null will allow the config to be used normally */ + public void setMcVersionOverrideValue(@Nullable T value) + { this.mcVersionOverrideValue = value; } + + public boolean mcVersionOverridePresent() + { return this.mcVersionOverrideValue != null; } + /** * Should only be used when loading the config from file.
* Sets the value without informing the rest of the code (ie, it doesn't call listeners, or saving the value to file). @@ -183,6 +200,12 @@ public class ConfigEntry extends AbstractConfigBase @Override public T get() { + // always use the MC version specific option if defined + if (this.mcVersionOverrideValue != null) + { + return this.mcVersionOverrideValue; + } + if (this.allowApiOverride && this.apiValue != null) { diff --git a/core/src/main/resources/assets/distanthorizons/lang/en_us.json b/core/src/main/resources/assets/distanthorizons/lang/en_us.json index 4887d3807..f5ec62ca3 100644 --- a/core/src/main/resources/assets/distanthorizons/lang/en_us.json +++ b/core/src/main/resources/assets/distanthorizons/lang/en_us.json @@ -28,7 +28,10 @@ "API LOCK", "distanthorizons.general.disabledByApi.@tooltip": "This option is controlled by another mod via DH's API \nso it cannot be changed via the UI or config file.", - + "distanthorizons.general.unsupportedMcVersion": + "VER LOCK", + "distanthorizons.general.unsupportedMcVersion.@tooltip": + "DH doesn't support changing this option on this version of Minecraft. \nAny config file or API set values will be ignored.",