vivecraft fixes

This commit is contained in:
mcrcortex
2025-10-19 11:53:17 +10:00
parent 87c7f37bb1
commit 46a0c982e1

View File

@@ -8,6 +8,8 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Supplier; import java.util.function.Supplier;
import static org.vivecraft.api.client.data.RenderPass.VANILLA;
public class ViewportSelector <T extends Viewport<?>> { public class ViewportSelector <T extends Viewport<?>> {
public static final boolean VIVECRAFT_INSTALLED = FabricLoader.getInstance().isModLoaded("vivecraft"); public static final boolean VIVECRAFT_INSTALLED = FabricLoader.getInstance().isModLoaded("vivecraft");
@@ -25,27 +27,28 @@ public class ViewportSelector <T extends Viewport<?>> {
} }
private T getVivecraftViewport() { private T getVivecraftViewport() {
var rApi = VRRenderingAPI.instance(); var pass = VRRenderingAPI.instance().getCurrentRenderPass();
if (rApi == null) { if (pass == null || pass == VANILLA) {
return this.defaultViewport; return null;
}
var pass = rApi.getCurrentRenderPass();
if (pass == null) {
return this.defaultViewport;
} }
return this.getOrCreate(pass); return this.getOrCreate(pass);
} }
private static final Object IRIS_SHADOW_OBJECT = new Object(); private static final Object IRIS_SHADOW_OBJECT = new Object();
public T getViewport() { public T getViewport() {
if (VIVECRAFT_INSTALLED) { T viewport = null;
return getVivecraftViewport(); if (viewport == null && VIVECRAFT_INSTALLED) {
viewport = getVivecraftViewport();
} }
if (IrisUtil.irisShadowActive()) { if (viewport == null && IrisUtil.irisShadowActive()) {
return this.getOrCreate(IRIS_SHADOW_OBJECT); viewport = this.getOrCreate(IRIS_SHADOW_OBJECT);
} }
return this.defaultViewport;
if (viewport == null) {
viewport = this.defaultViewport;
}
return viewport;
} }
public void free() { public void free() {