From 0c4edbca8dcd5e5f03725ddcfedbb45c62976250 Mon Sep 17 00:00:00 2001 From: IMS212 <31803019+IMS212@users.noreply.github.com> Date: Wed, 26 May 2021 20:10:58 -0700 Subject: [PATCH] Make requested changes --- gradle/wrapper/gradle-wrapper.properties | 2 +- .../iris/mixin/MixinBackgroundRenderer.java | 4 ++-- .../iris/uniforms/CapturedRenderingState.java | 15 +++++++++++++++ .../coderbot/iris/uniforms/CommonUniforms.java | 13 +------------ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f371643eed..0f80bbf516 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/net/coderbot/iris/mixin/MixinBackgroundRenderer.java b/src/main/java/net/coderbot/iris/mixin/MixinBackgroundRenderer.java index b3e150fe39..365950cc51 100644 --- a/src/main/java/net/coderbot/iris/mixin/MixinBackgroundRenderer.java +++ b/src/main/java/net/coderbot/iris/mixin/MixinBackgroundRenderer.java @@ -1,6 +1,6 @@ package net.coderbot.iris.mixin; -import net.coderbot.iris.uniforms.CommonUniforms; +import net.coderbot.iris.uniforms.CapturedRenderingState; import net.minecraft.client.render.BackgroundRenderer; import net.minecraft.client.render.Camera; import net.minecraft.client.world.ClientWorld; @@ -15,6 +15,6 @@ public class MixinBackgroundRenderer { @Shadow private static float red, green, blue; @Inject(method = "render", at = @At("TAIL")) private static void render(Camera camera, float tickDelta, ClientWorld world, int i, float f, CallbackInfo ci) { - CommonUniforms.setFogColor(red, green, blue); + CapturedRenderingState.INSTANCE.setFogColor(red, green, blue); } } diff --git a/src/main/java/net/coderbot/iris/uniforms/CapturedRenderingState.java b/src/main/java/net/coderbot/iris/uniforms/CapturedRenderingState.java index 1d9450c08e..0ec219e097 100644 --- a/src/main/java/net/coderbot/iris/uniforms/CapturedRenderingState.java +++ b/src/main/java/net/coderbot/iris/uniforms/CapturedRenderingState.java @@ -1,14 +1,17 @@ package net.coderbot.iris.uniforms; import net.minecraft.block.entity.BlockEntity; +import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.util.math.Matrix4f; +import net.minecraft.util.math.Vec3d; public class CapturedRenderingState { public static final CapturedRenderingState INSTANCE = new CapturedRenderingState(); private Matrix4f gbufferModelView; private Matrix4f gbufferProjection; + private Vec3d fogColor; private float tickDelta; private BlockEntity currentRenderedBlockEntity; private Entity currentRenderedEntity; @@ -32,6 +35,18 @@ public void setGbufferProjection(Matrix4f gbufferProjection) { this.gbufferProjection = gbufferProjection.copy(); } + public Vec3d getFogColor() { + if (MinecraftClient.getInstance().world == null || fogColor == null) { + return Vec3d.ZERO; + } + + return fogColor; + } + + public void setFogColor(float red, float green, float blue) { + fogColor = new Vec3d(red, green, blue); + } + public void setTickDelta(float tickDelta) { this.tickDelta = tickDelta; } diff --git a/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java b/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java index fb69511a79..0ebdfdd770 100644 --- a/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java +++ b/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java @@ -21,10 +21,8 @@ import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; import net.minecraft.tag.FluidTags; -import net.minecraft.util.CubicSampler; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec2f; import net.minecraft.util.math.Vec3d; import net.minecraft.world.LightType; @@ -34,7 +32,6 @@ public final class CommonUniforms { private static final MinecraftClient client = MinecraftClient.getInstance(); - private static Vec3d fogColor; private CommonUniforms() { // no construction allowed @@ -71,7 +68,7 @@ public static void generalCommonUniforms(UniformHolder uniforms){ .uniform1f(PER_TICK, "rainStrength", CommonUniforms::getRainStrength) .uniform1f(PER_TICK, "wetness", new SmoothedFloat(600f, CommonUniforms::getRainStrength)) .uniform3d(PER_FRAME, "skyColor", CommonUniforms::getSkyColor) - .uniform3d(PER_FRAME, "fogColor", CommonUniforms::getFogColor); + .uniform3d(PER_FRAME, "fogColor", CapturedRenderingState.INSTANCE::getFogColor); } private static Vec3d getSkyColor() { @@ -82,14 +79,6 @@ private static Vec3d getSkyColor() { return client.world.method_23777(client.cameraEntity.getBlockPos(), CapturedRenderingState.INSTANCE.getTickDelta()); } - private static Vec3d getFogColor() { - return fogColor; - } - - public static void setFogColor(float red, float green, float blue) { - fogColor = new Vec3d(red, green, blue); - } - private static float getBlindness() { Entity cameraEntity = client.getCameraEntity();