Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
fix: Fix error due to shaderpack presets
Browse files Browse the repository at this point in the history
Also fixed the saturation multiplier pointing towards the brightness multiplier in Blendium's config.
  • Loading branch information
Steveplays28 committed Nov 19, 2023
1 parent 36b7243 commit 115556e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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";
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.*;
Expand All @@ -13,6 +13,6 @@ public static void onReload() {
return;
}

applyDhShaderpackPreset(Iris.getCurrentPackName());
applyDhShaderpackPreset(BlendiumDhShaderpackPresets.getShaderpackName());
}
}

0 comments on commit 115556e

Please sign in to comment.