From 115556e78f2c1e3b29ebf949a7801473cd5211a4 Mon Sep 17 00:00:00 2001 From: Steveplays28 Date: Sun, 19 Nov 2023 23:16:00 +0100 Subject: [PATCH] fix: Fix error due to shaderpack presets Also fixed the saturation multiplier pointing towards the brightness multiplier in Blendium's config. --- .../steveplays28/blendium/client/BlendiumClient.java | 11 +++++++++++ .../BlendiumAfterDhInitEventHandler.java | 6 ------ .../compat/iris/BlendiumDhShaderpackPresets.java | 2 +- .../config/BlendiumConfigOnLoadEventHandler.java | 4 ++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/github/steveplays28/blendium/client/BlendiumClient.java b/src/main/java/io/github/steveplays28/blendium/client/BlendiumClient.java index fe34228..c64ab42 100644 --- a/src/main/java/io/github/steveplays28/blendium/client/BlendiumClient.java +++ b/src/main/java/io/github/steveplays28/blendium/client/BlendiumClient.java @@ -3,6 +3,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import io.github.steveplays28.blendium.client.command.BlendiumReloadCommand; import io.github.steveplays28.blendium.client.compat.distanthorizons.BlendiumDhRegistry; +import io.github.steveplays28.blendium.client.compat.iris.BlendiumDhShaderpackPresets; import io.github.steveplays28.blendium.client.config.BlendiumConfigLoader; import io.github.steveplays28.blendium.client.config.BlendiumConfigOnLoadEventHandler; import io.github.steveplays28.blendium.client.config.user.BlendiumConfig; @@ -11,6 +12,7 @@ import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.fabricmc.loader.api.FabricLoader; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; @@ -19,6 +21,8 @@ import java.nio.file.Path; import java.util.List; +import static io.github.steveplays28.blendium.client.compat.iris.BlendiumDhShaderpackPresets.applyDhShaderpackPreset; + @Environment(EnvType.CLIENT) public class BlendiumClient implements ClientModInitializer { public static final String MOD_ID = "blendium"; @@ -47,6 +51,13 @@ public void onInitializeClient() { IRIS_SHADERS_MOD_ID)) { BlendiumDhRegistry.register(); } + + ClientLifecycleEvents.CLIENT_STARTED.register(client -> { + if (FabricLoader.getInstance().isModLoaded(DISTANT_HORIZONS_MOD_ID) && FabricLoader.getInstance().isModLoaded( + IRIS_SHADERS_MOD_ID)) { + applyDhShaderpackPreset(BlendiumDhShaderpackPresets.getShaderpackName()); + } + }); } public static void reloadConfig() { diff --git a/src/main/java/io/github/steveplays28/blendium/client/compat/distanthorizons/BlendiumAfterDhInitEventHandler.java b/src/main/java/io/github/steveplays28/blendium/client/compat/distanthorizons/BlendiumAfterDhInitEventHandler.java index 0978e7d..9a25d82 100644 --- a/src/main/java/io/github/steveplays28/blendium/client/compat/distanthorizons/BlendiumAfterDhInitEventHandler.java +++ b/src/main/java/io/github/steveplays28/blendium/client/compat/distanthorizons/BlendiumAfterDhInitEventHandler.java @@ -4,19 +4,13 @@ import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent; import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam; import io.github.steveplays28.blendium.client.compat.iris.BlendiumDhShaderpackPresets; -import net.fabricmc.loader.api.FabricLoader; import static io.github.steveplays28.blendium.client.BlendiumClient.*; -import static io.github.steveplays28.blendium.client.compat.iris.BlendiumDhShaderpackPresets.applyDhShaderpackPreset; // TODO: Maybe reset the LOD shaderpack presets when unloading the game, in case Iris gets disabled/removed public class BlendiumAfterDhInitEventHandler extends DhApiAfterDhInitEvent { @Override public void afterDistantHorizonsInit(DhApiEventParam input) { - if (FabricLoader.getInstance().isModLoaded(IRIS_SHADERS_MOD_ID)) { - applyDhShaderpackPreset(BlendiumDhShaderpackPresets.getShaderpackName()); - } - DhApi.Delayed.configs.graphics().brightnessMultiplier().addChangeListener(this::onBrightnessMultiplierChanged); DhApi.Delayed.configs.graphics().saturationMultiplier().addChangeListener(this::onSaturationMultiplierChanged); } diff --git a/src/main/java/io/github/steveplays28/blendium/client/compat/iris/BlendiumDhShaderpackPresets.java b/src/main/java/io/github/steveplays28/blendium/client/compat/iris/BlendiumDhShaderpackPresets.java index f3032f0..fe9853e 100644 --- a/src/main/java/io/github/steveplays28/blendium/client/compat/iris/BlendiumDhShaderpackPresets.java +++ b/src/main/java/io/github/steveplays28/blendium/client/compat/iris/BlendiumDhShaderpackPresets.java @@ -43,7 +43,7 @@ public static void applyDhShaderpackPreset(String shaderpackName) { // Apply DH LOD saturation from the shaderpack preset var shaderpackSaturationMultiplier = BlendiumConfigLoader.BlendiumConfigurations.CONFIG.shaderpackSaturationMultipliers.getOrDefault( shaderpackName, 1d); - DhApi.Delayed.configs.graphics().brightnessMultiplier().setValue(shaderpackSaturationMultiplier); + DhApi.Delayed.configs.graphics().saturationMultiplier().setValue(shaderpackSaturationMultiplier); BlendiumClient.LOGGER.info("Applied shaderpack preset for {}.", shaderpackName); } diff --git a/src/main/java/io/github/steveplays28/blendium/client/config/BlendiumConfigOnLoadEventHandler.java b/src/main/java/io/github/steveplays28/blendium/client/config/BlendiumConfigOnLoadEventHandler.java index 65def23..7b88a95 100644 --- a/src/main/java/io/github/steveplays28/blendium/client/config/BlendiumConfigOnLoadEventHandler.java +++ b/src/main/java/io/github/steveplays28/blendium/client/config/BlendiumConfigOnLoadEventHandler.java @@ -1,6 +1,6 @@ package io.github.steveplays28.blendium.client.config; -import net.coderbot.iris.Iris; +import io.github.steveplays28.blendium.client.compat.iris.BlendiumDhShaderpackPresets; import net.fabricmc.loader.api.FabricLoader; import static io.github.steveplays28.blendium.client.BlendiumClient.*; @@ -13,6 +13,6 @@ public static void onReload() { return; } - applyDhShaderpackPreset(Iris.getCurrentPackName()); + applyDhShaderpackPreset(BlendiumDhShaderpackPresets.getShaderpackName()); } }