/*
 * Copyright (c) 2026 盐灯水母
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

package com.remains_cave.item.client;

import com.remains_cave.item.custom.DoomHoodItem;
import net.minecraft.world.entity.EquipmentSlot;
import software.bernie.geckolib.cache.object.GeoBone;
import software.bernie.geckolib.model.GeoModel;
import software.bernie.geckolib.renderer.GeoArmorRenderer;

import javax.annotation.Nullable;

public class DoomHoodRenderer extends GeoArmorRenderer<DoomHoodItem> {
    public DoomHoodRenderer() {
        super(new DoomHoodModel());
    }
    @Override
    @Nullable
    public GeoBone getHeadBone(GeoModel<DoomHoodItem> model) {
        return model.getBone("head").orElse(null);
    }

    @Override
    @Nullable
    public GeoBone getBodyBone(GeoModel<DoomHoodItem> model) {
        return model.getBone("body").orElse(null);
    }
    // 关键：重写可见性控制方法，确保头盔槽也显示身体
    @Override
    @Nullable
    public GeoBone getRightArmBone(GeoModel<DoomHoodItem> model) {
        // 返回你在模型中命名的右肩骨骼，例如 "rightArm"
        return model.getBone("rightArm").orElse(null);
    }
    @Override
    @Nullable
    public GeoBone getLeftArmBone(GeoModel<DoomHoodItem> model) {
        // 返回你在模型中命名的左肩骨骼，例如 "leftArm"
        return model.getBone("leftArm").orElse(null);
    }

    @Override
    protected void applyBoneVisibilityBySlot(EquipmentSlot currentSlot) {
        // 先调用父类方法应用默认可见性（头盔槽会隐藏身体）
        super.applyBoneVisibilityBySlot(currentSlot);
        // 如果是头盔槽并且身体骨骼存在，强制设为可见
        if (currentSlot == EquipmentSlot.HEAD && this.body != null) {
            this.body.setHidden(false);
            this.rightArm.setHidden(false);
            this.leftArm.setHidden(false);
        }
    }
}