Skip to content

Commit

Permalink
OptiFine Custom Sky Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Jul 24, 2024
1 parent 40406d3 commit c7861b6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
19 changes: 16 additions & 3 deletions src/main/java/club/sk1er/patcher/config/PatcherConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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<Boolean> smoothFontDetected = () -> ClassTransformer.smoothFontDetected;
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -21,7 +32,7 @@ public class RenderGlobalMixin_FixSkyVBOs {
)
)
private int patcher$distanceOverride(RenderGlobal instance) {
return 256;
return PatcherConfig.customSkyFix ? 256 : this.renderDistance;
}

@Dynamic("OptiFine")
Expand All @@ -35,6 +46,6 @@ public class RenderGlobalMixin_FixSkyVBOs {
)
)
private boolean patcher$fixVBO(RenderGlobal instance) {
return false;
return !PatcherConfig.customSkyFix && this.vboEnabled;
}
}

0 comments on commit c7861b6

Please sign in to comment.