package com.zivilon.cinder_loe.blocks;

import com.zivilon.cinder_loe.LoECreativeTabs;
import com.zivilon.cinder_loe.util.Utilities;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import lotr.common.LOTRCreativeTabs;
import lotr.common.block.LOTRBlockBrickBase;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
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.lang.reflect.Field;
import java.util.List;

public class CinderFurBlock extends Block {
    protected IIcon[] brickIcons;
    protected String[] brickNames;


    public CinderFurBlock() {
        super(Material.cloth);
        this.setCreativeTab(LoECreativeTabs.tabBlockLoE);
        setBlockTextureName("lotr:cinderfur");
        setBlockName("lotr:cinderfur");
        setStepSound(Block.soundTypeCloth);
        this.setBrickNames("brown", "gray", "black", "white", "obsidian", "bearblack", "bearbrown", "lion", "lioness");
    }

    protected void setBrickNames(String ... names) {
        this.brickNames = names;
    }

    @SideOnly(Side.CLIENT)
    @Override
    public void registerBlockIcons(IIconRegister iconregister) {
        this.brickIcons = new IIcon[this.brickNames.length];
        for (int i = 0; i < this.brickNames.length; ++i) {
            String texturePath = this.getTextureName() + "_" + this.brickNames[i];
            System.out.println("Registering texture: " + texturePath); // Debug log
            this.brickIcons[i] = iconregister.registerIcon(texturePath);
        }
    }
    @Override
    public IIcon getIcon(int side, int meta) {
        return this.brickIcons[meta];
    }

    @Override
    public int damageDropped(int meta) {
        return meta;
    }
    @SideOnly(Side.CLIENT)
    @Override
    public void getSubBlocks(Item item, CreativeTabs tab, List list) {
        for (int i = 0; i < this.brickNames.length; ++i) {
            list.add(new ItemStack(item, 1, i));
        }
    }
}
