package com.tiedup.remake.items;

import com.tiedup.remake.items.base.GagVariant;
import com.tiedup.remake.items.base.ItemGag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import org.jetbrains.annotations.Nullable;

/**
 * Generic gag item created from GagVariant enum.
 * Replaces individual gag classes (ItemBallGag, ItemTapeGag, etc.)
 *
 * Factory pattern: All gag variants are created using this single class.
 *
 * Note: ItemMedicalGag is NOT handled by this class because it implements
 * IHasBlindingEffect (combo item with special behavior).
 */
public class GenericGag extends ItemGag {

    private final GagVariant variant;

    public GenericGag(GagVariant variant) {
        super(new Item.Properties().stacksTo(16), variant.getMaterial());
        this.variant = variant;
    }

    /**
     * Get the variant this gag was created from.
     */
    public GagVariant getVariant() {
        return variant;
    }

    /**
     * Check if this gag can have a padlock attached via anvil.
     * Adhesive (tape) and organic (slime, vine, web) gags cannot have padlocks.
     */
    @Override
    public boolean canAttachPadlock() {
        return switch (variant) {
            case TAPE_GAG, SLIME_GAG, VINE_GAG, WEB_GAG -> false;
            default -> true;
        };
    }

    /**
     * Get the texture subfolder for this gag variant.
     * Issue #12 fix: Eliminates string checks in renderers.
     */
    @Override
    public String getTextureSubfolder() {
        return variant.getTextureSubfolder();
    }

    /**
     * Check if this gag uses a 3D OBJ model.
     */
    @Override
    public boolean uses3DModel() {
        return variant.uses3DModel();
    }

    /**
     * Get the 3D model location for this gag.
     */
    @Override
    @Nullable
    public ResourceLocation get3DModelLocation() {
        String path = variant.getModelPath();
        return path != null ? ResourceLocation.tryParse(path) : null;
    }
}
