From 0720ed52cb765816cbbc63378f30552a71875c1b Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Sat, 27 Jul 2024 03:09:03 +0800 Subject: [PATCH] Fixed `flawlessFrames` does not work after the first enabling nobody knows how was this code written resolved #70 --- .../tweakermore/config/TweakerMoreConfigs.java | 2 +- .../flawlessFrames/FlawlessFramesHandler.java | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java b/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java index e1454689..47b4fe0b 100644 --- a/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java +++ b/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java @@ -922,7 +922,7 @@ public static void initConfigs() OF_SANTA_HAT.setValueChangeCallback(OptifinePlayerExtraModelOverrider::onConfigValueChanged); OF_WITCH_HAT.setValueChangeCallback(OptifinePlayerExtraModelOverrider::onConfigValueChanged); PARTICLE_LIMIT.setValueChangeCallback(ParticleLimitHelper::onConfigValueChanged); - FLAWLESS_FRAMES.setValueChangeCallback(config -> FlawlessFramesHandler.setEnabled(config.getBooleanValue())); + FLAWLESS_FRAMES.setValueChangeCallback(FlawlessFramesHandler::onConfigValueChanged); // debugs TWEAKERMORE_DEBUG_MODE.setValueChangeCallback(redrawConfigGui); diff --git a/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/flawlessFrames/FlawlessFramesHandler.java b/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/flawlessFrames/FlawlessFramesHandler.java index 9682f496..d1324876 100644 --- a/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/flawlessFrames/FlawlessFramesHandler.java +++ b/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/flawlessFrames/FlawlessFramesHandler.java @@ -21,8 +21,8 @@ package me.fallenbreath.tweakermore.impl.mc_tweaks.flawlessFrames; import com.google.common.collect.ImmutableList; +import fi.dy.masa.malilib.config.options.ConfigBoolean; import me.fallenbreath.tweakermore.TweakerMoreMod; -import me.fallenbreath.tweakermore.config.TweakerMoreConfigs; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.WorldRenderer; @@ -77,14 +77,12 @@ private static void uninstallHook() { TweakerMoreMod.LOGGER.error("Failed to invoke method uninstall of replay flawless rendering hook {}", hook, e); } + hook = null; } - public static void setEnabled(boolean enabled) + public static void onConfigValueChanged(ConfigBoolean config) { - if (!TweakerMoreConfigs.FLAWLESS_FRAMES.getTweakerMoreOption().isEnabled()) - { - return; - } + boolean enabled = config.getBooleanValue(); if (hook == null && enabled) { installHook();