package com.zivilon.cinder_loe.items;

import com.zivilon.cinder_loe.LoECreativeTabs;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;

import java.util.List;

public class CinderFurItem extends Item {
    public IIcon[] icons;

    public CinderFurItem() {
        super();
        this.setCreativeTab(LoECreativeTabs.tabMiscLoE);
        setHasSubtypes(true);
    }

    @Override
    public void registerIcons(IIconRegister iconRegister) {
        icons = new IIcon[7];
        for (int i = 0; i < 7; i++) {
            icons[i] = iconRegister.registerIcon("lotr:cinder_fur_item_" + i);
        }
    }

    @Override
    public String getUnlocalizedName(ItemStack item) {
        return "item.cinder_fur_item_" + item.getItemDamage();
    }

    @Override
    public IIcon getIconIndex(ItemStack item) {
        return getIcon(item, 0);
    }

    @Override
    public IIcon getIcon(ItemStack stack, int renderPass) {
        int dmg = stack.getItemDamage();

        // Ensure dmg is within the expected range of subtypes
        if (dmg < 7) {
            return icons[dmg];
        }
        return icons[0]; // Default to 0 if out of bounds
    }

    @Override
    public void getSubItems(Item item, CreativeTabs tab, List list) {
        for (int i = 0; i < 7; i++) {
            list.add(new ItemStack(item, 1, i));
        }
    }
}
