From 4207e873aa1fa6ad2a7475f81a1ad0068f1f6a4b Mon Sep 17 00:00:00 2001 From: UnlikePaladin <36827970+UnlikePaladin@users.noreply.github.com> Date: Fri, 21 Jun 2024 19:58:22 -0600 Subject: [PATCH] Fixed getShaderPack to work with Iris 1.7+ --- build.gradle | 4 +--- .../java/org/figuramc/figura/lua/api/ClientAPI.java | 13 +++++++++++-- gradle.properties | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 98c5ef503..71c1ce27d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,6 @@ plugins { id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "1.2-SNAPSHOT" apply false - id "io.github.juuxel.loom-vineflower" version "1.+" apply false + id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false } architectury { @@ -10,7 +9,6 @@ architectury { subprojects { apply plugin: "dev.architectury.loom" - apply plugin: "io.github.juuxel.loom-vineflower" loom { silentMojangMappingsLicense() diff --git a/common/src/main/java/org/figuramc/figura/lua/api/ClientAPI.java b/common/src/main/java/org/figuramc/figura/lua/api/ClientAPI.java index f87dfbc12..5a716cd69 100644 --- a/common/src/main/java/org/figuramc/figura/lua/api/ClientAPI.java +++ b/common/src/main/java/org/figuramc/figura/lua/api/ClientAPI.java @@ -42,6 +42,8 @@ import org.luaj.vm2.LuaValue; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.text.SimpleDateFormat; import java.util.*; import java.util.function.Supplier; @@ -367,14 +369,21 @@ public static boolean hasShaderPack() { public static String getShaderPackName() { try { if (HAS_IRIS) { - return net.coderbot.iris.Iris.getCurrentPackName(); + Method shaderNameField = Class.forName("net.coderbot.iris.Iris").getMethod("getCurrentPackName"); + shaderNameField.setAccessible(true); + return shaderNameField.invoke(null).toString(); } else if (OPTIFINE_LOADED.get()) { Field shaderNameField = Class.forName("net.optifine.shaders.Shaders").getField("currentShaderName"); Class shaderClass = shaderNameField.getType(); if (shaderClass == String.class) return (String) shaderNameField.get(null); } - }catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException ignored) { + } catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | + InvocationTargetException | NoSuchMethodException ignored) { + try { + return net.irisshaders.iris.Iris.getCurrentPackName(); + }catch (Exception ignored1) { + } } return ""; } diff --git a/gradle.properties b/gradle.properties index 6b1ab79ae..a0d8fc0b5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -33,7 +33,7 @@ fabric_loader_version = 0.14.22 # https://modrinth.com/mod/geckolib # https://github.com/bernie-g/geckolib/blob/1.20.1/gradle.properties modmenu = 7.2.1 -iris = 1.6.4+1.20 +iris = 1.7.1+1.20.1 immediately_fast = 1.2.0+1.20.1 geckolib_version = 1.20.1:4.4 mclib_version=20