From 1cd270fdd0d6fb4efd72ff0dcf84ee7b92345368 Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Fri, 7 Nov 2025 14:39:10 -0800 Subject: [PATCH] Uniform Additions and fixes (#1102) --- .../compat/iris/BiomeCategoryCache.java | 17 + .../compat/iris/ModdedBiomeDetector.java | 102 +++++ .../angelica/compat/mojang/Camera.java | 65 ++- .../angelica/compat/mojang/GameModeUtil.java | 17 + .../java/kroppeb/stareval/function/Type.java | 3 +- .../iris/gl/program/ProgramUniforms.java | 58 +-- .../iris/gl/shader/StandardMacros.java | 54 ++- .../coderbot/iris/gl/uniform/UniformType.java | 2 + .../coderbot/iris/pipeline/HandRenderer.java | 6 +- .../iris/pipeline/SodiumTerrainPipeline.java | 3 + .../iris/shaderpack/ShaderProperties.java | 15 +- .../preprocessor/PropertiesPreprocessor.java | 34 +- .../coderbot/iris/uniforms/BiomeUniforms.java | 369 ++++++++++++++++++ .../iris/uniforms/CommonUniforms.java | 45 +-- .../uniforms/ExternallyManagedUniforms.java | 6 +- .../iris/uniforms/IrisExclusiveUniforms.java | 65 +-- .../iris/uniforms/VanillaBiomeList.java | 85 ++++ src/main/resources/META-INF/angelica_at.cfg | 1 + .../early/angelica/MixinEntityRenderer.java | 14 +- .../early/shaders/MixinEntityRenderer.java | 6 +- .../early/sodium/MixinBiomeGenBase.java | 19 +- .../early/sodium/MixinRenderGlobal.java | 16 +- 22 files changed, 846 insertions(+), 156 deletions(-) create mode 100644 src/main/java/com/gtnewhorizons/angelica/compat/iris/BiomeCategoryCache.java create mode 100644 src/main/java/com/gtnewhorizons/angelica/compat/iris/ModdedBiomeDetector.java create mode 100644 src/main/java/com/gtnewhorizons/angelica/compat/mojang/GameModeUtil.java create mode 100644 src/main/java/net/coderbot/iris/uniforms/BiomeUniforms.java create mode 100644 src/main/java/net/coderbot/iris/uniforms/VanillaBiomeList.java diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/iris/BiomeCategoryCache.java b/src/main/java/com/gtnewhorizons/angelica/compat/iris/BiomeCategoryCache.java new file mode 100644 index 000000000..200f6262d --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/compat/iris/BiomeCategoryCache.java @@ -0,0 +1,17 @@ +package com.gtnewhorizons.angelica.compat.iris; + +/** + * Interface implemented by BiomeGenBase via mixin to cache biome category. + * This avoids recomputing the category every frame for shader uniforms. + */ +public interface BiomeCategoryCache { + /** + * Gets the cached biome category ordinal, or -1 if not yet computed. + */ + int iris$getCachedCategory(); + + /** + * Sets the cached biome category ordinal. + */ + void iris$setCachedCategory(int category); +} diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/iris/ModdedBiomeDetector.java b/src/main/java/com/gtnewhorizons/angelica/compat/iris/ModdedBiomeDetector.java new file mode 100644 index 000000000..8810c47bf --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/compat/iris/ModdedBiomeDetector.java @@ -0,0 +1,102 @@ +package com.gtnewhorizons.angelica.compat.iris; + +import net.coderbot.iris.parsing.BiomeCategories; +import net.minecraft.world.biome.BiomeGenBase; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Detects and categorizes biomes from popular modded biome mods using cached class checks. + * Currently supports: BiomesOPlenty (BOP), Realistic World Gen (RWG) + */ +public class ModdedBiomeDetector { + private static boolean initialized = false; + + // BiomesOPlenty (BOP) cache - dimension-specific base classes + // BOP 1.7.10 hierarchy: BOPBiome -> BOPEndBiome/BOPNetherBiome/BOPOverworldBiome -> specific biomes + private static Class bopEndBiomeClass = null; + private static Class bopNetherBiomeClass = null; + private static Class bopOceanBiomeClass = null; + + // Realistic World Gen (RWG) cache - base biome classes that extend BiomeGenBase + // LinkedHashMap maintains insertion order for deterministic behavior + private static final Map, BiomeCategories> rwgClassMap = new LinkedHashMap<>(); + + private static synchronized void initialize() { + if (initialized) return; + initialized = true; + + initializeBOP(); + initializeRWG(); + } + + private static void initializeBOP() { + try { + bopEndBiomeClass = Class.forName("biomesoplenty.common.biome.BOPEndBiome"); + bopNetherBiomeClass = Class.forName("biomesoplenty.common.biome.BOPNetherBiome"); + bopOceanBiomeClass = Class.forName("biomesoplenty.common.biome.BOPOceanBiome"); + } catch (ClassNotFoundException ignored) { + // BOP not installed + } + } + + private static void initializeRWG() { + // RWG adds actual BiomeGenBase subclasses in rwg.biomes.base package + tryAddRWGClass("rwg.biomes.base.BaseBiomeOcean", BiomeCategories.OCEAN); + tryAddRWGClass("rwg.biomes.base.BaseBiomeRiver", BiomeCategories.RIVER); + tryAddRWGClass("rwg.biomes.base.BaseBiomePlains", BiomeCategories.PLAINS); + tryAddRWGClass("rwg.biomes.base.BaseBiomeColdPlains", BiomeCategories.PLAINS); + tryAddRWGClass("rwg.biomes.base.BaseBiomeHotPlains", BiomeCategories.PLAINS); + tryAddRWGClass("rwg.biomes.base.BaseBiomeHotDesert", BiomeCategories.DESERT); + tryAddRWGClass("rwg.biomes.base.BaseBiomeSnowDesert", BiomeCategories.DESERT); // Cold desert, but still desert + tryAddRWGClass("rwg.biomes.base.BaseBiomeJungle", BiomeCategories.JUNGLE); + tryAddRWGClass("rwg.biomes.base.BaseBiomeTropicalIsland", BiomeCategories.JUNGLE); // Tropical islands are jungle-like + tryAddRWGClass("rwg.biomes.base.BaseBiomeRedwood", BiomeCategories.FOREST); // Redwood/Sequoia forests + tryAddRWGClass("rwg.biomes.base.BaseBiomeTemperateForest", BiomeCategories.FOREST); + tryAddRWGClass("rwg.biomes.base.BaseBiomeColdForest", BiomeCategories.TAIGA); // Cold forests are taiga-like + tryAddRWGClass("rwg.biomes.base.BaseBiomeHotForest", BiomeCategories.FOREST); + tryAddRWGClass("rwg.biomes.base.BaseBiomeSnowForest", BiomeCategories.TAIGA); // Snow forests are taiga + } + + private static void tryAddRWGClass(String className, BiomeCategories category) { + try { + final Class clazz = Class.forName(className); + rwgClassMap.put(clazz, category); + } catch (ClassNotFoundException ignored) { + // Class not available, RWG not installed or different version + } + } + + /** + * Attempts to detect the biome category for modded biomes. + * Returns null if no modded biome detection applies. + */ + public static BiomeCategories detectModdedBiome(BiomeGenBase biome) { + if (!initialized) { + initialize(); + } + + // BiomesOPlenty detection - dimension-specific classes give us clear categories + if (bopEndBiomeClass != null && bopEndBiomeClass.isInstance(biome)) { + return BiomeCategories.THE_END; + } + if (bopNetherBiomeClass != null && bopNetherBiomeClass.isInstance(biome)) { + return BiomeCategories.NETHER; + } + if (bopOceanBiomeClass != null && bopOceanBiomeClass.isInstance(biome)) { + return BiomeCategories.OCEAN; + } + // For other BOP overworld biomes (e.g., Alps, Arctic, BambooForest), + // fall through to name/property-based detection + + // Realistic World Gen detection + for (Map.Entry, BiomeCategories> entry : rwgClassMap.entrySet()) { + if (entry.getKey().isInstance(biome)) { + return entry.getValue(); + } + } + + return null; + } +} diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/Camera.java b/src/main/java/com/gtnewhorizons/angelica/compat/mojang/Camera.java index 1a628b220..69a940cae 100644 --- a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/Camera.java +++ b/src/main/java/com/gtnewhorizons/angelica/compat/mojang/Camera.java @@ -9,35 +9,62 @@ import net.minecraft.util.MathHelper; import org.joml.Matrix4f; import org.joml.Vector3d; -import org.joml.Vector4f; +import org.joml.Vector3f; +/** + * Singleton camera instance that tracks the current camera position and orientation. + */ @Getter public class Camera { - final Vector3d pos = new Vector3d(); - final BlockPos blockPos = new BlockPos(); - float pitch; - float yaw; - EntityLivingBase entity; - boolean thirdPerson; - final float partialTicks; + public static final Camera INSTANCE = new Camera(); - public Camera(EntityLivingBase entity, float partialTicks) { + private final Vector3d pos = new Vector3d(); + private final BlockPos blockPos = new BlockPos(); + private final Vector3f offset = new Vector3f(); + private final Matrix4f inverseModelView = new Matrix4f(); + + private float pitch; + private float yaw; + private EntityLivingBase entity; + private boolean thirdPerson; + private float partialTicks; + + private Camera() { + } + + /** + * Updates the camera position and orientation based on the current entity and partial ticks. + * + * @param entity The entity to track (usually the render view entity) + * @param partialTicks The partial tick time for interpolation + */ + public void update(EntityLivingBase entity, float partialTicks) { this.partialTicks = partialTicks; - final Vector4f offset = new Vector4f(); // third person offset - final Matrix4f inverseModelView = new Matrix4f(RenderingState.INSTANCE.getModelViewMatrix()).invert(); - inverseModelView.transform(offset); - - final double camX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks + offset.x; - final double camY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks + offset.y; - final double camZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks + offset.z; this.entity = entity; + // Entity position (interpolated, at feet level) + final double entityX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks; + final double entityY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks; + final double entityZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks; + final double eyeHeight = entity.getEyeHeight(); + + thirdPerson = Minecraft.getMinecraft().gameSettings.thirdPersonView > 0; + + final double camX, camY, camZ; + offset.set(0, 0, 0); + + if (thirdPerson) { + // Third person: use inverse modelview to find camera offset + inverseModelView.set(RenderingState.INSTANCE.getModelViewMatrix()).invert(); + inverseModelView.transformPosition(offset); + } + camX = entityX + offset.x; + camY = entityY + eyeHeight + offset.y; + camZ = entityZ + offset.z; + pos.set(camX, camY, camZ); blockPos.set(MathHelper.floor_double(camX), MathHelper.floor_double(camY), MathHelper.floor_double(camZ)); pitch = entity.cameraPitch; yaw = entity.rotationYaw; - thirdPerson = Minecraft.getMinecraft().gameSettings.thirdPersonView == 1; - } - } diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/GameModeUtil.java b/src/main/java/com/gtnewhorizons/angelica/compat/mojang/GameModeUtil.java new file mode 100644 index 000000000..1312fd839 --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/compat/mojang/GameModeUtil.java @@ -0,0 +1,17 @@ +package com.gtnewhorizons.angelica.compat.mojang; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.PlayerControllerMP; + +public final class GameModeUtil { + private GameModeUtil() { + } + + public static boolean isSpectator() { + final PlayerControllerMP controller = Minecraft.getMinecraft().playerController; + if (controller == null) { + return false; + } + return controller.currentGameType.getID() == 3; + } +} diff --git a/src/main/java/kroppeb/stareval/function/Type.java b/src/main/java/kroppeb/stareval/function/Type.java index 3b0cfeee4..d5eed1e20 100644 --- a/src/main/java/kroppeb/stareval/function/Type.java +++ b/src/main/java/kroppeb/stareval/function/Type.java @@ -16,7 +16,8 @@ public abstract class Type { public static final Primitive[] AllPrimitives = {Type.Boolean, Type.Int, Type.Float}; public static UniformType convert(Type type) { - if (type == Type.Int || type == Type.Boolean) return UniformType.INT; + if (type == Type.Int) return UniformType.INT; + else if (type == Type.Boolean) return UniformType.INT; else if (type == Type.Float) return UniformType.FLOAT; else if (type == VectorType.VEC2) return UniformType.VEC2; else if (type == VectorType.VEC3) return UniformType.VEC3; diff --git a/src/main/java/net/coderbot/iris/gl/program/ProgramUniforms.java b/src/main/java/net/coderbot/iris/gl/program/ProgramUniforms.java index 72d0b13c9..0f1fc2e20 100644 --- a/src/main/java/net/coderbot/iris/gl/program/ProgramUniforms.java +++ b/src/main/java/net/coderbot/iris/gl/program/ProgramUniforms.java @@ -203,43 +203,45 @@ public class ProgramUniforms { final int size = sizeType.get(0); final int type = sizeType.get(1); - UniformType provided = uniformNames.get(name); + final UniformType provided = uniformNames.get(name); final UniformType expected = getExpectedType(type); - if (provided == null && !name.startsWith("gl_")) { - final String typeName = getTypeName(type); + if(AngelicaConfig.enableHardcodedCustomUniforms) { + // Legacy Checks from hardcoded custom uniforms + if (provided == null && !name.startsWith("gl_")) { + final String typeName = getTypeName(type); - if (isSampler(type) || isImage(type)) { - // don't print a warning, samplers and images are managed elsewhere. - // TODO: Detect unsupported samplers/images? - continue; - } + if (isSampler(type) || isImage(type)) { + // don't print a warning, samplers and images are managed elsewhere. + continue; + } - final UniformType externalProvided = externalUniformNames.get(name); + final UniformType externalProvided = externalUniformNames.get(name); - if (externalProvided != null) { - if (externalProvided != expected) { - String expectedName; + if (externalProvided != null) { + if (externalProvided != expected) { + final String expectedName; - if (expected != null) { - expectedName = expected.toString(); - } else { - expectedName = "(unsupported type: " + getTypeName(type) + ")"; + if (expected != null) { + expectedName = expected.toString(); + } else { + expectedName = "(unsupported type: " + getTypeName(type) + ")"; + } + + Iris.logger.error("[" + this.name + "] Wrong uniform type for externally-managed uniform " + name + ": " + externalProvided + " is provided but the program expects " + expectedName + "."); } - Iris.logger.error("[" + this.name + "] Wrong uniform type for externally-managed uniform " + name + ": " + externalProvided + " is provided but the program expects " + expectedName + "."); + continue; + } + + if (size == 1) { + Iris.logger.warn("[" + this.name + "] Unsupported uniform: " + typeName + " " + name); + } else { + Iris.logger.warn("[" + this.name + "] Unsupported uniform: " + name + " of size " + size + " and type " + typeName); } continue; } - - if (size == 1) { - Iris.logger.warn("[" + this.name + "] Unsupported uniform: " + typeName + " " + name); - } else { - Iris.logger.warn("[" + this.name + "] Unsupported uniform: " + name + " of size " + size + " and type " + typeName); - } - - continue; } if (provided != null && provided != expected) { @@ -291,6 +293,7 @@ public class ProgramUniforms { return switch(type) { case GL11.GL_FLOAT -> "float"; case GL11.GL_INT -> "int"; + case GL20.GL_BOOL -> "bool"; case GL20.GL_FLOAT_MAT4 -> "mat4"; case GL20.GL_FLOAT_VEC4 -> "vec4"; case GL20.GL_FLOAT_MAT3 -> "mat3"; @@ -316,12 +319,13 @@ public class ProgramUniforms { return switch (type) { case GL11.GL_FLOAT -> UniformType.FLOAT; case GL11.GL_INT -> UniformType.INT; + case GL20.GL_BOOL -> UniformType.INT; case GL20.GL_FLOAT_MAT4 -> UniformType.MAT4; case GL20.GL_FLOAT_VEC4 -> UniformType.VEC4; case GL20.GL_INT_VEC4 -> UniformType.VEC4I; case GL20.GL_FLOAT_VEC3 -> UniformType.VEC3; - case GL20.GL_FLOAT_MAT3 -> null; - case GL20.GL_INT_VEC3 -> null; + case GL20.GL_FLOAT_MAT3 -> UniformType.MAT3; + case GL20.GL_INT_VEC3 -> UniformType.VEC3I; case GL20.GL_FLOAT_MAT2 -> null; case GL20.GL_FLOAT_VEC2 -> UniformType.VEC2; case GL20.GL_INT_VEC2 -> UniformType.VEC2I; diff --git a/src/main/java/net/coderbot/iris/gl/shader/StandardMacros.java b/src/main/java/net/coderbot/iris/gl/shader/StandardMacros.java index df7a20c74..0fbc6da36 100644 --- a/src/main/java/net/coderbot/iris/gl/shader/StandardMacros.java +++ b/src/main/java/net/coderbot/iris/gl/shader/StandardMacros.java @@ -3,11 +3,13 @@ package net.coderbot.iris.gl.shader; import com.google.common.collect.ImmutableList; import com.gtnewhorizons.angelica.Tags; import cpw.mods.fml.common.Loader; +import net.coderbot.iris.parsing.BiomeCategories; import net.coderbot.iris.pipeline.HandRenderer; import net.coderbot.iris.pipeline.WorldRenderingPhase; import net.coderbot.iris.shaderpack.StringPair; import net.coderbot.iris.texture.format.TextureFormat; import net.coderbot.iris.texture.format.TextureFormatLoader; +import net.coderbot.iris.uniforms.VanillaBiomeList; import org.lwjgl.LWJGLUtil; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL20; @@ -88,6 +90,9 @@ public class StandardMacros { define(standardDefines, irisDefine); } + getBiomeCategoryDefines().forEach((category, ordinal) -> define(standardDefines, category, ordinal)); + getVanillaBiomeDefines().forEach((biome, id) -> define(standardDefines, biome, id)); + return ImmutableList.copyOf(standardDefines); } @@ -98,7 +103,7 @@ public class StandardMacros { * @see Optifine Doc */ public static String getMcVersion() { - final String version = Loader.MC_VERSION;; + final String version = Loader.MC_VERSION; String[] splitVersion = version.split("\\."); @@ -117,10 +122,10 @@ public class StandardMacros { } if (minor.length() == 1) { - minor = 0 + minor; + minor = "0" + minor; } if (bugfix.length() == 1) { - bugfix = 0 + bugfix; + bugfix = "0" + bugfix; } return major + minor + bugfix; @@ -283,4 +288,47 @@ public class StandardMacros { return defines; } + + /** + * Returns biome category defines for use in shaders. + * Generates #define CAT_ for each BiomeCategories enum value. + * + * @return Map of biome category defines and their ordinal values + */ + public static Map getBiomeCategoryDefines() { + Map defines = new HashMap<>(); + for (BiomeCategories category : BiomeCategories.values()) { + defines.put("CAT_" + category.name(), String.valueOf(category.ordinal())); + } + return defines; + } + + /** + * Returns vanilla biome ID defines for use in shaders. + * Generates #define BIOME_ for all vanilla biomes. + * + * @return Map of vanilla biome defines and their IDs + */ + public static Map getVanillaBiomeDefines() { + final Map defines = new HashMap<>(); + + for (VanillaBiomeList.BiomeEntry entry : VanillaBiomeList.getVanillaBiomes()) { + if (entry.biome != null) { + defines.put("BIOME_" + entry.name, String.valueOf(entry.biome.biomeID)); + } + } + + // Modern biomes that don't exist in 1.7.10 - add dummy IDs that will never match + // This allows shader expressions to parse without errors while always evaluating to false/0 + // Using negative IDs to avoid conflicts with actual biome IDs + defines.put("BIOME_NETHER_WASTES", "-1000"); + defines.put("BIOME_SOUL_SAND_VALLEY", "-1001"); + defines.put("BIOME_CRIMSON_FOREST", "-1002"); + defines.put("BIOME_WARPED_FOREST", "-1003"); + defines.put("BIOME_BASALT_DELTAS", "-1004"); + defines.put("BIOME_LUSH_CAVES", "-1005"); + defines.put("BIOME_PALE_GARDEN", "-1006"); + + return defines; + } } diff --git a/src/main/java/net/coderbot/iris/gl/uniform/UniformType.java b/src/main/java/net/coderbot/iris/gl/uniform/UniformType.java index 6933943dd..03cbd383d 100644 --- a/src/main/java/net/coderbot/iris/gl/uniform/UniformType.java +++ b/src/main/java/net/coderbot/iris/gl/uniform/UniformType.java @@ -2,7 +2,9 @@ package net.coderbot.iris.gl.uniform; public enum UniformType { INT, + BOOL, FLOAT, + MAT3, MAT4, VEC2, VEC2I, diff --git a/src/main/java/net/coderbot/iris/pipeline/HandRenderer.java b/src/main/java/net/coderbot/iris/pipeline/HandRenderer.java index 335e3b9b4..4b2cfb417 100644 --- a/src/main/java/net/coderbot/iris/pipeline/HandRenderer.java +++ b/src/main/java/net/coderbot/iris/pipeline/HandRenderer.java @@ -1,6 +1,7 @@ package net.coderbot.iris.pipeline; import com.gtnewhorizons.angelica.compat.mojang.Camera; +import com.gtnewhorizons.angelica.compat.mojang.GameModeUtil; import com.gtnewhorizons.angelica.compat.mojang.InteractionHand; import com.gtnewhorizons.angelica.compat.toremove.RenderLayer; import com.gtnewhorizons.angelica.glsm.GLStateManager; @@ -26,7 +27,7 @@ public class HandRenderer { public static final float DEPTH = 0.125F; private void setupGlState(RenderGlobal gameRenderer, Camera camera, float tickDelta) { - Minecraft mc = Minecraft.getMinecraft(); + final Minecraft mc = Minecraft.getMinecraft(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); @@ -72,8 +73,7 @@ public class HandRenderer { mc.gameSettings.thirdPersonView == 0 && !camera.getEntity().isPlayerSleeping() && !mc.gameSettings.hideGUI && - // TODO: SPECTATOR - // mc.playerController.currentGameType + !GameModeUtil.isSpectator() && !mc.playerController.enableEverythingIsScrewedUpMode(); } diff --git a/src/main/java/net/coderbot/iris/pipeline/SodiumTerrainPipeline.java b/src/main/java/net/coderbot/iris/pipeline/SodiumTerrainPipeline.java index 500a2e2dd..721daa7b6 100644 --- a/src/main/java/net/coderbot/iris/pipeline/SodiumTerrainPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/SodiumTerrainPipeline.java @@ -9,6 +9,7 @@ import net.coderbot.iris.pipeline.transform.TransformPatcher; import net.coderbot.iris.shaderpack.ProgramSet; import net.coderbot.iris.shaderpack.ProgramSource; import net.coderbot.iris.uniforms.CommonUniforms; +import net.coderbot.iris.uniforms.ExternallyManagedUniforms; import net.coderbot.iris.uniforms.builtin.BuiltinReplacementUniforms; import net.coderbot.iris.uniforms.custom.CustomUniforms; @@ -143,6 +144,8 @@ public class SodiumTerrainPipeline { CommonUniforms.addDynamicUniforms(uniforms); customUniforms.assignTo(uniforms); + ExternallyManagedUniforms.addExternallyManagedUniforms116(uniforms); + BuiltinReplacementUniforms.addBuiltinReplacementUniforms(uniforms); return uniforms; } diff --git a/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java b/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java index cc22ea47b..cd53bfe9f 100644 --- a/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java +++ b/src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java @@ -18,13 +18,17 @@ import net.coderbot.iris.gl.blending.BlendModeFunction; import net.coderbot.iris.gl.blending.BlendModeOverride; import net.coderbot.iris.gl.blending.BufferBlendInformation; import net.coderbot.iris.gl.texture.TextureScaleOverride; +import net.coderbot.iris.pipeline.PatchedShaderPrinter; import net.coderbot.iris.shaderpack.option.ShaderPackOptions; import net.coderbot.iris.shaderpack.preprocessor.PropertiesPreprocessor; import net.coderbot.iris.shaderpack.texture.TextureStage; import net.coderbot.iris.uniforms.custom.CustomUniforms; +import net.minecraft.client.Minecraft; import java.io.IOException; import java.io.StringReader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.EnumMap; @@ -98,6 +102,15 @@ public class ShaderProperties { public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, Iterable environmentDefines) { final String preprocessedContents = PropertiesPreprocessor.preprocessSource(contents, shaderPackOptions, environmentDefines); + if (PatchedShaderPrinter.prettyPrintShaders) { + try { + Files.write(Minecraft.getMinecraft().mcDataDir.toPath().resolve("preprocessed.properties"), preprocessedContents.getBytes(StandardCharsets.UTF_8)); + Files.write(Minecraft.getMinecraft().mcDataDir.toPath().resolve("original.properties"), contents.getBytes(StandardCharsets.UTF_8)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + final Properties preprocessed = new OrderBackedProperties(); final Properties original = new OrderBackedProperties(); try { @@ -181,7 +194,7 @@ public class ShaderProperties { }); handlePassDirective("alphaTest.", key, value, pass -> { - if ("off".equals(value)) { + if ("off".equals(value) || "false".equals(value)) { alphaTestOverrides.put(pass, AlphaTestOverride.OFF); return; } diff --git a/src/main/java/net/coderbot/iris/shaderpack/preprocessor/PropertiesPreprocessor.java b/src/main/java/net/coderbot/iris/shaderpack/preprocessor/PropertiesPreprocessor.java index e9ae63b3c..1ee57ae96 100644 --- a/src/main/java/net/coderbot/iris/shaderpack/preprocessor/PropertiesPreprocessor.java +++ b/src/main/java/net/coderbot/iris/shaderpack/preprocessor/PropertiesPreprocessor.java @@ -6,6 +6,7 @@ import net.coderbot.iris.shaderpack.option.ShaderPackOptions; import org.anarres.cpp.Feature; import org.anarres.cpp.LexerException; import org.anarres.cpp.Preprocessor; +import org.anarres.cpp.PreprocessorCommand; import org.anarres.cpp.StringLexerSource; import org.anarres.cpp.Token; @@ -14,18 +15,19 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.stream.Collectors; public class PropertiesPreprocessor { // Derived from ShaderProcessor.glslPreprocessSource, which is derived from GlShader from Canvas, licenced under LGPL public static String preprocessSource(String source, ShaderPackOptions shaderPackOptions, Iterable environmentDefines) { - if (source.contains(PropertyCollectingListener.PROPERTY_MARKER)) { + if (source.contains(PropertyCollectingListener.PROPERTY_MARKER) || source.contains("IRIS_PASSTHROUGHBACKSLASH")) { throw new RuntimeException("Some shader author is trying to exploit internal Iris implementation details, stop!"); } - List booleanValues = getBooleanValues(shaderPackOptions); - Map stringValues = getStringValues(shaderPackOptions); + final List booleanValues = getBooleanValues(shaderPackOptions); + final Map stringValues = getStringValues(shaderPackOptions); try (Preprocessor pp = new Preprocessor()) { for (String value : booleanValues) { @@ -57,7 +59,7 @@ public class PropertiesPreprocessor { throw new RuntimeException("Some shader author is trying to exploit internal Iris implementation details, stop!"); } - Preprocessor preprocessor = new Preprocessor(); + final Preprocessor preprocessor = new Preprocessor(); try { for (StringPair envDefine : environmentDefines) { @@ -78,19 +80,23 @@ public class PropertiesPreprocessor { // Not super efficient, but this removes trailing whitespace on lines, fixing an issue with whitespace after // line continuations (see PreprocessorTest#testWeirdPropertiesLineContinuation) // Required for Voyager Shader - source = Arrays.stream(source.split("\\R")).map(String::trim) + source = Arrays.stream(source.split("\\R")).map(String::trim).filter(s -> !s.isEmpty()) .map(line -> { if (line.startsWith("#")) { - // In PropertyCollectingListener we suppress "unknown preprocessor directive errors" and - // assume the line to be a comment, since in .properties files `#` also functions as a comment - // marker. - return line; - } else { - // This is a hack to ensure that non-macro lines don't have any preprocessing applied... - // In properties files, we don't substitute #define values except on macro lines. - return "#warning IRIS_PASSTHROUGH " + line; + for (PreprocessorCommand command : PreprocessorCommand.values()) { + if (line.startsWith("#" + (command.name().replace("PP_", "").toLowerCase(Locale.ROOT)))) { + return line; + } + } + return ""; } + // In PropertyCollectingListener we suppress "unknown preprocessor directive errors" and + // assume the line to be a comment, since in .properties files `#` also functions as a comment + // marker. + return line.replace("#", ""); }).collect(Collectors.joining("\n")) + "\n"; + // TODO: This is a horrible fix to trick the preprocessor into not seeing the backslashes during processing. We need a better way to do this. + source = source.replace("\\", "IRIS_PASSTHROUGHBACKSLASH"); preprocessor.addInput(new StringLexerSource(source, true)); preprocessor.addFeature(Feature.KEEPCOMMENTS); @@ -110,7 +116,7 @@ public class PropertiesPreprocessor { source = builder.toString(); - return listener.collectLines() + source; + return (listener.collectLines() + source).replace("IRIS_PASSTHROUGHBACKSLASH", "\\"); } private static List getBooleanValues(ShaderPackOptions shaderPackOptions) { diff --git a/src/main/java/net/coderbot/iris/uniforms/BiomeUniforms.java b/src/main/java/net/coderbot/iris/uniforms/BiomeUniforms.java new file mode 100644 index 000000000..5bfd3ff95 --- /dev/null +++ b/src/main/java/net/coderbot/iris/uniforms/BiomeUniforms.java @@ -0,0 +1,369 @@ +package net.coderbot.iris.uniforms; + +import com.gtnewhorizons.angelica.compat.iris.BiomeCategoryCache; +import com.gtnewhorizons.angelica.compat.iris.ModdedBiomeDetector; +import net.coderbot.iris.gl.uniform.UniformHolder; +import net.coderbot.iris.parsing.BiomeCategories; +import net.minecraft.client.Minecraft; +import net.minecraft.util.MathHelper; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.BiomeGenBeach; +import net.minecraft.world.biome.BiomeGenDesert; +import net.minecraft.world.biome.BiomeGenEnd; +import net.minecraft.world.biome.BiomeGenForest; +import net.minecraft.world.biome.BiomeGenHell; +import net.minecraft.world.biome.BiomeGenHills; +import net.minecraft.world.biome.BiomeGenJungle; +import net.minecraft.world.biome.BiomeGenMesa; +import net.minecraft.world.biome.BiomeGenMushroomIsland; +import net.minecraft.world.biome.BiomeGenMutated; +import net.minecraft.world.biome.BiomeGenOcean; +import net.minecraft.world.biome.BiomeGenPlains; +import net.minecraft.world.biome.BiomeGenRiver; +import net.minecraft.world.biome.BiomeGenSavanna; +import net.minecraft.world.biome.BiomeGenSnow; +import net.minecraft.world.biome.BiomeGenStoneBeach; +import net.minecraft.world.biome.BiomeGenSwamp; +import net.minecraft.world.biome.BiomeGenTaiga; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.HashMap; +import java.util.Map; + +import static net.coderbot.iris.gl.uniform.UniformUpdateFrequency.PER_TICK; + +public class BiomeUniforms { + + private static final Logger LOGGER = LogManager.getLogger("BiomeUniforms"); + private static final Minecraft client = Minecraft.getMinecraft(); + + // Cache to avoid multiple biome lookups per tick + private static BiomeGenBase cachedBiome = null; + private static long cachedWorldTime = -1; + private static int cachedPlayerX = Integer.MIN_VALUE; + private static int cachedPlayerZ = Integer.MIN_VALUE; + + /** + * Adds biome-related uniforms that change based on the player's current biome. + */ + public static void addBiomeUniforms(UniformHolder uniforms) { + uniforms.uniform1i(PER_TICK, "biome", BiomeUniforms::getBiomeId) + .uniform1i(PER_TICK, "biome_category", BiomeUniforms::getBiomeCategory) + .uniform1i(PER_TICK, "biome_precipitation", BiomeUniforms::getBiomePrecipitation) + .uniform1f(PER_TICK, "rainfall", BiomeUniforms::getBiomeRainfall) + .uniform1f(PER_TICK, "temperature", BiomeUniforms::getBiomeTemperature); + } + + /** + * Gets the current biome, with caching to avoid repeated lookups within the same tick. + * Returns null if player or world is not available. + */ + private static BiomeGenBase getCachedBiome() { + if (client.thePlayer == null || client.theWorld == null) { + return null; + } + + final long worldTime = client.theWorld.getTotalWorldTime(); + final int playerX = MathHelper.floor_double(client.thePlayer.posX); + final int playerZ = MathHelper.floor_double(client.thePlayer.posZ); + + // Invalidate cache if time or position changed + if (cachedBiome == null || cachedWorldTime != worldTime || cachedPlayerX != playerX || cachedPlayerZ != playerZ) { + cachedBiome = client.theWorld.getBiomeGenForCoords(playerX, playerZ); + cachedWorldTime = worldTime; + cachedPlayerX = playerX; + cachedPlayerZ = playerZ; + } + + return cachedBiome; + } + + public static int getBiomePrecipitation() { + final BiomeGenBase biome = getCachedBiome(); + if (biome == null) { + return 0; + } + + if (!biome.enableRain && !biome.enableSnow) { + return 0; + } + + final float temp = biome.getFloatTemperature( + MathHelper.floor_double(client.thePlayer.posX), + MathHelper.floor_double(client.thePlayer.posY), + MathHelper.floor_double(client.thePlayer.posZ)); + + return temp > 0.15F ? 1 : 2; + } + + public static float getBiomeRainfall() { + final BiomeGenBase biome = getCachedBiome(); + return biome != null ? biome.rainfall : 0.0F; + } + + public static float getBiomeTemperature() { + final BiomeGenBase biome = getCachedBiome(); + return biome != null ? biome.temperature : 0.0F; + } + + public static int getBiomeId() { + final BiomeGenBase biome = getCachedBiome(); + return biome != null ? biome.biomeID : 0; + } + + public static int getBiomeCategory() { + final BiomeGenBase biome = getCachedBiome(); + if (biome == null) { + return BiomeCategories.NONE.ordinal(); + } + + // Check cache first + if (biome instanceof BiomeCategoryCache cache) { + final int cached = cache.iris$getCachedCategory(); + if (cached != -1) { + return cached; + } + + // Not cached yet, determine and cache it + final int category = determineBiomeCategory(biome); + cache.iris$setCachedCategory(category); + final BiomeCategories[] categories = BiomeCategories.values(); + final String categoryName = (category >= 0 && category < categories.length) + ? categories[category].name() + : "INVALID(" + category + ")"; + LOGGER.debug("Cached biome category for '{}': {}", biome.biomeName, categoryName); + + return category; + } + + // Fallback if mixin didn't apply (shouldn't happen) + return determineBiomeCategory(biome); + } + + private static int determineBiomeCategory(BiomeGenBase biome) { + // Tier 1: Hardcoded vanilla biome IDs + BiomeGenBase lookupBiome = biome; + if (biome instanceof BiomeGenMutated mutated && mutated.baseBiome != null) { + lookupBiome = mutated.baseBiome; + } + + BiomeCategories category = getVanillaBiomeCategory(lookupBiome.biomeID); + if (category != null) { + return category.ordinal(); + } + + // Tier 2: Class-based detection for vanilla biome types + category = detectVanillaBiomeByClass(biome); + if (category != null) { + return category.ordinal(); + } + + // Tier 3: Modded biome detection (BiomesOPlenty, Realistic World Gen) + category = detectModdedBiome(biome); + if (category != null) { + return category.ordinal(); + } + + // Tier 4: Name pattern matching + category = detectBiomeByName(biome); + if (category != null) { + return category.ordinal(); + } + + // Tier 5: Temperature/rainfall heuristics + category = detectBiomeByProperties(biome); + if (category != null) { + return category.ordinal(); + } + + // Default: NONE + return BiomeCategories.NONE.ordinal(); + } + + private static BiomeCategories getVanillaBiomeCategory(int biomeID) { + return switch (biomeID) { + // OCEAN + case 0, 10, 24 -> BiomeCategories.OCEAN; // ocean, frozenOcean, deepOcean + + // PLAINS + case 1 -> BiomeCategories.PLAINS; // plains + + // DESERT + case 2, 17 -> BiomeCategories.DESERT; // desert, desertHills + + // EXTREME_HILLS (Vanilla mountains) + case 3, 20, 34 -> BiomeCategories.EXTREME_HILLS; // extremeHills, extremeHillsEdge, extremeHillsPlus + + // FOREST + case 4, 18, 27, 28, 29 -> + BiomeCategories.FOREST; // forest, forestHills, birchForest, birchForestHills, roofedForest + + // TAIGA + case 5, 19, 30, 31, 32, 33 -> + BiomeCategories.TAIGA; // taiga, taigaHills, coldTaiga, coldTaigaHills, megaTaiga, megaTaigaHills + + // SWAMP + case 6 -> BiomeCategories.SWAMP; // swampland + + // RIVER + case 7, 11 -> BiomeCategories.RIVER; // river, frozenRiver + + // NETHER + case 8 -> BiomeCategories.NETHER; // hell + + // THE_END + case 9 -> BiomeCategories.THE_END; // sky + + // ICY + case 12, 13 -> BiomeCategories.ICY; // icePlains, iceMountains + + // MUSHROOM + case 14, 15 -> BiomeCategories.MUSHROOM; // mushroomIsland, mushroomIslandShore + + // BEACH + case 16, 25, 26 -> BiomeCategories.BEACH; // beach, stoneBeach, coldBeach + + // JUNGLE + case 21, 22, 23 -> BiomeCategories.JUNGLE; // jungle, jungleHills, jungleEdge + + // SAVANNA + case 35, 36 -> BiomeCategories.SAVANNA; // savanna, savannaPlateau + + // MESA + case 37, 38, 39 -> BiomeCategories.MESA; // mesa, mesaPlateau_F, mesaPlateau + + default -> null; // Not a vanilla biome or unknown + }; + } + + private static final Map, BiomeCategories> VANILLA_CLASS_MAP = createVanillaClassMap(); + + private static Map, BiomeCategories> createVanillaClassMap() { + final Map, BiomeCategories> map = new HashMap<>(); + // Most specific first (subclasses before superclasses) + map.put(BiomeGenStoneBeach.class, BiomeCategories.BEACH); + map.put(BiomeGenBeach.class, BiomeCategories.BEACH); + map.put(BiomeGenMushroomIsland.class, BiomeCategories.MUSHROOM); + map.put(BiomeGenOcean.class, BiomeCategories.OCEAN); + map.put(BiomeGenPlains.class, BiomeCategories.PLAINS); + map.put(BiomeGenDesert.class, BiomeCategories.DESERT); + map.put(BiomeGenHills.class, BiomeCategories.EXTREME_HILLS); + map.put(BiomeGenForest.class, BiomeCategories.FOREST); + map.put(BiomeGenTaiga.class, BiomeCategories.TAIGA); + map.put(BiomeGenSwamp.class, BiomeCategories.SWAMP); + map.put(BiomeGenRiver.class, BiomeCategories.RIVER); + map.put(BiomeGenHell.class, BiomeCategories.NETHER); + map.put(BiomeGenEnd.class, BiomeCategories.THE_END); + map.put(BiomeGenSnow.class, BiomeCategories.ICY); + map.put(BiomeGenJungle.class, BiomeCategories.JUNGLE); + map.put(BiomeGenSavanna.class, BiomeCategories.SAVANNA); + map.put(BiomeGenMesa.class, BiomeCategories.MESA); + return map; + } + + private static BiomeCategories detectVanillaBiomeByClass(BiomeGenBase biome) { + // Direct class lookup (O(1) for exact matches) + final BiomeCategories direct = VANILLA_CLASS_MAP.get(biome.getClass()); + if (direct != null) { + return direct; + } + + // Fallback: instanceof checks for subclasses (modded biomes extending vanilla) + for (Map.Entry, BiomeCategories> entry : VANILLA_CLASS_MAP.entrySet()) { + if (entry.getKey().isInstance(biome)) { + return entry.getValue(); + } + } + + return null; + } + + private static BiomeCategories detectModdedBiome(BiomeGenBase biome) { + return ModdedBiomeDetector.detectModdedBiome(biome); + } + + private static BiomeCategories detectBiomeByName(BiomeGenBase biome) { + if (biome.biomeName == null) return null; + + final String name = biome.biomeName.toLowerCase(); + + // Check for keywords in biome names + // Priority order matters - check more specific terms first + + if (name.contains("nether")) return BiomeCategories.NETHER; + if (name.contains("end")) return BiomeCategories.THE_END; + + if (name.contains("ocean") || name.contains("sea")) return BiomeCategories.OCEAN; + if (name.contains("river") || name.contains("stream")) return BiomeCategories.RIVER; + if (name.contains("beach") || name.contains("shore") || name.contains("coast")) return BiomeCategories.BEACH; + + if (name.contains("mushroom")) return BiomeCategories.MUSHROOM; + if (name.contains("swamp") || name.contains("marsh") || name.contains("bog")) return BiomeCategories.SWAMP; + + if (name.contains("jungle")) return BiomeCategories.JUNGLE; + if (name.contains("savanna") || name.contains("savannah")) return BiomeCategories.SAVANNA; + if (name.contains("mesa") || name.contains("badlands")) return BiomeCategories.MESA; + if (name.contains("desert")) return BiomeCategories.DESERT; + + // Mountain detection - for modded biomes + if (name.contains("mountain") || name.contains("peak") || name.contains("alpine") || + name.contains("cliff") || name.contains("crag")) return BiomeCategories.MOUNTAIN; + + // Ice/Snow detection + if (name.contains("ice") || name.contains("frozen") || name.contains("snow") || + name.contains("arctic") || name.contains("tundra") || name.contains("glacier")) return BiomeCategories.ICY; + + if (name.contains("taiga") || name.contains("boreal") || name.contains("conifer")) return BiomeCategories.TAIGA; + + if (name.contains("forest") || name.contains("wood") || name.contains("grove") || + name.contains("thicket")) return BiomeCategories.FOREST; + + if (name.contains("plain") || name.contains("field") || name.contains("meadow") || + name.contains("grassland") || name.contains("prairie")) return BiomeCategories.PLAINS; + + return null; + } + + private static BiomeCategories detectBiomeByProperties(BiomeGenBase biome) { + final float temp = biome.temperature; + final float rain = biome.rainfall; + + // Very cold biomes with snow + if (temp <= 0.0F && biome.enableSnow) { + return BiomeCategories.ICY; + } + + // Hot, dry biomes + if (temp >= 2.0F && !biome.enableRain) { + return BiomeCategories.DESERT; + } + + // Warm, dry biomes (savanna-like) + if (temp >= 1.0F && rain <= 0.1F && !biome.enableRain) { + return BiomeCategories.SAVANNA; + } + + // Wet biomes with high rainfall + if (rain >= 0.85F && temp >= 0.5F && temp <= 1.0F) { + return BiomeCategories.SWAMP; + } + + // Cold forested biomes + if (temp >= 0.0F && temp <= 0.4F && rain >= 0.4F) { + return BiomeCategories.TAIGA; + } + + // Temperate forested biomes + if (temp >= 0.4F && temp <= 0.9F && rain >= 0.5F) { + return BiomeCategories.FOREST; + } + + // Default to plains for temperate, moderate biomes + if (temp >= 0.4F && temp <= 1.0F && rain >= 0.3F && rain <= 0.6F) { + return BiomeCategories.PLAINS; + } + + return null; + } +} diff --git a/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java b/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java index 1b00f2cfc..6cb74b6b0 100644 --- a/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java +++ b/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java @@ -20,14 +20,11 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.AbstractTexture; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; -import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; -import net.minecraft.world.biome.BiomeGenBase; import org.joml.Math; import org.joml.Vector2f; import org.joml.Vector2i; @@ -53,6 +50,7 @@ public final class CommonUniforms { ViewportUniforms.addViewportUniforms(uniforms); WorldTimeUniforms.addWorldTimeUniforms(uniforms); SystemTimeUniforms.addSystemTimeUniforms(uniforms); + BiomeUniforms.addBiomeUniforms(uniforms); new CelestialUniforms(directives.getSunPathRotation()).addCelestialUniforms(uniforms); IrisExclusiveUniforms.addIrisExclusiveUniforms(uniforms); IdMapUniforms.addIdMapUniforms(updateNotifier, uniforms, idMap, directives.isOldHandLight()); @@ -67,6 +65,7 @@ public final class CommonUniforms { // Needs to use a LocationalUniformHolder as we need it for the common uniforms public static void addDynamicUniforms(DynamicUniformHolder uniforms) { + ExternallyManagedUniforms.addExternallyManagedUniforms116(uniforms); IdMapUniforms.addEntityIdMapUniforms(uniforms); FogUniforms.addFogUniforms(uniforms); @@ -113,6 +112,7 @@ public final class CommonUniforms { uniforms .uniform1f(ONCE, "darknessFactor", () -> 0.0F) // This is PER_FRAME in modern, it is an effect added by The Warden. We're just setting to 0 because 1.7.10 doesn't have it. + .uniform1f(ONCE, "darknessLightFactor", () -> 0.0F) // Warden darkness current light factor - 1.7.10 doesn't have it so hardcode to 0 .uniform1b(PER_FRAME, "hideGUI", () -> client.gameSettings.hideGUI) .uniform1i(PER_FRAME, "isEyeInWater", CommonUniforms::isEyeInWater) .uniform1f(PER_FRAME, "blindness", CommonUniforms::getBlindness) @@ -137,11 +137,7 @@ public final class CommonUniforms { .uniform1f(PER_TICK, "rainStrength", CommonUniforms::getRainStrength) .uniform1f(PER_TICK, "wetness", new SmoothedFloat(directives.getWetnessHalfLife(), directives.getDrynessHalfLife(), CommonUniforms::getRainStrength, updateNotifier)) .uniform3d(PER_FRAME, "skyColor", CommonUniforms::getSkyColor) - .uniform3d(PER_FRAME, "fogColor", GLStateManager::getFogColor) - - .uniform1i(PER_TICK, "biome_precipitation", CommonUniforms::getBiomePrecipitation) - .uniform1f(PER_TICK, "rainfall", CommonUniforms::getBiomeRainfall) - .uniform1f(PER_TICK, "temperature", CommonUniforms::getBiomeTemperature); + .uniform3d(PER_FRAME, "fogColor", GLStateManager::getFogColor); } private static boolean isOnGround() { @@ -153,38 +149,7 @@ public final class CommonUniforms { return (client.thePlayer != null && client.thePlayer.hurtTime > 0); } - private static BiomeGenBase getBiome() { - return client.theWorld.getBiomeGenForCoords(MathHelper.floor_double(client.thePlayer.posX), MathHelper.floor_double(client.thePlayer.posZ)); - } - - private static int getBiomePrecipitation() { - if (client.thePlayer == null || client.theWorld == null) { - return 0; - } - - BiomeGenBase biome = getBiome(); - float temp = biome.getFloatTemperature(MathHelper.floor_double(client.thePlayer.posX), MathHelper.floor_double(client.thePlayer.posY), MathHelper.floor_double(client.thePlayer.posZ)); - - if (!biome.enableRain && !biome.enableSnow) { - return 0; - } else if (temp > 0.15F) { - return 1; - } else { - return 2; - } - } - - private static float getBiomeRainfall() { - if (client.thePlayer == null || client.theWorld == null) return 0.0F; - return getBiome().rainfall; - } - - private static float getBiomeTemperature() { - if (client.thePlayer == null || client.theWorld == null) return 0.0F; - return getBiome().temperature; - } - - private static boolean isInvisible() { + private static boolean isInvisible() { return (client.thePlayer != null && client.thePlayer.isInvisible()); } diff --git a/src/main/java/net/coderbot/iris/uniforms/ExternallyManagedUniforms.java b/src/main/java/net/coderbot/iris/uniforms/ExternallyManagedUniforms.java index c4976a447..1a860d7a9 100644 --- a/src/main/java/net/coderbot/iris/uniforms/ExternallyManagedUniforms.java +++ b/src/main/java/net/coderbot/iris/uniforms/ExternallyManagedUniforms.java @@ -12,9 +12,9 @@ public class ExternallyManagedUniforms { addMat4(uniformHolder, "iris_ModelViewMatrix"); addMat4(uniformHolder, "u_ModelViewProjectionMatrix"); addMat4(uniformHolder, "iris_NormalMatrix"); - // Exclusive to pre-1.19 - addFloat(uniformHolder, "darknessFactor"); - addFloat(uniformHolder, "darknessLightFactor"); + + // 1.21.6+ + uniformHolder.externallyManagedUniform("heavyFog", UniformType.BOOL); } public static void addExternallyManagedUniforms116(UniformHolder uniformHolder) { diff --git a/src/main/java/net/coderbot/iris/uniforms/IrisExclusiveUniforms.java b/src/main/java/net/coderbot/iris/uniforms/IrisExclusiveUniforms.java index 3b3789031..6c5ede25a 100644 --- a/src/main/java/net/coderbot/iris/uniforms/IrisExclusiveUniforms.java +++ b/src/main/java/net/coderbot/iris/uniforms/IrisExclusiveUniforms.java @@ -1,16 +1,28 @@ package net.coderbot.iris.uniforms; +import com.gtnewhorizons.angelica.compat.mojang.Camera; +import com.gtnewhorizons.angelica.compat.mojang.GameModeUtil; import net.coderbot.iris.gl.uniform.UniformHolder; import net.coderbot.iris.gl.uniform.UniformUpdateFrequency; import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.PlayerControllerMP; import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.effect.EntityLightningBolt; import org.joml.Math; import org.joml.Vector3d; +import org.joml.Vector3dc; import org.joml.Vector4f; +import java.util.List; + public class IrisExclusiveUniforms { + // Reusable vectors to avoid allocations every frame + private static final Vector3d eyePositionCache = new Vector3d(); + private static final Vector3d relativeEyePositionCache = new Vector3d(); + private static final Vector4f lightningBoltPositionCache = new Vector4f(); + private static final Vector4f ZERO_VECTOR_4f = new Vector4f(0, 0, 0, 0); + public static void addIrisExclusiveUniforms(UniformHolder uniforms) { WorldInfoUniforms.addWorldInfoUniforms(uniforms); @@ -24,20 +36,10 @@ public class IrisExclusiveUniforms { uniforms.uniform1f(UniformUpdateFrequency.PER_TICK, "maxPlayerAir", IrisExclusiveUniforms::getMaxAir); uniforms.uniform1b(UniformUpdateFrequency.PER_FRAME, "firstPersonCamera", IrisExclusiveUniforms::isFirstPersonCamera); uniforms.uniform1b(UniformUpdateFrequency.PER_TICK, "isSpectator", IrisExclusiveUniforms::isSpectator); + uniforms.uniform1b(UniformUpdateFrequency.PER_TICK, "isRightHanded", () -> true); // 1.7.10 doesn't support left-handed mode uniforms.uniform3d(UniformUpdateFrequency.PER_FRAME, "eyePosition", IrisExclusiveUniforms::getEyePosition); - // TODO: Iris Shaders -// Vector4f zero = new Vector4f(0, 0, 0, 0); -// uniforms.uniform4f(UniformUpdateFrequency.PER_TICK, "lightningBoltPosition", () -> { -// if (Minecraft.getMinecraft().theWorld != null) { -// return StreamSupport.stream(Minecraft.getMinecraft().theWorld.entitiesForRendering().spliterator(), false).filter(bolt -> bolt instanceof LightningBolt).findAny().map(bolt -> { -// Vector3d unshiftedCameraPosition = CameraUniforms.getUnshiftedCameraPosition(); -// Vec3 vec3 = bolt.getPosition(Minecraft.getMinecraft().getDeltaFrameTime()); -// return new Vector4f((float) (vec3.x - unshiftedCameraPosition.x), (float) (vec3.y - unshiftedCameraPosition.y), (float) (vec3.z - unshiftedCameraPosition.z), 1); -// }).orElse(zero); -// } else { -// return zero; -// } -// }); + uniforms.uniform3d(UniformUpdateFrequency.PER_FRAME, "relativeEyePosition", IrisExclusiveUniforms::getRelativeEyePosition); + uniforms.uniform4f(UniformUpdateFrequency.PER_TICK, "lightningBoltPosition", IrisExclusiveUniforms::getLightningBoltPosition); } private static float getThunderStrength() { @@ -88,21 +90,40 @@ public class IrisExclusiveUniforms { private static boolean isFirstPersonCamera() { // If camera type is not explicitly third-person, assume it's first-person. - return (Minecraft.getMinecraft().gameSettings.thirdPersonView == 1); + return !Camera.INSTANCE.isThirdPerson(); } private static boolean isSpectator() { - final PlayerControllerMP controller = Minecraft.getMinecraft().playerController; - if(controller == null) - return false; - return controller.currentGameType.getID() == 3; + return GameModeUtil.isSpectator(); } private static Vector3d getEyePosition() { -// Objects.requireNonNull(Minecraft.getMinecraft().getCameraEntity()); -// return new Vector3d(Minecraft.getMinecraft().getCameraEntity().getX(), Minecraft.getMinecraft().getCameraEntity().getEyeY(), Minecraft.getMinecraft().getCameraEntity().getZ()); final EntityLivingBase eye = Minecraft.getMinecraft().renderViewEntity; - return new Vector3d(eye.posX, eye.posY, eye.posZ); + return eyePositionCache.set(eye.posX, eye.posY + eye.getEyeHeight(), eye.posZ); + } + + private static Vector3d getRelativeEyePosition() { + final Vector3dc cameraPos = CameraUniforms.getUnshiftedCameraPosition(); + final Vector3d eyePos = getEyePosition(); + return relativeEyePositionCache.set(eyePos).sub(cameraPos); + } + + private static Vector4f getLightningBoltPosition() { + if (Minecraft.getMinecraft().theWorld != null) { + final List weatherEffects = Minecraft.getMinecraft().theWorld.weatherEffects; + for (Entity entity : weatherEffects) { + if (entity instanceof EntityLightningBolt bolt) { + final Vector3dc cameraPos = CameraUniforms.getUnshiftedCameraPosition(); + return lightningBoltPositionCache.set( + (float)(bolt.posX - cameraPos.x()), + (float)(bolt.posY - cameraPos.y()), + (float)(bolt.posZ - cameraPos.z()), + 1.0f + ); + } + } + } + return ZERO_VECTOR_4f; } public static class WorldInfoUniforms { diff --git a/src/main/java/net/coderbot/iris/uniforms/VanillaBiomeList.java b/src/main/java/net/coderbot/iris/uniforms/VanillaBiomeList.java new file mode 100644 index 000000000..b13051bfa --- /dev/null +++ b/src/main/java/net/coderbot/iris/uniforms/VanillaBiomeList.java @@ -0,0 +1,85 @@ +package net.coderbot.iris.uniforms; + +import net.minecraft.world.biome.BiomeGenBase; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class VanillaBiomeList { + public static class BiomeEntry { + public final BiomeGenBase biome; + public final String name; + + public BiomeEntry(BiomeGenBase biome, String name) { + this.biome = biome; + this.name = name; + } + } + + private static final List VANILLA_BIOMES = createVanillaBiomeList(); + + private static List createVanillaBiomeList() { + final List biomes = new ArrayList<>(); + + // Vanilla biomes from BiomeGenBase static fields (IDs 0-39) + biomes.add(new BiomeEntry(BiomeGenBase.ocean, "OCEAN")); + biomes.add(new BiomeEntry(BiomeGenBase.plains, "PLAINS")); + biomes.add(new BiomeEntry(BiomeGenBase.desert, "DESERT")); + biomes.add(new BiomeEntry(BiomeGenBase.extremeHills, "EXTREME_HILLS")); + biomes.add(new BiomeEntry(BiomeGenBase.forest, "FOREST")); + biomes.add(new BiomeEntry(BiomeGenBase.taiga, "TAIGA")); + biomes.add(new BiomeEntry(BiomeGenBase.swampland, "SWAMPLAND")); + biomes.add(new BiomeEntry(BiomeGenBase.river, "RIVER")); + biomes.add(new BiomeEntry(BiomeGenBase.hell, "HELL")); + biomes.add(new BiomeEntry(BiomeGenBase.sky, "SKY")); + biomes.add(new BiomeEntry(BiomeGenBase.frozenOcean, "FROZEN_OCEAN")); + biomes.add(new BiomeEntry(BiomeGenBase.frozenRiver, "FROZEN_RIVER")); + biomes.add(new BiomeEntry(BiomeGenBase.icePlains, "ICE_PLAINS")); + biomes.add(new BiomeEntry(BiomeGenBase.iceMountains, "ICE_MOUNTAINS")); + biomes.add(new BiomeEntry(BiomeGenBase.mushroomIsland, "MUSHROOM_ISLAND")); + biomes.add(new BiomeEntry(BiomeGenBase.mushroomIslandShore, "MUSHROOM_ISLAND_SHORE")); + biomes.add(new BiomeEntry(BiomeGenBase.beach, "BEACH")); + biomes.add(new BiomeEntry(BiomeGenBase.desertHills, "DESERT_HILLS")); + biomes.add(new BiomeEntry(BiomeGenBase.forestHills, "FOREST_HILLS")); + biomes.add(new BiomeEntry(BiomeGenBase.taigaHills, "TAIGA_HILLS")); + biomes.add(new BiomeEntry(BiomeGenBase.extremeHillsEdge, "EXTREME_HILLS_EDGE")); + biomes.add(new BiomeEntry(BiomeGenBase.jungle, "JUNGLE")); + biomes.add(new BiomeEntry(BiomeGenBase.jungleHills, "JUNGLE_HILLS")); + biomes.add(new BiomeEntry(BiomeGenBase.jungleEdge, "JUNGLE_EDGE")); + biomes.add(new BiomeEntry(BiomeGenBase.deepOcean, "DEEP_OCEAN")); + biomes.add(new BiomeEntry(BiomeGenBase.stoneBeach, "STONE_BEACH")); + biomes.add(new BiomeEntry(BiomeGenBase.coldBeach, "COLD_BEACH")); + biomes.add(new BiomeEntry(BiomeGenBase.birchForest, "BIRCH_FOREST")); + biomes.add(new BiomeEntry(BiomeGenBase.birchForestHills, "BIRCH_FOREST_HILLS")); + biomes.add(new BiomeEntry(BiomeGenBase.roofedForest, "ROOFED_FOREST")); + biomes.add(new BiomeEntry(BiomeGenBase.coldTaiga, "COLD_TAIGA")); + biomes.add(new BiomeEntry(BiomeGenBase.coldTaigaHills, "COLD_TAIGA_HILLS")); + biomes.add(new BiomeEntry(BiomeGenBase.megaTaiga, "MEGA_TAIGA")); + biomes.add(new BiomeEntry(BiomeGenBase.megaTaigaHills, "MEGA_TAIGA_HILLS")); + biomes.add(new BiomeEntry(BiomeGenBase.extremeHillsPlus, "EXTREME_HILLS_PLUS")); + biomes.add(new BiomeEntry(BiomeGenBase.savanna, "SAVANNA")); + biomes.add(new BiomeEntry(BiomeGenBase.savannaPlateau, "SAVANNA_PLATEAU")); + biomes.add(new BiomeEntry(BiomeGenBase.mesa, "MESA")); + biomes.add(new BiomeEntry(BiomeGenBase.mesaPlateau_F, "MESA_PLATEAU_F")); + biomes.add(new BiomeEntry(BiomeGenBase.mesaPlateau, "MESA_PLATEAU")); + + // Modern End biome variants (1.9+) - all map to the single End biome in 1.7.10 + // This allows shaders expecting these constants to work + biomes.add(new BiomeEntry(BiomeGenBase.sky, "THE_END")); + biomes.add(new BiomeEntry(BiomeGenBase.sky, "SMALL_END_ISLANDS")); + biomes.add(new BiomeEntry(BiomeGenBase.sky, "END_MIDLANDS")); + biomes.add(new BiomeEntry(BiomeGenBase.sky, "END_HIGHLANDS")); + biomes.add(new BiomeEntry(BiomeGenBase.sky, "END_BARRENS")); + + return Collections.unmodifiableList(biomes); + } + + /** + * Returns the cached list of all vanilla biomes with their shader-friendly names. + * The list is immutable and created once during class initialization. + */ + public static List getVanillaBiomes() { + return VANILLA_BIOMES; + } +} diff --git a/src/main/resources/META-INF/angelica_at.cfg b/src/main/resources/META-INF/angelica_at.cfg index 83a03981f..003c55e3f 100644 --- a/src/main/resources/META-INF/angelica_at.cfg +++ b/src/main/resources/META-INF/angelica_at.cfg @@ -86,3 +86,4 @@ public net.minecraft.block.material.Material field_76240_I # isTranslucent public net.minecraft.world.biome.BiomeGenBase field_76765_S # enableRain public net.minecraft.world.biome.BiomeGenBase field_76766_R # enableSnow +public net.minecraft.world.biome.BiomeGenMutated field_150611_aD # baseBiome diff --git a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/MixinEntityRenderer.java b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/MixinEntityRenderer.java index 8ac588a44..0009659d3 100644 --- a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/MixinEntityRenderer.java +++ b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/MixinEntityRenderer.java @@ -1,5 +1,6 @@ package com.gtnewhorizons.angelica.mixins.early.angelica; +import com.gtnewhorizons.angelica.compat.mojang.Camera; import com.gtnewhorizons.angelica.mixins.interfaces.EntityRendererAccessor; import com.gtnewhorizons.angelica.rendering.RenderingState; import net.minecraft.client.Minecraft; @@ -19,15 +20,18 @@ public abstract class MixinEntityRenderer implements EntityRendererAccessor { @Invoker public abstract float invokeGetNightVisionBrightness(EntityPlayer entityPlayer, float partialTicks); - @Inject(method = "setupCameraTransform", at = @At(value = "TAIL")) - private void angelica$captureCameraMatrix(float partialTicks, int startTime, CallbackInfo ci) { + @Inject(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ActiveRenderInfo;updateRenderInfo(Lnet/minecraft/entity/player/EntityPlayer;Z)V", shift = At.Shift.AFTER)) + private void angelica$captureCameraMatrix(float partialTicks, long finishTimeNano, CallbackInfo ci) { final Minecraft mc = Minecraft.getMinecraft(); final EntityLivingBase viewEntity = mc.renderViewEntity; + Camera.INSTANCE.update(viewEntity, partialTicks); + + // Set RenderingState to use the correct camera position RenderingState.INSTANCE.setCameraPosition( - viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks, - viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks, - viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks + Camera.INSTANCE.getPos().x, + Camera.INSTANCE.getPos().y, + Camera.INSTANCE.getPos().z ); } diff --git a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinEntityRenderer.java b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinEntityRenderer.java index 47ae2afe8..d1ea5686e 100644 --- a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinEntityRenderer.java +++ b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/shaders/MixinEntityRenderer.java @@ -49,8 +49,7 @@ public abstract class MixinEntityRenderer implements IResourceManagerReloadListe @Inject(method = "renderWorld(FJ)V", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;dispatchRenderLast(Lnet/minecraft/client/renderer/RenderGlobal;F)V", remap = false)) private void iris$endLevelRender(float partialTicks, long limitTime, CallbackInfo callback, @Share("pipeline") LocalRef pipeline) { // TODO: Iris - final Camera camera = new Camera(mc.renderViewEntity, partialTicks); - HandRenderer.INSTANCE.renderTranslucent(partialTicks, camera, mc.renderGlobal, pipeline.get()); + HandRenderer.INSTANCE.renderTranslucent(partialTicks, Camera.INSTANCE, mc.renderGlobal, pipeline.get()); Minecraft.getMinecraft().mcProfiler.endStartSection("iris_final"); pipeline.get().finalizeLevelRendering(); pipeline.set(null); @@ -67,8 +66,7 @@ public abstract class MixinEntityRenderer implements IResourceManagerReloadListe @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;clipRenderersByFrustum(Lnet/minecraft/client/renderer/culling/ICamera;F)V", shift = At.Shift.AFTER), method = "renderWorld(FJ)V") private void iris$beginEntities(float partialTicks, long startTime, CallbackInfo ci, @Share("pipeline") LocalRef pipeline) { - final Camera camera = new Camera(mc.renderViewEntity, partialTicks); - pipeline.get().renderShadows((EntityRenderer) (Object) this, camera); + pipeline.get().renderShadows((EntityRenderer) (Object) this, Camera.INSTANCE); } diff --git a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/sodium/MixinBiomeGenBase.java b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/sodium/MixinBiomeGenBase.java index 01da56fda..7a67220c3 100644 --- a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/sodium/MixinBiomeGenBase.java +++ b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/sodium/MixinBiomeGenBase.java @@ -1,5 +1,6 @@ package com.gtnewhorizons.angelica.mixins.early.sodium; +import com.gtnewhorizons.angelica.compat.iris.BiomeCategoryCache; import com.gtnewhorizons.angelica.utils.EventUtils; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.event.terraingen.BiomeEvent; @@ -9,9 +10,11 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(BiomeGenBase.class) -public class MixinBiomeGenBase { - private final ThreadLocal waterColorEventLocal = ThreadLocal.withInitial(() -> new BiomeEvent.GetWaterColor((BiomeGenBase)(Object)this, 0));; - private final ThreadLocal grassColorEventLocal = ThreadLocal.withInitial(() -> new BiomeEvent.GetGrassColor((BiomeGenBase)(Object)this, 0));; +public class MixinBiomeGenBase implements BiomeCategoryCache { + @Unique + private int cachedBiomeCategory = -1; + private final ThreadLocal waterColorEventLocal = ThreadLocal.withInitial(() -> new BiomeEvent.GetWaterColor((BiomeGenBase)(Object)this, 0)); + private final ThreadLocal grassColorEventLocal = ThreadLocal.withInitial(() -> new BiomeEvent.GetGrassColor((BiomeGenBase)(Object)this, 0)); private final ThreadLocal foliageColorEventLocal = ThreadLocal.withInitial(() -> new BiomeEvent.GetFoliageColor((BiomeGenBase)(Object)this, 0)); @Unique @@ -41,4 +44,14 @@ public class MixinBiomeGenBase { prepareEvent(event, original); return event; } + + @Override + public int iris$getCachedCategory() { + return cachedBiomeCategory; + } + + @Override + public void iris$setCachedCategory(int category) { + this.cachedBiomeCategory = category; + } } diff --git a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/sodium/MixinRenderGlobal.java b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/sodium/MixinRenderGlobal.java index 88bdde667..acbc6e25a 100644 --- a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/sodium/MixinRenderGlobal.java +++ b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/sodium/MixinRenderGlobal.java @@ -1,6 +1,7 @@ package com.gtnewhorizons.angelica.mixins.early.sodium; import com.gtnewhorizons.angelica.compat.mojang.Camera; +import com.gtnewhorizons.angelica.compat.mojang.GameModeUtil; import com.gtnewhorizons.angelica.compat.toremove.MatrixStack; import com.gtnewhorizons.angelica.config.AngelicaConfig; import com.gtnewhorizons.angelica.mixins.interfaces.IRenderGlobalExt; @@ -20,7 +21,6 @@ import net.coderbot.iris.pipeline.WorldRenderingPhase; import net.coderbot.iris.pipeline.WorldRenderingPipeline; import net.coderbot.iris.uniforms.CapturedRenderingState; import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.PlayerControllerMP; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.renderer.RenderGlobal; import net.minecraft.client.renderer.RenderHelper; @@ -162,10 +162,8 @@ public class MixinRenderGlobal implements IRenderGlobalExt { if(pass == 0) { pipeline.setPhase(WorldRenderingPhase.TERRAIN_CUTOUT); } else if(pass == 1) { - final Camera camera = new Camera(mc.renderViewEntity, (float) partialTicks); - if (!ShadowRenderer.ACTIVE) { - iris$beginTranslucents(pipeline, camera); + iris$beginTranslucents(pipeline, Camera.INSTANCE); } pipeline.setPhase(WorldRenderingPhase.TERRAIN_TRANSLUCENT); @@ -204,10 +202,7 @@ public class MixinRenderGlobal implements IRenderGlobalExt { } private boolean isSpectatorMode() { - final PlayerControllerMP controller = Minecraft.getMinecraft().playerController; - if(controller == null) - return false; - return controller.currentGameType.getID() == 3; + return GameModeUtil.isSpectator(); } /** @@ -222,11 +217,10 @@ public class MixinRenderGlobal implements IRenderGlobalExt { final Frustrum frustum = (Frustrum) frustrum; boolean hasForcedFrustum = false; boolean spectator = isSpectatorMode(); - Camera camera = new Camera(mc.renderViewEntity, partialTicks); - frustum.setPosition(camera.getPos().x, camera.getPos().y, camera.getPos().z); + frustum.setPosition(Camera.INSTANCE.getPos().x, Camera.INSTANCE.getPos().y, Camera.INSTANCE.getPos().z); try { - this.renderer.updateChunks(camera, frustum, hasForcedFrustum, sodium$frame++, spectator); + this.renderer.updateChunks(Camera.INSTANCE, frustum, hasForcedFrustum, sodium$frame++, spectator); } finally { RenderDevice.exitManagedCode(); }