Skip to content

Commit

Permalink
fix: Fix crash on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveplays28 committed Sep 8, 2024
1 parent 5ff3e01 commit 411b0e8
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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<Integer> 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();
}
}

0 comments on commit 411b0e8

Please sign in to comment.