Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Comment thread
ysnt-yes marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ repositories {
dependencies {
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.officialMojangMappings()
forge "net.neoforged:forge:${minecraft_version}-${forge_version}"
forge "net.minecraftforge:forge:${minecraft_version}-${forge_version}"

modImplementation "org.embeddedt:embeddium-${minecraft_version}:${embeddium_version}"
modCompileOnly("maven.modrinth:distanthorizonsapi:3.0.0")
Expand Down Expand Up @@ -172,4 +172,4 @@ publishing {

repositories {
}
}
}
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.jvmargs=-Xmx3G
loom.platform = forge

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
forge_version=47.1.105
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
forge_version=47.1.105

# Mod Properties
mod_version = 1.8.0
maven_group = net.coderbot
archives_base_name = oculus
mod_version = 1.8.1
maven_group = net.coderbot
archives_base_name = oculus

# Dependencies
embeddium_version=0.3.31-beta.53+mc1.20.1
embeddium_version=0.3.31-beta.53+mc1.20.1
2 changes: 1 addition & 1 deletion src/main/java/net/irisshaders/iris/Iris.java
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ public static void onEarlyInitialize() {
logger.warn("", e);
}

irisConfig = new IrisConfig(FMLPaths.CONFIGDIR.get().resolve(MODID + ".properties"));
irisConfig = new IrisConfig(FMLPaths.CONFIGDIR.get().resolve(MODID + ".properties"), FMLPaths.CONFIGDIR.get().resolve("iris-excluded.json"));

try {
irisConfig.initialize();
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/net/irisshaders/iris/compat/SkipList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.irisshaders.iris.compat;

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.util.Map;

public class SkipList {
public static Map<Class<?>, MethodHandle> shouldSkipList = new Object2ObjectOpenHashMap<>();

public static final MethodHandle NONE = MethodHandles.constant(Integer.class, 2);

public static final MethodHandle ALWAYS = MethodHandles.constant(Integer.class, 1);
}
58 changes: 57 additions & 1 deletion src/main/java/net/irisshaders/iris/config/IrisConfig.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
package net.irisshaders.iris.config;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.gui.option.IrisVideoSettings;
import net.irisshaders.iris.pathways.colorspace.ColorSpace;
import net.minecraft.resources.ResourceLocation;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Properties;

Expand All @@ -19,6 +26,7 @@ public class IrisConfig {
private static final String COMMENT =
"This file stores configuration options for Iris, such as the currently active shaderpack";
private final Path propertiesPath;
private final Path excludedPath;
/**
* The path to the current shaderpack. Null if the internal shaderpack is being used.
*/
Expand All @@ -27,21 +35,32 @@ public class IrisConfig {
* Whether or not shaders are used for rendering. False to disable all shader-based rendering, true to enable it.
*/
private boolean enableShaders;
/**
* Whether or not to allow core shaders to draw to the main color texture.
*/
private boolean allowUnknownShaders;
/**
* If debug features should be enabled. Gives much more detailed OpenGL error outputs at the cost of performance.
*/
private boolean enableDebugOptions;
/**
* What shaders should be nuked.
*/
private List<ResourceLocation> shadersToSkip = new ArrayList<>();
/**
* If the update notification should be disabled or not.
*/
private boolean disableUpdateMessage;

public IrisConfig(Path propertiesPath) {
public IrisConfig(Path propertiesPath, Path excluded) {
shaderPackName = null;
enableShaders = true;
enableDebugOptions = false;
disableUpdateMessage = false;
this.propertiesPath = propertiesPath;
allowUnknownShaders = false;
this.excludedPath = excluded;

}

/**
Expand Down Expand Up @@ -113,6 +132,14 @@ public void setShadersEnabled(boolean enabled) {
this.enableShaders = enabled;
}

public void setUnknown(boolean b) throws IOException {
this.allowUnknownShaders = b;
save();
}

private static Gson GSON = new Gson();


/**
* loads the config file and then populates the string, int, and boolean entries with the parsed entries
*
Expand All @@ -124,6 +151,24 @@ public void load() throws IOException {
return;
}

if (Files.exists(excludedPath)) {
JsonArray json = JsonParser.parseString(Files.readString(excludedPath)).getAsJsonObject().getAsJsonArray("excluded");
for (int i = 0; i < json.size(); i++) {
ResourceLocation resource = ResourceLocation.tryParse(json.get(i).getAsString());
if (resource == null) {
Iris.logger.warn("Unknown shader " + json.get(i).getAsString());
}

shadersToSkip.add(resource);
}
} else {
JsonObject defaultV = new JsonObject();
JsonArray array = new JsonArray();
array.add("put:valuesHere");
defaultV.add("excluded", array);
Files.writeString(excludedPath, GSON.toJson(defaultV));
}

Properties properties = new Properties();
// NB: This uses ISO-8859-1 with unicode escapes as the encoding
try (InputStream is = Files.newInputStream(propertiesPath)) {
Expand All @@ -133,6 +178,8 @@ public void load() throws IOException {
enableShaders = !"false".equals(properties.getProperty("enableShaders"));
enableDebugOptions = "true".equals(properties.getProperty("enableDebugOptions"));
disableUpdateMessage = "true".equals(properties.getProperty("disableUpdateMessage"));
allowUnknownShaders = "true".equals(properties.getProperty("allowUnknownShaders"));

try {
IrisVideoSettings.shadowDistance = Integer.parseInt(properties.getProperty("maxShadowRenderDistance", "32"));
IrisVideoSettings.colorSpace = ColorSpace.valueOf(properties.getProperty("colorSpace", "SRGB"));
Expand Down Expand Up @@ -163,9 +210,18 @@ public void save() throws IOException {
properties.setProperty("disableUpdateMessage", disableUpdateMessage ? "true" : "false");
properties.setProperty("maxShadowRenderDistance", String.valueOf(IrisVideoSettings.shadowDistance));
properties.setProperty("colorSpace", IrisVideoSettings.colorSpace.name());
properties.setProperty("allowUnknownShaders", allowUnknownShaders ? "true" : "false");
// NB: This uses ISO-8859-1 with unicode escapes as the encoding
try (OutputStream os = Files.newOutputStream(propertiesPath)) {
properties.store(os, COMMENT);
}
}

public boolean shouldAllowUnknownShaders() {
return allowUnknownShaders;
}

public boolean shouldSkip(ResourceLocation value) {
return shadersToSkip.contains(value); // TODO
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public static ImmutableList<StringPair> createStandardEnvironmentDefines() {
define(standardDefines, "DISTANT_HORIZONS");
}

if (Iris.getIrisConfig().shouldAllowUnknownShaders()) {
define(standardDefines, "ALLOWS_UNKNOWN_SHADERS");
}

define(standardDefines, "DH_BLOCK_UNKNOWN", String.valueOf(0));
define(standardDefines, "DH_BLOCK_LEAVES", String.valueOf(1));
define(standardDefines, "DH_BLOCK_STONE", String.valueOf(2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta)
Component.literal("No")));
}

if (Screen.hasControlDown() && InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_KEY_G)) {
Minecraft.getInstance().setScreen(new ConfirmScreen((option) -> {
try {
Iris.getIrisConfig().setUnknown(option);
} catch (IOException e) {
throw new RuntimeException(e);
}
Minecraft.getInstance().setScreen(this);
}, Component.literal("Unknown shader toggle"),
Component.literal("This allows unknown shaders to load in."),
Component.literal("Enable"),
Component.literal("Disable")));
}

if (!this.guiHidden) {
if (optionMenuOpen && this.shaderOptionList != null) {
this.shaderOptionList.render(guiGraphics, mouseX, mouseY, delta);
Expand Down
Loading