Skip to content

Commit

Permalink
Fixed getShaderPack to work with Iris 1.7+
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Jun 22, 2024
1 parent bb6edda commit 4207e87
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 1 addition & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -10,7 +9,6 @@ architectury {

subprojects {
apply plugin: "dev.architectury.loom"
apply plugin: "io.github.juuxel.loom-vineflower"

loom {
silentMojangMappingsLicense()
Expand Down
13 changes: 11 additions & 2 deletions common/src/main/java/org/figuramc/figura/lua/api/ClientAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 "";
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4207e87

Please sign in to comment.