From 7dc4512bb70908e2186f03504c4ac4efc233974d Mon Sep 17 00:00:00 2001 From: NotRyken <127091011+NotRyken@users.noreply.github.com> Date: Sat, 24 Aug 2024 13:27:15 +0800 Subject: [PATCH] Revert GUI mixin and de-prioritize --- changelog.md | 2 +- .../effecttimerplus/mixin/MixinGui.java | 38 +++++++------------ 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/changelog.md b/changelog.md index 19633ee..6c998f2 100644 --- a/changelog.md +++ b/changelog.md @@ -1,2 +1,2 @@ - Add Ukrainian translation (Tarteroycc) -- Improve GUI mixin +- Improve compatibility with Simple Voice Chat diff --git a/common/src/main/java/dev/terminalmc/effecttimerplus/mixin/MixinGui.java b/common/src/main/java/dev/terminalmc/effecttimerplus/mixin/MixinGui.java index 571b623..454bb81 100644 --- a/common/src/main/java/dev/terminalmc/effecttimerplus/mixin/MixinGui.java +++ b/common/src/main/java/dev/terminalmc/effecttimerplus/mixin/MixinGui.java @@ -5,6 +5,7 @@ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; import dev.terminalmc.effecttimerplus.config.Config; +import net.minecraft.client.DeltaTracker; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiGraphics; @@ -13,13 +14,14 @@ import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.List; -import java.util.function.Consumer; import static dev.terminalmc.effecttimerplus.util.IndicatorUtil.*; -@Mixin(value = Gui.class, priority = 500) +@Mixin(value = Gui.class, priority = 2000) public class MixinGui { @Final @@ -30,16 +32,22 @@ public class MixinGui { @Nullable private Runnable effectTimerPlus$runnable; - @Unique - private void effectTimerPlus$scale(GuiGraphics graphics) { + @Inject( + method = "renderEffects", + at = @At("HEAD") + ) + private void scale(GuiGraphics graphics, DeltaTracker delta, CallbackInfo ci) { float scale = (float) Config.get().scale; graphics.pose().pushPose(); graphics.pose().translate(graphics.guiWidth() * (1 - scale), 0.0F, 0.0F); graphics.pose().scale(scale, scale, 0.0F); } - @Unique - private void effectTimerPlus$descale(GuiGraphics graphics) { + @Inject( + method = "renderEffects", + at = @At("RETURN") + ) + private void descale(GuiGraphics graphics, DeltaTracker delta, CallbackInfo ci) { graphics.pose().popPose(); } @@ -53,9 +61,7 @@ public class MixinGui { private void CreateOverlayRunnable(GuiGraphics graphics, ResourceLocation sprite, int x, int y, int width, int height, Operation original, @Local MobEffectInstance effectInstance) { - effectTimerPlus$scale(graphics); original.call(graphics, sprite, x, y, width, height); - effectTimerPlus$descale(graphics); Config options = Config.get(); effectTimerPlus$runnable = () -> { @@ -119,20 +125,4 @@ private boolean AddOverlayRunnable(boolean original, @Local List runna } return original; } - - @WrapOperation( - method = "renderEffects", - at = @At( - value = "INVOKE", - target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V" - ) - ) - private void scale(List instance, Consumer consumer, Operation original, - @Local(argsOnly = true) GuiGraphics graphics) { - effectTimerPlus$scale(graphics); - - original.call(instance, consumer); - - effectTimerPlus$descale(graphics); - } }