From a30fda126292a140a4be7553caa9db9d858a4625 Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Sat, 21 Feb 2026 14:59:32 +0100 Subject: [PATCH] Use a mixin for the gamma boost feature Fixes it being reset by the graphics settings screen, and doesn't need to modify the option Signed-off-by: Username404-59 --- .../snowygui/mixins/GammaMixin.java | 23 +++++++++++++++++++ .../snowygui/gui/feature/GammaBoost.kt | 15 +----------- .../resources/snowygui-common.mixins.json | 4 +++- 3 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 common/src/main/java/fr/username404/snowygui/mixins/GammaMixin.java diff --git a/common/src/main/java/fr/username404/snowygui/mixins/GammaMixin.java b/common/src/main/java/fr/username404/snowygui/mixins/GammaMixin.java new file mode 100644 index 0000000..a0b8368 --- /dev/null +++ b/common/src/main/java/fr/username404/snowygui/mixins/GammaMixin.java @@ -0,0 +1,23 @@ +package fr.username404.snowygui.mixins; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import fr.username404.snowygui.gui.feature.GammaBoost; +import net.minecraft.client.renderer.LightTexture; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(LightTexture.class) +abstract class GammaMixin { + @ModifyExpressionValue( + method = "updateLightTexture(F)V", at = @At( + value = "INVOKE", + target = "Ljava/lang/Double;floatValue()F", + ordinal = 1 + ) + ) + public float highGamma(float original) { + if (GammaBoost.INSTANCE.getToggled()) + return GammaBoost.BOOST; + return original; + } +} diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/GammaBoost.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/GammaBoost.kt index 7956a20..d48246b 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/GammaBoost.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/GammaBoost.kt @@ -1,19 +1,6 @@ package fr.username404.snowygui.gui.feature -import net.minecraft.client.Minecraft - @ButtonInfo(Category.MISC) object GammaBoost: ButtonImpl() { - private const val boost = 1400.0 - private var oldGamma = 0.0 - override fun execAction() { - with(Minecraft.getInstance().options) { - val gamma = gamma().get() - gamma().value = - if (toggled) { - if (gamma < boost) oldGamma = gamma - boost - } else oldGamma - } - } + const val BOOST = 1400.0F } \ No newline at end of file diff --git a/common/src/main/resources/snowygui-common.mixins.json b/common/src/main/resources/snowygui-common.mixins.json index 315916e..8afc7b6 100644 --- a/common/src/main/resources/snowygui-common.mixins.json +++ b/common/src/main/resources/snowygui-common.mixins.json @@ -2,7 +2,9 @@ "required": true, "package": "fr.username404.snowygui.mixins", "compatibilityLevel": "JAVA_18", - "client": [], + "client": [ + "GammaMixin" + ], "injectors": { "defaultRequire": 1 },