package de.winniepat.citrus.cosmetics.wings;

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

public class WingsModel extends GeoModel<CosmeticWings> {
    private static final Identifier DEFAULT_ANIMATION = Identifier.of("citrus", "animations/wings.animation.json");
    private static final Identifier DEFAULT_MODEL = Identifier.of("citrus", "geo/wings.geo.json");
    private static final Identifier DEFAULT_TEXTURE = Identifier.of("citrus", "textures/cosmetics/wings.png");

    @Override
    public Identifier getModelResource(CosmeticWings wings) {
        WingType type = wings.getWingType();
        if (type == WingType.NONE) return null;

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

    @Override
    public Identifier getTextureResource(CosmeticWings wings) {
        WingType type = wings.getWingType();
        if (type == WingType.NONE) return null;

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

    @Override
    public Identifier getAnimationResource(CosmeticWings wings) {
        WingType type = wings.getWingType();
        if (type == WingType.NONE) {
            Client.debugLog("Animation resource is null for NONE wing type");
            return null;
        }

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

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