diff --git a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java index 17bec1ddc..116d38886 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java @@ -1,6 +1,8 @@ package com.seibel.distanthorizons.common; +import com.seibel.distanthorizons.api.enums.config.EDhApiMcRenderingFadeMode; import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi; +import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent; import com.seibel.distanthorizons.common.commands.CommandInitializer; @@ -101,6 +103,7 @@ public abstract class AbstractModInitializer // Client uses config for auto-updater, so it's initialized here instead of post-init stage this.initConfig(); logIncompatibilityWarnings(); // needs to be called after config loading + setUnsupportedConfigsBasedOnMcVersion(); Initializer.postConfigInit(); LOGGER.info(ModInfo.READABLE_NAME + " client Initialized."); @@ -409,6 +412,24 @@ public abstract class AbstractModInitializer } + /** + * Some Minecraft versions don't support all + * DH options. + * In that case we need to override what options are available. + */ + private static void setUnsupportedConfigsBasedOnMcVersion() + { + + #if MC_VER <= MC_1_12_2 + Config.Client.Advanced.Graphics.Experimental.renderingApi.setMcVersionOverrideValue(EDhApiRenderApi.OPEN_GL); + Config.Client.Advanced.Graphics.Quality.vanillaFadeMode.setMcVersionOverrideValue(EDhApiMcRenderingFadeMode.NONE); + Config.Common.WorldGenerator.distantGeneratorMode.setMcVersionOverrideValue(EDhApiDistantGeneratorMode.INTERNAL_SERVER); + #elif MC_VER <= MC_1_21_10 + Config.Client.Advanced.Graphics.Experimental.renderingApi.setMcVersionOverrideValue(EDhApiRenderApi.OPEN_GL); + #else + #endif + } + //endregion diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java index 073b6b242..51540f0d6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java @@ -565,6 +565,7 @@ class DhConfigScreen extends DhScreen { configEntry.uiSetWithoutSaving(configEntry.getDefaultValue()); this.reload = true; + #if MC_VER <= MC_1_12_2 Objects.requireNonNull(this.mc).displayGuiScreen(ClassicConfigGUI.getScreen(this.parent, this.category)); #else @@ -587,7 +588,18 @@ class DhConfigScreen extends DhScreen ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_HEIGHT, btnAction); - if (configEntry.apiIsOverriding()) + + if (configEntry.mcVersionOverridePresent()) + { + #if MC_VER <= MC_1_12_2 + resetButton.enabled = false; + resetButton.displayString = Translatable("distanthorizons.general.unsupportedMcVersion").setStyle(new Style().setColor(TextFormatting.DARK_GRAY)).getFormattedText(); + #else + resetButton.active = false; + resetButton.setMessage(Translatable("distanthorizons.general.unsupportedMcVersion").withStyle(ChatFormatting.DARK_GRAY)); + #endif + } + else if (configEntry.apiIsOverriding()) { #if MC_VER <= MC_1_12_2 resetButton.enabled = false; @@ -599,7 +611,11 @@ class DhConfigScreen extends DhScreen } else { - resetButton.#if MC_VER <= MC_1_12_2 enabled #else active #endif = true; + #if MC_VER <= MC_1_12_2 + resetButton.enabled = true; + #else + resetButton.active = true; + #endif } //endregion @@ -648,12 +664,20 @@ class DhConfigScreen extends DhScreen ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, widget.getKey()); + // deactivate the button if the API is overriding it - #if MC_VER <= MC_1_12_2 - button.enabled = !configEntry.apiIsOverriding(); - #else - button.active = !configEntry.apiIsOverriding(); - #endif + // or the MC version doesn't support it + if (configEntry.mcVersionOverridePresent() + || configEntry.apiIsOverriding()) + { + #if MC_VER <= MC_1_12_2 + button.enabled = false; + #else + button.active = false; + #endif + } + + this.configListWidget.addButton(this, configEntry, button, @@ -957,14 +981,21 @@ class DhConfigScreen extends DhScreen button.dhConfigType; boolean apiOverrideActive = false; + boolean unsupportedMcVersion = false; if (configBase instanceof ConfigEntry) { apiOverrideActive = ((ConfigEntry) configBase).apiIsOverriding(); + unsupportedMcVersion = ((ConfigEntry) configBase).mcVersionOverridePresent(); } + String key = TRANSLATION_PREFIX + (configBase.category.isEmpty() ? "" : configBase.category + ".") + configBase.getName() + ".@tooltip"; - if (apiOverrideActive) + if (unsupportedMcVersion) + { + key = "distanthorizons.general.unsupportedMcVersion.@tooltip"; + } + else if (apiOverrideActive) { key = "distanthorizons.general.disabledByApi.@tooltip"; } diff --git a/coreSubProjects b/coreSubProjects index e3f586da5..fd3a8f7dd 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit e3f586da5698c8529a249b0214d58bb95f27143d +Subproject commit fd3a8f7ddfb3674d7e9af4b5d40efaad85340320