From c7861b6066332e92e27d42b937edd95de954b6e3 Mon Sep 17 00:00:00 2001 From: ev chang Date: Thu, 25 Jul 2024 02:24:53 +0900 Subject: [PATCH] OptiFine Custom Sky Fix --- .../sk1er/patcher/config/PatcherConfig.java | 19 ++++++++++++++++--- .../RenderGlobalMixin_FixSkyVBOs.java | 15 +++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/main/java/club/sk1er/patcher/config/PatcherConfig.java b/src/main/java/club/sk1er/patcher/config/PatcherConfig.java index 18b39b26b..96a39e813 100644 --- a/src/main/java/club/sk1er/patcher/config/PatcherConfig.java +++ b/src/main/java/club/sk1er/patcher/config/PatcherConfig.java @@ -73,11 +73,24 @@ public class PatcherConfig extends Config { @Switch( name = "Player Void Rendering", description = "Resolve the black box around the player while in the void.", - category = "Bug Fixes", subcategory = "Rendering", - size = 2 + category = "Bug Fixes", subcategory = "Rendering", size = 2 ) public static boolean playerVoidRendering = true; + @Info( + text = "OptiFine Custom Sky Fix also changes the rendering of the normal sky. Some people may prefer the original rendering.", + category = "Bug Fixes", subcategory = "Rendering", + type = InfoType.WARNING, size = 2 + ) + private static String customSkyFixInfo = ""; + + @Switch( + name = "OptiFine Custom Sky Fix", + description = "Resolve OptiFine creating a \"black box\" effect at the bottom of the sky when using custom skies.", + category = "Bug Fixes", subcategory = "Rendering", size = 2 + ) + public static boolean customSkyFix = true; + @Info( text = "Alex Arm Position requires a restart once toggled.", category = "Bug Fixes", subcategory = "Rendering", @@ -1988,7 +2001,7 @@ public PatcherConfig() { "scrollToZoom", "normalZoomSensitivity", "customZoomSensitivity", "smoothZoomAnimation", "smoothZoomAnimationWhenScrolling", "smoothZoomAlgorithm", "toggleToZoom", "normalFpsCounter", "useVanillaMetricsRenderer", "renderHandWhenZoomed", "smartFullbright", "smartEntityCulling", - "dynamicZoomSensitivity" + "dynamicZoomSensitivity", "customSkyFix" ).forEach(property -> hideIf(property, noOptiFine)); Supplier smoothFontDetected = () -> ClassTransformer.smoothFontDetected; diff --git a/src/main/java/club/sk1er/patcher/mixins/bugfixes/optifine/RenderGlobalMixin_FixSkyVBOs.java b/src/main/java/club/sk1er/patcher/mixins/bugfixes/optifine/RenderGlobalMixin_FixSkyVBOs.java index 2bc1f190f..cdbc56b2d 100644 --- a/src/main/java/club/sk1er/patcher/mixins/bugfixes/optifine/RenderGlobalMixin_FixSkyVBOs.java +++ b/src/main/java/club/sk1er/patcher/mixins/bugfixes/optifine/RenderGlobalMixin_FixSkyVBOs.java @@ -1,15 +1,26 @@ package club.sk1er.patcher.mixins.bugfixes.optifine; +import club.sk1er.patcher.config.PatcherConfig; import net.minecraft.client.renderer.RenderGlobal; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.Slice; @Mixin(RenderGlobal.class) public class RenderGlobalMixin_FixSkyVBOs { + + @Dynamic("OptiFine") + @Shadow + private int renderDistance; + + @Dynamic("OptiFine") + @Shadow + private boolean vboEnabled = false; + @Dynamic("OptiFine") @Redirect( method = "renderSky(Lnet/minecraft/client/renderer/WorldRenderer;FZ)V", @@ -21,7 +32,7 @@ public class RenderGlobalMixin_FixSkyVBOs { ) ) private int patcher$distanceOverride(RenderGlobal instance) { - return 256; + return PatcherConfig.customSkyFix ? 256 : this.renderDistance; } @Dynamic("OptiFine") @@ -35,6 +46,6 @@ public class RenderGlobalMixin_FixSkyVBOs { ) ) private boolean patcher$fixVBO(RenderGlobal instance) { - return false; + return !PatcherConfig.customSkyFix && this.vboEnabled; } }