use of net.coderbot.iris.config.IrisConfig in project Iris by IrisShaders.
the class Iris method onInitializeClient.
@Override
public void onInitializeClient() {
FabricLoader.getInstance().getModContainer("sodium").ifPresent(modContainer -> {
sodiumInstalled = true;
String versionString = modContainer.getMetadata().getVersion().getFriendlyString();
// nice warning, and prevent them from playing the game with a wrong version of Sodium.
if (!SodiumVersionCheck.isAllowedVersion(versionString)) {
sodiumInvalid = true;
}
});
ModContainer iris = FabricLoader.getInstance().getModContainer(MODID).orElseThrow(() -> new IllegalStateException("Couldn't find the mod container for Iris"));
IRIS_VERSION = iris.getMetadata().getVersion().getFriendlyString();
try {
if (!Files.exists(getShaderpacksDirectory())) {
Files.createDirectories(getShaderpacksDirectory());
}
} catch (IOException e) {
logger.warn("Failed to create the shaderpacks directory!");
logger.warn("", e);
}
irisConfig = new IrisConfig(FabricLoader.getInstance().getConfigDir().resolve("iris.properties"));
try {
irisConfig.initialize();
} catch (IOException e) {
logger.error("Failed to initialize Iris configuration, default values will be used instead");
logger.error("", e);
}
reloadKeybind = KeyBindingHelper.registerKeyBinding(new KeyMapping("iris.keybind.reload", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_R, "iris.keybinds"));
toggleShadersKeybind = KeyBindingHelper.registerKeyBinding(new KeyMapping("iris.keybind.toggleShaders", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_K, "iris.keybinds"));
shaderpackScreenKeybind = KeyBindingHelper.registerKeyBinding(new KeyMapping("iris.keybind.shaderPackSelection", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_O, "iris.keybinds"));
initialized = true;
}
use of net.coderbot.iris.config.IrisConfig in project Iris by IrisShaders.
the class IrisApiV0ConfigImpl method setShadersEnabledAndApply.
@Override
public void setShadersEnabledAndApply(boolean enabled) {
IrisConfig config = Iris.getIrisConfig();
config.setShadersEnabled(enabled);
try {
config.save();
} catch (IOException e) {
Iris.logger.error("Error saving configuration file!", e);
}
try {
Iris.reload();
} catch (IOException e) {
Iris.logger.error("Error reloading shader pack while applying changes!", e);
}
}
use of net.coderbot.iris.config.IrisConfig in project Iris by IrisShaders.
the class Iris method handleKeybinds.
public static void handleKeybinds(Minecraft minecraft) {
if (reloadKeybind.consumeClick()) {
try {
reload();
if (minecraft.player != null) {
minecraft.player.displayClientMessage(new TranslatableComponent("iris.shaders.reloaded"), false);
}
} catch (Exception e) {
logger.error("Error while reloading Shaders for Iris!", e);
if (minecraft.player != null) {
minecraft.player.displayClientMessage(new TranslatableComponent("iris.shaders.reloaded.failure", Throwables.getRootCause(e).getMessage()).withStyle(ChatFormatting.RED), false);
}
}
} else if (toggleShadersKeybind.consumeClick()) {
IrisConfig config = getIrisConfig();
try {
config.setShadersEnabled(!config.areShadersEnabled());
config.save();
reload();
if (minecraft.player != null) {
minecraft.player.displayClientMessage(new TranslatableComponent("iris.shaders.toggled", config.areShadersEnabled() ? currentPackName : "off"), false);
}
} catch (Exception e) {
logger.error("Error while toggling shaders!", e);
if (minecraft.player != null) {
minecraft.player.displayClientMessage(new TranslatableComponent("iris.shaders.toggled.failure", Throwables.getRootCause(e).getMessage()).withStyle(ChatFormatting.RED), false);
}
setShadersDisabled();
currentPackName = "(off) [fallback, check your logs for errors]";
}
} else if (shaderpackScreenKeybind.consumeClick()) {
minecraft.setScreen(new ShaderPackScreen(null));
}
}
Aggregations