package de.winniepat.citrus.cosmetics.hat;

import net.minecraft.util.Identifier;

public enum HatType {
    NONE("none", null, null, null, 1.0f, 0.0, 0.0, 0.0),
    TEST("test_hat", "test_hat", "test_hat.png", "test_hat", 1.0f, 2.0, -5.0, -2.0);

    private final String id;
    private final String modelName;
    private final String textureName;
    private final String animationName;
    private final float scale;
    private final double posX, posY, posZ;

    HatType(String id, String modelName, String textureName, String animationName,
            float scale, double posX, double posY, double posZ) {
        this.id = id;
        this.modelName = modelName;
        this.textureName = textureName;
        this.animationName = animationName;
        this.scale = scale;
        this.posX = posX;
        this.posY = posY;
        this.posZ = posZ;
    }

    public String getId() {
        return id;
    }

    public String getModelName() {
        return modelName;
    }

    public Identifier getModelId() {
        if (modelName == null || NONE.id.equals(id)) return null;
        return Identifier.of("citrus", "geo/hat/" + modelName + ".geo.json");
    }

    public Identifier getTextureId() {
        if (textureName == null || NONE.id.equals(id)) return null;
        return Identifier.of("citrus", "textures/cosmetics/hat/" + textureName);
    }

    public Identifier getAnimationResource() {
        if (animationName == null || NONE.id.equals(id)) return null;
        return Identifier.of("citrus", "animations/hat/" + animationName + ".animation.json");
    }

    public float getScale() {
        return scale;
    }

    public double getPosX() {
        return posX;
    }

    public double getPosY() {
        return posY;
    }

    public double getPosZ() {
        return posZ;
    }

    public static HatType fromId(String id) {
        if (id == null || id.equals("none") || id.isEmpty()) return NONE;

        for (HatType type : values()) {
            if (type.id.equalsIgnoreCase(id)) {
                return type;
            }
        }
        return NONE;
    }

    public static HatType[] getAvailableTypes() {
        return values();
    }
}