package com.tiedup.remake.items.bondage3d.gags;

import com.tiedup.remake.items.base.ItemGag;
import com.tiedup.remake.items.bondage3d.IHas3DModelConfig;
import com.tiedup.remake.items.bondage3d.Model3DConfig;
import com.tiedup.remake.util.GagMaterial;
import java.util.Set;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import org.jetbrains.annotations.Nullable;

/**
 * Ball Gag 3D - Extends ItemGag with 3D OBJ model rendering.
 * All 3D configuration is defined here.
 * Supports color variants via tinting the "Ball" material.
 */
public class ItemBallGag3D extends ItemGag implements IHas3DModelConfig {

    // 3D config with "Ball" material tintable for color variants
    private static final Model3DConfig CONFIG = new Model3DConfig(
        "tiedup:models/obj/ball_gag/model.obj", // OBJ
        "tiedup:models/obj/ball_gag/texture.png", // Explicit texture
        0.0f, // posX
        1.55f, // posY
        0.0f, // posZ
        1.0f, // scale
        0.0f,
        0.0f,
        180.0f, // rotation
        Set.of("Ball") // Tintable materials (for color variants)
    );

    public ItemBallGag3D() {
        super(new Item.Properties().stacksTo(16), GagMaterial.BALL);
    }

    // ===== 3D Model Support =====

    @Override
    public boolean uses3DModel() {
        return true;
    }

    @Override
    @Nullable
    public ResourceLocation get3DModelLocation() {
        return ResourceLocation.tryParse(CONFIG.objPath());
    }

    /**
     * Returns the complete 3D configuration for the renderer.
     */
    @Override
    public Model3DConfig getModelConfig() {
        return CONFIG;
    }

    /**
     * Explicit texture (if non-null, overrides MTL map_Kd).
     */
    @Nullable
    public ResourceLocation getExplicitTexture() {
        String path = CONFIG.texturePath();
        return path != null ? ResourceLocation.tryParse(path) : null;
    }

    // ===== Gag Properties =====

    @Override
    public String getTextureSubfolder() {
        return "ballgags/normal"; // Fallback if 3D fails
    }

    @Override
    public boolean canAttachPadlock() {
        return true;
    }
}
