package de.winniepat.citrus.cosmetics.halo;

import de.winniepat.citrus.Client;
import software.bernie.geckolib.model.GeoModel;
import net.minecraft.util.Identifier;

public class HaloModel extends GeoModel<CosmeticHalo> {
    private static final Identifier DEFAULT_HALO_ANIMATION = Identifier.of("citrus", "animations/halo/default_halo.animation.json");
    private static final Identifier DEFAULT_HALO_MODEL = Identifier.of("citrus", "geo/halo/default_halo.geo.json");
    private static final Identifier DEFAULT_HALO_TEXTURE = Identifier.of("citrus", "textures/cosmetics/halo/default_halo.png");

    @Override
    public Identifier getModelResource(CosmeticHalo halo) {
        HaloType type = halo.getHaloType();
        if (type == HaloType.NONE) return null;

        Identifier modelId = type.getModelId();
        if (modelId == null) {
            Client.debugLog("Halo model is null for type: " + type.getId());
            return DEFAULT_HALO_MODEL;
        }
        return modelId;
    }

    @Override
    public Identifier getTextureResource(CosmeticHalo halo) {
        HaloType type = halo.getHaloType();
        if (type == HaloType.NONE) return null;

        Identifier textureId = type.getTextureId();
        if (textureId == null) {
            Client.debugLog("Halo texture is null for type: " + type.getId());
            return DEFAULT_HALO_TEXTURE;
        }
        return textureId;
    }

    @Override
    public Identifier getAnimationResource(CosmeticHalo halo) {
        HaloType type = halo.getHaloType();
        if (type == HaloType.NONE) {
            Client.debugLog("Animation resource is null for NONE halo type");
            return null;
        }

        Identifier anim = type.getAnimationResource();
        if (anim == null) {
            Client.debugLog("Animation resource is null for halo type: " + type.getId());
            Client.debugLog("Falling back to default halo animation");
            return DEFAULT_HALO_ANIMATION;
        }

        Client.debugLog("Halo animation resource: " + anim.toString() + " for type: " + type.getId());
        return anim;
    }
}