diff --git a/common/src/main/java/io/github/steveplays28/stevesrealisticsleep/mixin/client/gui/InGameHudMixin.java b/common/src/main/java/io/github/steveplays28/stevesrealisticsleep/mixin/client/gui/InGameHudMixin.java index 77dc33f..f67e777 100644 --- a/common/src/main/java/io/github/steveplays28/stevesrealisticsleep/mixin/client/gui/InGameHudMixin.java +++ b/common/src/main/java/io/github/steveplays28/stevesrealisticsleep/mixin/client/gui/InGameHudMixin.java @@ -1,25 +1,26 @@ package io.github.steveplays28.stevesrealisticsleep.mixin.client.gui; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import io.github.steveplays28.stevesrealisticsleep.StevesRealisticSleep; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.client.render.RenderTickCounter; import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Environment(EnvType.CLIENT) @Mixin(InGameHud.class) public class InGameHudMixin { - @WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getSleepTimer()I")) - private int stevesrealisticsleep$cancelSleepVignetteIfDisabled(ClientPlayerEntity instance, @NotNull Operation original) { + @Inject(method = "renderSleepOverlay", at = @At(value = "HEAD"), cancellable = true) + private void stevesrealisticsleep$cancelSleepVignetteIfDisabled(DrawContext context, RenderTickCounter tickCounter, @NotNull CallbackInfo ci) { if (StevesRealisticSleep.config.showSleepVignette) { - return original.call(instance); + return; } - return -1; + ci.cancel(); } }