Skip to content

Commit a5b406b

Browse files
fix: Disable HUDCaching when rendering vignettes
1 parent a659be0 commit a5b406b

File tree

5 files changed

+68
-3
lines changed

5 files changed

+68
-3
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Skytils - Hypixel Skyblock Quality of Life Mod
3+
* Copyright (C) 2020-2024 Skytils
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published
7+
* by the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
package gg.skytils.skytilsmod.mixins.transformers.patcher;
20+
21+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
22+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
23+
import gg.skytils.skytilsmod.utils.PatcherCompatability;
24+
import net.minecraft.client.gui.GuiIngame;
25+
import net.minecraft.client.renderer.EntityRenderer;
26+
import org.objectweb.asm.Opcodes;
27+
import org.spongepowered.asm.mixin.Dynamic;
28+
import org.spongepowered.asm.mixin.Mixin;
29+
import org.spongepowered.asm.mixin.Pseudo;
30+
import org.spongepowered.asm.mixin.injection.At;
31+
32+
@Pseudo
33+
@Mixin(targets = "club.sk1er.patcher.screen.render.caching.HUDCaching")
34+
public abstract class MixinHUDCaching {
35+
@Dynamic
36+
@WrapOperation(method = "renderCachedHud", at = @At(value = "FIELD", target = "Lclub/sk1er/patcher/config/PatcherConfig;hudCaching:Z", opcode = Opcodes.GETSTATIC))
37+
private static boolean renderCachedHud(Operation<Boolean> original, EntityRenderer renderer, GuiIngame guiIngame) {
38+
return !PatcherCompatability.INSTANCE.getDisableHUDCaching() && original.call();
39+
}
40+
}

src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ object Config : Vigilant(
17171717

17181718
@Property(
17191719
type = PropertyType.PERCENT_SLIDER, name = "Low Health Vignette Threshold",
1720-
description = "Render a red vignette on the edge of the screen when your health drops below this threshold. Set to 0.0%% to disable.",
1720+
description = "Render a red vignette on the edge of the screen when your health drops below this threshold. Set to 0.0%% to disable.\n§cThis feature will temporarily disable HUD Caching while active.",
17211721
category = "Miscellaneous", subcategory = "Quality of Life"
17221722
)
17231723
var lowHealthVignetteThreshold = 0.0f

src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import gg.skytils.skytilsmod.utils.RenderUtil.renderItem
4343
import gg.skytils.skytilsmod.utils.RenderUtil.renderTexture
4444
import gg.skytils.skytilsmod.utils.Utils.equalsOneOf
4545
import gg.skytils.skytilsmod.utils.graphics.ScreenRenderer
46-
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer
4746
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer.TextAlignment
4847
import gg.skytils.skytilsmod.utils.graphics.colors.CommonColors
4948
import net.minecraft.block.BlockEndPortalFrame
@@ -334,8 +333,10 @@ object MiscFeatures {
334333
if (healthPercentage < Skytils.config.lowHealthVignetteThreshold) {
335334
val color =
336335
Skytils.config.lowHealthVignetteColor.withAlpha((Skytils.config.lowHealthVignetteColor.alpha * (1.0 - healthPercentage)).toInt())
336+
337+
PatcherCompatability.disableHUDCaching = true
337338
RenderUtil.drawVignette(color)
338-
}
339+
} else PatcherCompatability.disableHUDCaching = false
339340
}
340341

341342
@SubscribeEvent
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Skytils - Hypixel Skyblock Quality of Life Mod
3+
* Copyright (C) 2020-2024 Skytils
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published
7+
* by the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
package gg.skytils.skytilsmod.utils
20+
21+
object PatcherCompatability {
22+
var disableHUDCaching = false
23+
}

src/main/resources/mixins.skytils.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"neu.MixinStorageOverlay",
5757
"neu.MixinTradeWindow",
5858
"particle.MixinEffectRenderer",
59+
"patcher.MixinHUDCaching",
5960
"renderer.MixinBlockRendererDispatcher",
6061
"renderer.MixinEntityRenderer",
6162
"renderer.MixinInventoryEffectRenderer",

0 commit comments

Comments
 (0)