From e9b96c435214fb6125875ee015f8efedf9b0be07 Mon Sep 17 00:00:00 2001 From: makamys Date: Fri, 15 Jul 2022 19:27:58 +0200 Subject: O(O)F --- .../java/makamys/neodymium/MixinConfigPlugin.java | 1 + .../ducks/IMixinGameSettings_OptiFine.java | 7 +++++++ .../neodymium/mixin/MixinGameSettings_OptiFine.java | 21 +++++++++++++++++++++ .../makamys/neodymium/renderer/NeoRenderer.java | 3 ++- src/main/java/makamys/neodymium/util/OFUtil.java | 10 ++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/main/java/makamys/neodymium/ducks/IMixinGameSettings_OptiFine.java create mode 100644 src/main/java/makamys/neodymium/mixin/MixinGameSettings_OptiFine.java (limited to 'src/main/java/makamys') diff --git a/src/main/java/makamys/neodymium/MixinConfigPlugin.java b/src/main/java/makamys/neodymium/MixinConfigPlugin.java index 6624a49..678fadd 100644 --- a/src/main/java/makamys/neodymium/MixinConfigPlugin.java +++ b/src/main/java/makamys/neodymium/MixinConfigPlugin.java @@ -43,6 +43,7 @@ public class MixinConfigPlugin implements IMixinConfigPlugin { if (OFUtil.isOptiFinePresent()) { System.out.println("Detected OptiFine"); mixins.add("MixinRenderGlobal_OptiFine"); + mixins.add("MixinGameSettings_OptiFine"); } if(Config.replaceOpenGLSplash) { diff --git a/src/main/java/makamys/neodymium/ducks/IMixinGameSettings_OptiFine.java b/src/main/java/makamys/neodymium/ducks/IMixinGameSettings_OptiFine.java new file mode 100644 index 0000000..f7f4850 --- /dev/null +++ b/src/main/java/makamys/neodymium/ducks/IMixinGameSettings_OptiFine.java @@ -0,0 +1,7 @@ +package makamys.neodymium.ducks; + +public interface IMixinGameSettings_OptiFine { + + public int getOfFogType(); + +} diff --git a/src/main/java/makamys/neodymium/mixin/MixinGameSettings_OptiFine.java b/src/main/java/makamys/neodymium/mixin/MixinGameSettings_OptiFine.java new file mode 100644 index 0000000..43fa0b9 --- /dev/null +++ b/src/main/java/makamys/neodymium/mixin/MixinGameSettings_OptiFine.java @@ -0,0 +1,21 @@ +package makamys.neodymium.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Shadow; + +import makamys.neodymium.ducks.IMixinGameSettings_OptiFine; +import net.minecraft.client.settings.GameSettings; + +@Mixin(value = GameSettings.class, remap = false) +@Pseudo +public class MixinGameSettings_OptiFine implements IMixinGameSettings_OptiFine { + + @Shadow + private int ofFogType; + + public int getOfFogType() { + return ofFogType; + } + +} diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java index 4fe459c..3762dea 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -29,6 +29,7 @@ import makamys.neodymium.config.Config; import makamys.neodymium.ducks.IWorldRenderer; import makamys.neodymium.renderer.Mesh.GPUStatus; import makamys.neodymium.util.GuiHelper; +import makamys.neodymium.util.OFUtil; import makamys.neodymium.util.Preprocessor; import makamys.neodymium.util.Util; import net.minecraft.client.Minecraft; @@ -616,7 +617,7 @@ public class NeoRenderer { case FALSE: return false; default: - return GL11.glIsEnabled(GL11.GL_FOG); + return GL11.glIsEnabled(GL11.GL_FOG) && !OFUtil.isFogOff(); } } diff --git a/src/main/java/makamys/neodymium/util/OFUtil.java b/src/main/java/makamys/neodymium/util/OFUtil.java index a26177f..c98a651 100644 --- a/src/main/java/makamys/neodymium/util/OFUtil.java +++ b/src/main/java/makamys/neodymium/util/OFUtil.java @@ -1,6 +1,8 @@ package makamys.neodymium.util; import makamys.neodymium.MixinConfigPlugin; +import makamys.neodymium.ducks.IMixinGameSettings_OptiFine; +import net.minecraft.client.Minecraft; public class OFUtil { private static boolean isOptiFinePresent = MixinConfigPlugin.class.getResource("/optifine/OptiFineTweaker.class") != null; @@ -8,4 +10,12 @@ public class OFUtil { public static boolean isOptiFinePresent() { return isOptiFinePresent; } + + public static boolean isFogOff() { + return isOptiFinePresent && getIsFogOff(); + } + + private static boolean getIsFogOff() { + return ((IMixinGameSettings_OptiFine)Minecraft.getMinecraft().gameSettings).getOfFogType() == 3; + } } -- cgit