package com.tiedup.remake.items.base;

import com.tiedup.remake.v2.BodyRegionV2;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;

/**
 * Interface for all bondage equipment items.
 * Defines the core behavior for items that can be equipped in custom bondage slots.
 *
 * Based on original IExtraBondageItem from 1.12.2
 */
public interface IBondageItem {
    /**
     * Get the body region this item occupies when equipped.
     * @return The body region
     */
    BodyRegionV2 getBodyRegion();

    /**
     * Called every tick while this item is equipped on an entity.
     * @param stack The equipped item stack
     * @param entity The entity wearing the item
     */
    default void onWornTick(ItemStack stack, LivingEntity entity) {
        // Default: do nothing
    }

    /**
     * Called when this item is equipped on an entity.
     * @param stack The equipped item stack
     * @param entity The entity wearing the item
     */
    default void onEquipped(ItemStack stack, LivingEntity entity) {
        // Default: do nothing
    }

    /**
     * Called when this item is unequipped from an entity.
     * @param stack The unequipped item stack
     * @param entity The entity that was wearing the item
     */
    default void onUnequipped(ItemStack stack, LivingEntity entity) {
        // Default: do nothing
    }

    /**
     * Check if this item can be equipped on the given entity.
     * @param stack The item stack to equip
     * @param entity The target entity
     * @return true if the item can be equipped, false otherwise
     */
    default boolean canEquip(ItemStack stack, LivingEntity entity) {
        return true;
    }

    /**
     * Check if this item can be unequipped from the given entity.
     * @param stack The equipped item stack
     * @param entity The entity wearing the item
     * @return true if the item can be unequipped, false otherwise
     */
    default boolean canUnequip(ItemStack stack, LivingEntity entity) {
        return true;
    }

    /**
     * Get the texture subfolder for this bondage item.
     * Used by renderers to locate texture files.
     *
     * <p><b>Issue #12 fix:</b> Eliminates 40+ string checks in renderers by letting
     * each item type declare its own texture subfolder.
     *
     * @return Subfolder path under textures/entity/bondage/ (e.g., "ropes", "ballgags/normal")
     */
    default String getTextureSubfolder() {
        return "misc"; // Fallback for items without explicit subfolder
    }

    /**
     * Check if this bondage item uses a 3D OBJ model instead of a flat texture.
     * Items with 3D models will be rendered using ObjModelRenderer.
     *
     * @return true if this item uses a 3D model, false for standard texture rendering
     */
    default boolean uses3DModel() {
        return false;
    }

    /**
     * Get the ResourceLocation of the 3D model for this item.
     * Only called if uses3DModel() returns true.
     *
     * @return ResourceLocation pointing to the .obj file, or null if no 3D model
     */
    @Nullable
    default ResourceLocation get3DModelLocation() {
        return null;
    }
}
