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 spiceIngredient extends Item {
    public IIcon[] icons;

    public spiceIngredient() {
        this.setHasSubtypes(true);
        setMaxStackSize(64);
        this.setMaxDamage(0);
        setCreativeTab(LoECreativeTabs.tabMiscLoE);
    }

        @Override
    public IIcon getIconFromDamage(int damage) {
        if (damage < 0 || damage >= icons.length) {
            damage = 0;
        }
        return this.icons[damage];
    }

        @Override
    public void registerIcons(IIconRegister iconRegister) {
        this.icons = new IIcon[12];
        this.icons[0] = iconRegister.registerIcon("lotr:fine_bone_dust");
        this.icons[1] = iconRegister.registerIcon("lotr:dried_morgul_caps");
        this.icons[2] = iconRegister.registerIcon("lotr:blighted_root");
        this.icons[3] = iconRegister.registerIcon("lotr:coldbreath_leaf");
        this.icons[4] = iconRegister.registerIcon("lotr:brambleberry");
        this.icons[5] = iconRegister.registerIcon("lotr:willow_bark");
        this.icons[6] = iconRegister.registerIcon("lotr:seregon");
        this.icons[7] = iconRegister.registerIcon("lotr:niphredil_seeds");
        this.icons[8] = iconRegister.registerIcon("lotr:dried_mallorn");
        this.icons[9] = iconRegister.registerIcon("lotr:curing_salts");
        this.icons[10] = iconRegister.registerIcon("lotr:underroot");
        this.icons[11] = iconRegister.registerIcon("lotr:miners_lichen");
    }

    @Override
    public String getUnlocalizedName(ItemStack item) {
        switch(item.getItemDamage()) {
            case 0:
                return "item.fine_bone_dust";
            case 1:
                return "item.dried_morgul_caps";
            case 2:
                return "item.blighted_root";
            case 3:
                return "item.coldbreath_leaf";
            case 4:
                return "item.brambleberry";
            case 5:
                return "item.willow_bark";
            case 6:
                return "item.seregon";
            case 7:
                return "item.niphredil_seeds";
            case 8:
                return "item.dried_mallorn";
            case 9:
                return "item.curing_salts";
            case 10:
                return "item.underroot";
            case 11:
                return "item.miners_lichen";
            default:
                return "item.fine_bone_dust";
        }
    }

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