Skip to content

Commit

Permalink
fix crash with iris 1.8 beta4
Browse files Browse the repository at this point in the history
  • Loading branch information
fayer3 committed Sep 18, 2024
1 parent 9e49613 commit b266fd0
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 10 deletions.
4 changes: 2 additions & 2 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ dependencies {
modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" }

// for sodium compat
modCompileOnly "maven.modrinth:sodium:mc1.21-0.5.9"
modCompileOnly "maven.modrinth:sodium:mc1.21-0.6.0-beta.2-fabric"

// for iris compat
modCompileOnly "maven.modrinth:iris:1.7.1+1.21"
modCompileOnly "maven.modrinth:iris:1.8.0-beta.4+1.21-fabric"

// for REI compat
modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:14.0.688") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" exclude group: "dev.architectury" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public void prepare() {
animatedSprites = ConcurrentHashMap.newKeySet();
blockCounts = new ConcurrentHashMap<>();
renderTimes = new ConcurrentHashMap<>();
if (IrisHelper.isIrisLoaded() && IrisHelper.isShaderActive()) {
if (IrisHelper.isIrisLoaded() && IrisHelper.isShaderActive() && IrisHelper.hasIssuesWithMenuWorld()) {
shadersEnabled = true;
mc.gui.getChat().addMessage(Component.literal("Vivecraft: temporarily disabling shaders to build Menuworld"));
IrisHelper.toggleShaders(mc, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class IrisHelper {

private static Method CapturedRenderingState_getGbufferProjection;

private static Method WorldRenderingSettings_setUseExtendedVertexFormat;

public static boolean isIrisLoaded() {
return Xplat.isModLoaded("iris") || Xplat.isModLoaded("oculus");
}
Expand Down Expand Up @@ -84,13 +86,17 @@ public static boolean isShaderActive() {
return IrisApi.getInstance().isShaderPackInUse();
}

public static boolean hasIssuesWithMenuWorld() {
return init() && WorldRenderingSettings_setUseExtendedVertexFormat != null;
}

public static void toggleShaders(Minecraft mc, boolean enabled) {
try {
Iris.toggleShaders(mc, enabled);
if (!enabled) {
WorldRenderingSettings.INSTANCE.setUseExtendedVertexFormat(false);
if (!enabled && hasIssuesWithMenuWorld()) {
WorldRenderingSettings_setUseExtendedVertexFormat.invoke(WorldRenderingSettings.INSTANCE, false);
}
} catch (IOException e) {
} catch (IOException | InvocationTargetException | IllegalAccessException e) {
VRSettings.logger.error("Vivecraft: error Toggling Iris shader to '{}': {}", enabled, e.getMessage());
}
}
Expand Down Expand Up @@ -156,6 +162,10 @@ private static boolean init() {

WorldRenderingPipeline_shouldRenderUnderwaterOverlay = worldRenderingPipeline.getMethod("shouldRenderUnderwaterOverlay");

try {
WorldRenderingSettings_setUseExtendedVertexFormat = Class.forName("net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings").getMethod("setUseExtendedVertexFormat", boolean.class);
} catch (ClassNotFoundException | NoSuchMethodException ignore) {}

// distant horizon compat
if (Xplat.isModLoaded("distanthorizons")) {
try {
Expand Down
4 changes: 2 additions & 2 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ dependencies {
modCompileOnly("dev.architectury:architectury-fabric:${rootProject.architectury_version}") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" }

// for sodium compat
modRuntimeOnly "maven.modrinth:sodium:mc1.21-0.5.9"
modRuntimeOnly "maven.modrinth:sodium:mc1.21-0.6.0-beta.2-fabric"

// for iris compat
modRuntimeOnly "maven.modrinth:iris:1.7.1+1.21"
modRuntimeOnly "maven.modrinth:iris:1.8.0-beta.4+1.21-fabric"
modRuntimeOnly 'org.anarres:jcpp:1.4.14' //temp iris
modRuntimeOnly 'io.github.douira:glsl-transformer:2.0.0-pre13' //temp iris

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ maven_group=org.vivecraft

architectury_version=12.0.26

fabric_loader_version=0.15.11
fabric_api_version=0.100.1+1.21
fabric_loader_version=0.16.5
fabric_api_version=0.104.0+1.21.1

forge_version=1.21-51.0.22
neoforge_version=21.0.110-beta
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.irisshaders.iris.compat.sodium.impl.shader_overrides;

public interface IrisChunkProgramOverrides {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.irisshaders.iris.compat.sodium.impl.shader_overrides;

public interface IrisChunkShaderInterface {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.irisshaders.iris.compat.sodium.impl.shader_overrides;

public enum IrisTerrainPass {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.irisshaders.iris.pipeline;

public interface SodiumTerrainPipeline {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package net.irisshaders.iris.pipeline;

public interface WorldRenderingPipeline {
SodiumTerrainPipeline getSodiumTerrainPipeline();

void destroy();
}

0 comments on commit b266fd0

Please sign in to comment.