diff --git a/build.gradle b/build.gradle index ee9dfac5..94f0bf56 100644 --- a/build.gradle +++ b/build.gradle @@ -134,8 +134,8 @@ dependencies { modCompileOnly("maven.modrinth:modmenu:17.0.0-alpha.1") modRuntimeOnlyMsk("maven.modrinth:modmenu:17.0.0-alpha.1") - modCompileOnly("maven.modrinth:iris:1.10.0+1.21.11-fabric") - //modRuntimeOnlyMsk("maven.modrinth:iris:1.10.0+1.21.11-fabric") + modCompileOnly("maven.modrinth:iris:1.10.4+1.21.11-fabric") + modRuntimeOnlyMsk("maven.modrinth:iris:1.10.4+1.21.11-fabric") //modCompileOnly("maven.modrinth:starlight:1.1.3+1.20.4") diff --git a/src/main/java/me/cortex/voxy/client/config/SodiumConfigBuilder.java b/src/main/java/me/cortex/voxy/client/config/SodiumConfigBuilder.java index 4c2097d8..a39ac22a 100644 --- a/src/main/java/me/cortex/voxy/client/config/SodiumConfigBuilder.java +++ b/src/main/java/me/cortex/voxy/client/config/SodiumConfigBuilder.java @@ -146,18 +146,12 @@ public class SodiumConfigBuilder { protected Identifier[] postRunnerConflicts; protected Identifier[] postChangeFlags; public OPTION setPostChangeRunner(Consumer postRunner, String... dontRunIfChangedVars) { - if (this.postChangeFlags != null) { - throw new IllegalStateException(); - } this.postRunner = postRunner; this.postRunnerConflicts = mapIds(dontRunIfChangedVars); return (OPTION) this; } public OPTION setPostChangeFlags(String... flags) { - if (this.postRunner != null) { - throw new IllegalStateException(); - } this.postChangeFlags = mapIds(flags); return (OPTION) this; } @@ -169,14 +163,21 @@ public class SodiumConfigBuilder { option.setName(this.name); option.setTooltip(this.tooltip); + Set flags = new LinkedHashSet<>(); if (this.postRunner != null) { var id = Identifier.parse(this.id); var runner = this.postRunner; var getter = this.getter; ctx.postRunner.register(id, ()->runner.accept(getter.get()), this.postRunnerConflicts); - option.setFlags(id); - } else if (this.postChangeFlags != null) { - option.setFlags(this.postChangeFlags); + flags.add(id); + } + + if (this.postChangeFlags != null) { + flags.addAll(List.of(this.postChangeFlags)); + } + + if (!flags.isEmpty()) { + option.setFlags(flags.toArray(Identifier[]::new)); } option.setBinding(this.setter, this.getter); diff --git a/src/main/java/me/cortex/voxy/client/config/VoxyConfigMenu.java b/src/main/java/me/cortex/voxy/client/config/VoxyConfigMenu.java index ccb12a9c..d0b774de 100644 --- a/src/main/java/me/cortex/voxy/client/config/VoxyConfigMenu.java +++ b/src/main/java/me/cortex/voxy/client/config/VoxyConfigMenu.java @@ -5,6 +5,7 @@ import me.cortex.voxy.client.config.SodiumConfigBuilder.*; import me.cortex.voxy.client.VoxyClient; import me.cortex.voxy.client.VoxyClientInstance; import me.cortex.voxy.client.core.IGetVoxyRenderSystem; +import me.cortex.voxy.client.core.util.IrisUtil; import me.cortex.voxy.common.util.cpu.CpuLayout; import me.cortex.voxy.commonImpl.VoxyCommon; import net.caffeinemc.mods.sodium.api.config.ConfigEntryPoint; @@ -24,37 +25,37 @@ public class VoxyConfigMenu implements ConfigEntryPoint { var cc = B.registerModOptions("voxy", "Voxy", VoxyCommon.MOD_VERSION) .setIcon(Identifier.parse("voxy:icon.png")); + final var RENDER_RELOAD = OptionFlag.REQUIRES_RENDERER_RELOAD.getId().toString(); + SodiumConfigBuilder.buildToSodium(B, cc, CFG::save, postOp->{ postOp.register("voxy:update_threads", ()->{ var instance = VoxyCommon.getInstance(); if (instance != null) { instance.updateDedicatedThreads(); } - }, "voxy:enabled"); + }, "voxy:enabled").register("voxy:iris_reload", ()->IrisUtil.reload()); }, new Page(Component.translatable("voxy.config.general"), new Group( new BoolOption( "voxy:enabled", Component.translatable("voxy.config.general.enabled"), - ()->CFG.enabled, v->CFG.enabled=v) + ()->CFG.enabled, v->{ + CFG.enabled=v; + //we need to special case enabled, since the render reload flag runs befor us and its quite important we get it right + if (v&&VoxyClientInstance.isInGame) { + VoxyCommon.createInstance(); + } + }) .setPostChangeRunner(c->{ - if (c) { - if (VoxyClientInstance.isInGame) { - VoxyCommon.createInstance(); - var vrsh = (IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer; - if (vrsh != null && CFG.enableRendering) { - vrsh.createRenderer(); - } - } - } else { + if (!c) { var vrsh = (IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer; if (vrsh != null) { vrsh.shutdownRenderer(); } VoxyCommon.shutdownInstance(); } - }).setEnabler(null) + }).setPostChangeFlags(RENDER_RELOAD, "voxy:iris_reload").setEnabler(null) ), new Group( new IntOption( "voxy:thread_count", @@ -89,7 +90,8 @@ public class VoxyConfigMenu implements ConfigEntryPoint { vrsh.shutdownRenderer(); } } - },"voxy:enabled", "voxy:renderer_reload") + },"voxy:enabled", RENDER_RELOAD) + .setPostChangeFlags("voxy:iris_reload") .setEnabler("voxy:enabled") ), new Group( new IntOption( @@ -112,19 +114,19 @@ public class VoxyConfigMenu implements ConfigEntryPoint { vrs.setRenderDistance(c); } } - }, "voxy:rendering", "voxy:renderer_reload") + }, "voxy:rendering", RENDER_RELOAD) ), new Group( new BoolOption( "voxy:eviromental_fog", Component.translatable("voxy.config.general.environmental_fog"), ()->CFG.useEnvironmentalFog, v->CFG.useEnvironmentalFog=v) - .setPostChangeFlags(OptionFlag.REQUIRES_RENDERER_RELOAD.getId().toString()) + .setPostChangeFlags(RENDER_RELOAD) ), new Group( new BoolOption( "voxy:render_debug", Component.translatable("voxy.config.general.render_statistics"), ()-> RenderStatistics.enabled, v->RenderStatistics.enabled=v) - .setPostChangeFlags(OptionFlag.REQUIRES_RENDERER_RELOAD.getId().toString())) + .setPostChangeFlags(RENDER_RELOAD)) ).setEnablerAND("voxy:enabled", "voxy:rendering")); } diff --git a/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java b/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java index fd9b8b34..f25a970f 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java +++ b/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java @@ -22,6 +22,7 @@ import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; import org.joml.Quaternionf; import org.joml.Vector3f; +import org.lwjgl.opengl.ARBDrawBuffersBlend; import org.lwjgl.opengl.GL14; import static org.lwjgl.opengl.GL11.*; @@ -203,7 +204,7 @@ public class ModelTextureBakery { if (layer == ChunkSectionLayer.TRANSLUCENT) { glEnablei(GL_BLEND, 0); glDisablei(GL_BLEND, 1); - glBlendFuncSeparatei(0, GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + ARBDrawBuffersBlend.glBlendFuncSeparateiARB(0, GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); } else { glDisable(GL_BLEND);//FUCK YOU INTEL (screams), for _some reason_ discard or something... JUST DOESNT WORK?? //glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ONE); diff --git a/src/main/java/me/cortex/voxy/client/core/util/IrisUtil.java b/src/main/java/me/cortex/voxy/client/core/util/IrisUtil.java index 6d9ffb8d..6d701485 100644 --- a/src/main/java/me/cortex/voxy/client/core/util/IrisUtil.java +++ b/src/main/java/me/cortex/voxy/client/core/util/IrisUtil.java @@ -10,7 +10,10 @@ import net.irisshaders.iris.api.v0.IrisApi; import net.irisshaders.iris.gl.IrisRenderSystem; import net.irisshaders.iris.shadows.ShadowRenderer; +import java.io.IOException; + public class IrisUtil { + public record CapturedViewportParameters(ChunkRenderMatrices matrices, FogParameters parameters, double x, double y, double z) { public Viewport apply(VoxyRenderSystem vrs) { return vrs.setupViewport(this.matrices, this.parameters, this.x, this.y, this.z); @@ -34,6 +37,19 @@ public class IrisUtil { public static void clearIrisSamplers() { if (IRIS_INSTALLED) clearIrisSamplers0(); } + public static void reload() { + if (IRIS_INSTALLED) reload0(); + } + + private static void reload0() { + try { + if (IrisApi.getInstance().isShaderPackInUse()) {//Only reload if there is a shaderpack + Iris.reload(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } private static void clearIrisSamplers0() { for (int i = 0; i < 16; i++) { diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinLevelRenderer.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinLevelRenderer.java index a3ba9761..c4fac281 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinLevelRenderer.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinLevelRenderer.java @@ -60,10 +60,14 @@ public abstract class MixinLevelRenderer implements IGetVoxyRenderSystem { @Override public void createRenderer() { if (this.renderer != null) throw new IllegalStateException("Cannot have multiple renderers"); - if (!VoxyConfig.CONFIG.isRenderingEnabled()) { + if (!VoxyConfig.CONFIG.enabled) { Logger.info("Not creating renderer due to disabled"); return; } + if (!VoxyConfig.CONFIG.isRenderingEnabled()) { + Logger.info("Not creating renderer due to disabled rendering"); + return; + } if (this.level == null) { Logger.error("Not creating renderer due to null world"); return; diff --git a/src/main/java/me/cortex/voxy/common/world/other/Mapper.java b/src/main/java/me/cortex/voxy/common/world/other/Mapper.java index 33d99179..07f9edc1 100644 --- a/src/main/java/me/cortex/voxy/common/world/other/Mapper.java +++ b/src/main/java/me/cortex/voxy/common/world/other/Mapper.java @@ -86,6 +86,10 @@ public class Mapper { return (id&(~(0xFFL<<56)))|(Integer.toUnsignedLong(light&0xFF)<<56); } + public static long withBlockBiome(long id, int block, int biome) { + return (id&(0xFFL<<56))|(Integer.toUnsignedLong(block)<<27)|(Integer.toUnsignedLong(biome)<<47); + } + public static long airWithLight(int light) { return Integer.toUnsignedLong(light&0xFF)<<56; }