Merge remote-tracking branch 'origin/main'

This commit is contained in:
Vojtěch Šokala
2026-05-15 18:59:42 +02:00
3 changed files with 61 additions and 9 deletions
@@ -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
@@ -572,6 +572,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
@@ -594,7 +595,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;
@@ -606,7 +618,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
@@ -655,12 +671,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,
@@ -964,14 +988,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";
}