package com.tiedup.remake.client.animation.render;

import com.tiedup.remake.core.TiedUpMod;
import com.tiedup.remake.state.PlayerBindState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

/**
 * Hide first-person hand/item rendering based on bondage state.
 *
 * Behavior:
 * - Tied up: Hide hands completely (hands are behind back)
 * - Mittens: Hide hands + items (Forge limitation - can't separate them)
 */
@OnlyIn(Dist.CLIENT)
@Mod.EventBusSubscriber(
    modid = TiedUpMod.MOD_ID,
    bus = Mod.EventBusSubscriber.Bus.FORGE,
    value = Dist.CLIENT
)
public class FirstPersonHandHideHandler {

    @SubscribeEvent
    public static void onRenderHand(RenderHandEvent event) {
        Minecraft mc = Minecraft.getInstance();
        if (mc == null) {
            return;
        }
        LocalPlayer player = mc.player;

        if (player == null) {
            return;
        }

        PlayerBindState state = PlayerBindState.getInstance(player);
        if (state == null) {
            return;
        }

        // Tied or Mittens: hide hands completely
        // (Forge limitation: RenderHandEvent controls hand + item together)
        if (state.isTiedUp() || state.hasMittens()) {
            event.setCanceled(true);
        }
    }
}
