diff --git a/CHANGELOG.md b/CHANGELOG.md index 992f809c..2e4e950b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +> ### DynamicSurroundings-1.21.1-0.4.2 +**All Loaders** +* JAVA 21+ +* Architectury 13.0.8+ + +**Fabric** +* Fabric Loader >= 0.16.9 +* Fabric API >= 0.110.0+1.21. + +**NeoForge** +* NeoForge 21.1.84+ + +**Fixes** +* Disabling fog effect actually works +* Compatibility with Nostalgia Tweaks world fog effect + > ### DynamicSurroundings-1.21.1-0.4.1 **All Loaders** * JAVA 21+ diff --git a/common/src/main/java/org/orecruncher/dsurround/mixins/core/MixinFogRenderer.java b/common/src/main/java/org/orecruncher/dsurround/mixins/core/MixinFogRenderer.java index faa673ff..5bd7fe13 100644 --- a/common/src/main/java/org/orecruncher/dsurround/mixins/core/MixinFogRenderer.java +++ b/common/src/main/java/org/orecruncher/dsurround/mixins/core/MixinFogRenderer.java @@ -1,25 +1,34 @@ package org.orecruncher.dsurround.mixins.core; +import com.llamalad7.mixinextras.sugar.Local; +import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Camera; import net.minecraft.client.renderer.FogRenderer; -import net.minecraft.world.entity.Entity; import net.minecraft.world.level.material.FogType; import org.orecruncher.dsurround.eventing.ClientEventHooks; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(FogRenderer.class) public class MixinFogRenderer { - @Inject(method = "setupFog(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/FogRenderer$FogMode;FZF)V", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD) - private static void dsurround_renderFog(Camera camera, FogRenderer.FogMode fogMode, float f, boolean bl, float g, CallbackInfo ci, FogType fogType, Entity entity, FogRenderer.FogData fogData) { + @Inject(method = "setupFog(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/FogRenderer$FogMode;FZF)V", at = @At("RETURN")) + private static void dsurround_renderFog(Camera camera, FogRenderer.FogMode fogMode, float f, boolean bl, float g, CallbackInfo ci, @Local FogType fogType, @Local FogRenderer.FogData fogData) { if (fogData.mode != FogRenderer.FogMode.FOG_TERRAIN || fogType != FogType.NONE) return; - ClientEventHooks.FOG_RENDER_EVENT.raise().onRenderFog(fogData, f, g); + // At this point, Minecraft has already configured fog. It's possible that another + // mixin fired and configured as well. We cannot trust the state of fogData, so + // we interrogate the shader directly to see what was configured. (Nostalgic Tweaks + // uses this approach.) + var data = new FogRenderer.FogData(fogData.mode); + data.start = RenderSystem.getShaderFogStart(); + data.end = RenderSystem.getShaderFogEnd(); + data.shape = RenderSystem.getShaderFogShape(); + + ClientEventHooks.FOG_RENDER_EVENT.raise().onRenderFog(data, f, g); } } diff --git a/common/src/main/java/org/orecruncher/dsurround/processing/FogHandler.java b/common/src/main/java/org/orecruncher/dsurround/processing/FogHandler.java index e3ac1c19..6f3a891d 100644 --- a/common/src/main/java/org/orecruncher/dsurround/processing/FogHandler.java +++ b/common/src/main/java/org/orecruncher/dsurround/processing/FogHandler.java @@ -46,6 +46,9 @@ private void renderFog(FogRenderer.FogData data, float renderDistance, float par @Override protected void gatherDiagnostics(CollectDiagnosticsEvent event) { - event.add(CollectDiagnosticsEvent.Section.Systems, "Fog: %f/%f, %s, %s".formatted(this.lastData.start, this.lastData.end, this.lastData.shape, this.lastData.mode)); + if (this.fogCalculator.enabled()) + event.add(CollectDiagnosticsEvent.Section.Systems, "Fog: %f/%f, %s, %s".formatted(this.lastData.start, this.lastData.end, this.lastData.shape, this.lastData.mode)); + else + event.add(CollectDiagnosticsEvent.Section.Systems, "Fog: DISABLED"); } } diff --git a/common/src/main/java/org/orecruncher/dsurround/processing/fog/HolisticFogRangeCalculator.java b/common/src/main/java/org/orecruncher/dsurround/processing/fog/HolisticFogRangeCalculator.java index 61fbb957..2969bd19 100644 --- a/common/src/main/java/org/orecruncher/dsurround/processing/fog/HolisticFogRangeCalculator.java +++ b/common/src/main/java/org/orecruncher/dsurround/processing/fog/HolisticFogRangeCalculator.java @@ -37,13 +37,13 @@ public String getName() { @Override public boolean enabled() { - return true; + return this.fogOptions.enableFogEffects; } @NotNull public FogRenderer.FogData render(@NotNull final FogRenderer.FogData data, float renderDistance, float partialTick) { - if (!this.fogOptions.enableFogEffects) + if (!this.enabled()) return data; float start = data.start; diff --git a/gradle.properties b/gradle.properties index 14eb065e..975b7dd2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ org.gradle.parallel=true # Mod properties mod_name = Dynamic Surroundings -mod_description = Alters the fabric of Minecraft experience by weaving a tapestry of sound and visual effects -mod_version = 0.4.1 +mod_description = Alters the fabric of Minecraft experience by weaving a tapestry of sound and visual effects +mod_version = 0.4.2 mod_author = OreCruncher mod_license = MIT mod_issues_url = https://github.com/OreCruncher/DynamicSurroundingsFabric/issues