Skip to content

Commit

Permalink
Save shadow render distance to configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Sep 3, 2021
1 parent 7131efb commit 4b657e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/net/coderbot/iris/config/IrisConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Properties;

import net.coderbot.iris.Iris;
import net.coderbot.iris.gui.option.IrisVideoSettings;
import net.fabricmc.loader.api.FabricLoader;

/**
Expand Down Expand Up @@ -107,6 +108,7 @@ public void load() throws IOException {
properties.load(Files.newInputStream(propertiesPath));
shaderPackName = properties.getProperty("shaderPack");
enableShaders = !"false".equals(properties.getProperty("enableShaders"));
IrisVideoSettings.shadowDistance = Double.parseDouble(properties.getProperty("shadowRenderDistance", "32.0"));

if (shaderPackName != null) {
if (shaderPackName.equals("(internal)") || shaderPackName.isEmpty()) {
Expand All @@ -124,6 +126,7 @@ public void save() throws IOException {
Properties properties = new Properties();
properties.setProperty("shaderPack", getShaderPackName().orElse(""));
properties.setProperty("enableShaders", enableShaders ? "true" : "false");
properties.setProperty("shadowRenderDistance", String.valueOf(IrisVideoSettings.shadowDistance));
// NB: This uses ISO-8859-1 with unicode escapes as the encoding
properties.store(Files.newOutputStream(propertiesPath), COMMENT);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package net.coderbot.iris.gui.option;

import net.coderbot.iris.Iris;
import net.minecraft.client.options.DoubleOption;
import net.minecraft.text.TranslatableText;

import java.io.IOException;

public class IrisVideoSettings {
public static double shadowDistance = 32.0;

Expand All @@ -13,6 +16,11 @@ public class IrisVideoSettings {
return shadowDistance;
}, (gameOptions, viewDistance) -> {
shadowDistance = viewDistance;
try {
Iris.getIrisConfig().save();
} catch (IOException e) {
e.printStackTrace();
}
}, (gameOptions, option) -> {
double d = option.get(gameOptions);

Expand Down

0 comments on commit 4b657e4

Please sign in to comment.