|  | 
|  | 1 | +package dev.tildejustin.half_heart_hardcore.mixin; | 
|  | 2 | + | 
|  | 3 | +import net.minecraft.client.MinecraftClient; | 
|  | 4 | +import net.minecraft.client.gui.DrawableHelper; | 
|  | 5 | +import net.minecraft.client.gui.hud.InGameHud; | 
|  | 6 | +import net.minecraft.entity.player.ClientPlayerEntity; | 
|  | 7 | +import org.spongepowered.asm.mixin.Mixin; | 
|  | 8 | +import org.spongepowered.asm.mixin.Unique; | 
|  | 9 | +import org.spongepowered.asm.mixin.injection.At; | 
|  | 10 | +import org.spongepowered.asm.mixin.injection.Inject; | 
|  | 11 | +import org.spongepowered.asm.mixin.injection.Redirect; | 
|  | 12 | +import org.spongepowered.asm.mixin.injection.Slice; | 
|  | 13 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | 
|  | 14 | + | 
|  | 15 | +@Mixin(InGameHud.class) | 
|  | 16 | +public abstract class InGameHudMixin extends DrawableHelper { | 
|  | 17 | +    @Unique | 
|  | 18 | +    private int count = 0; | 
|  | 19 | + | 
|  | 20 | +    @Redirect( | 
|  | 21 | +            method = "renderStatusBars", | 
|  | 22 | +            at = @At( | 
|  | 23 | +                    value = "INVOKE", | 
|  | 24 | +                    target = "Lnet/minecraft/client/gui/hud/InGameHud;drawTexture(IIIIII)V", | 
|  | 25 | +                    ordinal = 0 | 
|  | 26 | +            ), | 
|  | 27 | +            slice = @Slice( | 
|  | 28 | +                    from = @At( | 
|  | 29 | +                            value = "INVOKE", | 
|  | 30 | +                            target = "Lnet/minecraft/world/level/LevelProperties;isHardcore()Z" | 
|  | 31 | +                    ) | 
|  | 32 | +            ) | 
|  | 33 | +    ) | 
|  | 34 | +    private void skipHeartRendering(InGameHud instance, int x, int y, int u, int v, int width, int height) { | 
|  | 35 | +        ClientPlayerEntity player = MinecraftClient.getInstance().player; | 
|  | 36 | +        if (this.count < player.getMaxHealth() + player.getAbsorption()) { | 
|  | 37 | +            this.drawTexture(x, y, u, v, width, height); | 
|  | 38 | +        } | 
|  | 39 | +        this.count++; | 
|  | 40 | +    } | 
|  | 41 | + | 
|  | 42 | +    @Inject(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 1)) | 
|  | 43 | +    private void resetCount(CallbackInfo ci) { | 
|  | 44 | +        this.count = 0; | 
|  | 45 | +    } | 
|  | 46 | +} | 
0 commit comments