aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java
blob: 1f7e07ab6e99f084cf807cbb80c74600e30a443b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package moe.nea.firmament.mixins;

import moe.nea.firmament.events.HotbarItemRenderEvent;
import moe.nea.firmament.events.HudRenderEvent;
import moe.nea.firmament.features.fixes.Fixes;
import moe.nea.firmament.util.SBData;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.DeltaTracker;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
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;

@Mixin(Gui.class)
public class HudRenderEventsPatch {
    @Inject(method = "renderSleepOverlay", at = @At(value = "HEAD"))
    public void renderCallBack(GuiGraphics context, DeltaTracker tickCounter, CallbackInfo ci) {
        HudRenderEvent.Companion.publish(new HudRenderEvent(context, tickCounter));
    }

    @Inject(method = "renderSlot", at = @At("HEAD"))
    public void onRenderHotbarItem(GuiGraphics context, int x, int y, DeltaTracker tickCounter, Player player, ItemStack stack, int seed, CallbackInfo ci) {
        if (stack != null && !stack.isEmpty())
            HotbarItemRenderEvent.Companion.publish(new HotbarItemRenderEvent(stack, context, x, y, tickCounter));
    }

	@Inject(method = "renderEffects", at = @At("HEAD"), cancellable = true)
	public void hideStatusEffects(CallbackInfo ci) {
		if (Fixes.TConfig.INSTANCE.getHidePotionEffectsHud() && SBData.INSTANCE.isOnSkyblock()) ci.cancel();
	}

}