-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
OreCruncher
committed
Jan 1, 2025
1 parent
4fbe3fa
commit 4b9fb8a
Showing
5 changed files
with
38 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 14 additions & 5 deletions
19
common/src/main/java/org/orecruncher/dsurround/mixins/core/MixinFogRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters