From 9ff1015d19e5ef57be5af088bc16f8734b732d04 Mon Sep 17 00:00:00 2001 From: TotallyNotOndre <40639199+TotallyNotOndre@users.noreply.github.com> Date: Fri, 31 Jan 2025 21:18:09 +0200 Subject: [PATCH] Fix shadow render distance reset to 32 (#856) --- .../net/coderbot/iris/config/IrisConfig.java | 18 +++++++++--------- .../iris/gui/option/IrisVideoSettings.java | 4 ++-- .../coderbot/iris/pipeline/ShadowRenderer.java | 5 +++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/net/coderbot/iris/config/IrisConfig.java b/src/main/java/net/coderbot/iris/config/IrisConfig.java index 251ef35f8..86b2c8b26 100644 --- a/src/main/java/net/coderbot/iris/config/IrisConfig.java +++ b/src/main/java/net/coderbot/iris/config/IrisConfig.java @@ -1,6 +1,7 @@ package net.coderbot.iris.config; import net.coderbot.iris.Iris; +import net.coderbot.iris.gui.option.IrisVideoSettings; import java.io.IOException; import java.io.InputStream; @@ -122,13 +123,13 @@ public void load() throws IOException { enableShaders = !"false".equals(properties.getProperty("enableShaders")); disableUpdateMessage = "true".equals(properties.getProperty("disableUpdateMessage")); // TODO: GUI -// try { -// IrisVideoSettings.shadowDistance = Integer.parseInt(properties.getProperty("maxShadowRenderDistance", "32")); -// } catch (NumberFormatException e) { -// Iris.logger.error("Shadow distance setting reset; value is invalid."); -// IrisVideoSettings.shadowDistance = 32; -// save(); -// } + try { + IrisVideoSettings.shadowDistance = Integer.parseInt(properties.getProperty("maxShadowRenderDistance", "32")); + } catch (NumberFormatException e) { + Iris.logger.error("Shadow distance setting reset; value is invalid."); + IrisVideoSettings.shadowDistance = 32; + save(); + } if (shaderPackName != null) { if (shaderPackName.equals("(internal)") || shaderPackName.isEmpty()) { @@ -147,8 +148,7 @@ public void save() throws IOException { properties.setProperty("shaderPack", getShaderPackName().orElse("")); properties.setProperty("enableShaders", enableShaders ? "true" : "false"); properties.setProperty("disableUpdateMessage", disableUpdateMessage ? "true" : "false"); -// properties.setProperty("maxShadowRenderDistance", String.valueOf(IrisVideoSettings.shadowDistance)); - properties.setProperty("maxShadowRenderDistance", String.valueOf(32)); + properties.setProperty("maxShadowRenderDistance", String.valueOf(IrisVideoSettings.shadowDistance)); // NB: This uses ISO-8859-1 with unicode escapes as the encoding try (OutputStream os = Files.newOutputStream(propertiesPath)) { properties.store(os, COMMENT); diff --git a/src/main/java/net/coderbot/iris/gui/option/IrisVideoSettings.java b/src/main/java/net/coderbot/iris/gui/option/IrisVideoSettings.java index 8337106fc..756207549 100644 --- a/src/main/java/net/coderbot/iris/gui/option/IrisVideoSettings.java +++ b/src/main/java/net/coderbot/iris/gui/option/IrisVideoSettings.java @@ -11,8 +11,8 @@ public class IrisVideoSettings { public static int shadowDistance = 32; // TODO: Tell the user to check in the shader options once that's supported. - private static final String DISABLED_TOOLTIP = I18n.format("options.iris.shadowDistance.disabled"); - private static final String ENABLED_TOOLTIP = I18n.format("options.iris.shadowDistance.enabled"); + // private static final String DISABLED_TOOLTIP = I18n.format("options.iris.shadowDistance.disabled"); + // private static final String ENABLED_TOOLTIP = I18n.format("options.iris.shadowDistance.enabled"); public static int getOverriddenShadowDistance(int base) { return Iris.getPipelineManager().getPipeline() diff --git a/src/main/java/net/coderbot/iris/pipeline/ShadowRenderer.java b/src/main/java/net/coderbot/iris/pipeline/ShadowRenderer.java index 798dd603e..1226733c5 100644 --- a/src/main/java/net/coderbot/iris/pipeline/ShadowRenderer.java +++ b/src/main/java/net/coderbot/iris/pipeline/ShadowRenderer.java @@ -14,6 +14,7 @@ import java.util.Objects; import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer; import net.coderbot.iris.Iris; +import net.coderbot.iris.gui.option.IrisVideoSettings; import net.coderbot.iris.shaderpack.OptionalBoolean; import net.coderbot.iris.shaderpack.PackDirectives; import net.coderbot.iris.shaderpack.PackShadowDirectives; @@ -284,8 +285,8 @@ private FrustumHolder createShadowFrustum(float renderMultiplier, FrustumHolder if (renderMultiplier < 0) { // TODO: GUI -// distance = IrisVideoSettings.shadowDistance * 16; - distance = 32 * 16; + distance = IrisVideoSettings.shadowDistance * 16; // can be zero :( + //distance = 32 * 16; setter = "(set by user)"; }