package common.item;

import java.util.List;

import common.init.Blocks;
import common.init.ItemRegistry;
import common.init.Items;

public enum CheatTab
{
    tabBlocks("Baumaterial")
    {
        protected Item getTabIconItem()
        {
            return ItemRegistry.getItemFromBlock(Blocks.glass);
        }
    },
    tabNature("Gestein und Natur")
    {
        protected Item getTabIconItem()
        {
        	return ItemRegistry.getItemFromBlock(Blocks.grass);
        }
    },
    tabWood("Holz")
    {
        protected Item getTabIconItem()
        {
        	return ItemRegistry.getItemFromBlock(Blocks.maple_planks);
        }
    },
    tabPlants("Pflanzen")
    {
    	protected Item getTabIconItem()
        {
            return ItemRegistry.getItemFromBlock(Blocks.oak_leaves);
        }
    },
    tabDeco("Dekoration")
    {
        protected Item getTabIconItem()
        {
            return ItemRegistry.getItemFromBlock(Blocks.hay_block);
        }
    },
    tabTech("Redstone & Technik")
    {
        protected Item getTabIconItem()
        {
        	return ItemRegistry.getItemFromBlock(Blocks.tnt);
        }
    },
    tabGems("Erze & Teure Blöcke")
    {
        protected Item getTabIconItem()
        {
        	return ItemRegistry.getItemFromBlock(Blocks.diamond_block);
        }
    },
    tabSpawners("Mob & Itemspawner")
    {
        protected Item getTabIconItem()
        {
            return Items.minecart;
        }
    },
    tabTools("Werkzeug")
    {
        protected Item getTabIconItem()
        {
            return Items.flint_and_steel;
        }
    },
    tabCombat("Kampf")
    {
        protected Item getTabIconItem()
        {
            return Items.bow;
        }
    },
    tabMagic("Tränke & Verzauberungen")
    {
        protected Item getTabIconItem()
        {
            return Items.potion;
        }
        protected int getIconItemDamage()
        {
            return 8261;
        }
    },
    tabMaterials("Werkstoffe")
    {
        protected Item getTabIconItem()
        {
            return Items.leather;
        }
    },
    tabMetals("Metalle und Juwelen")
    {
        protected Item getTabIconItem()
        {
        	return Items.iron_ingot;
        }
    },
    tabMisc("Verschiedenes & Nahrung")
    {
        protected Item getTabIconItem()
        {
        	return Items.charge_crystal;
        }
    };
    
    private final String name;
    private ItemStack iconItemStack;

    private CheatTab(String name)
    {
        this.name = name;
    }

    public int getHorizontal()
    {
        return this.ordinal() % 12;
    }

    public int getVertical()
    {
        return this.ordinal() / 12;
    }
    
    public String getName()
    {
        return this.name;
    }

    public ItemStack getIconItemStack()
    {
        if (this.iconItemStack == null)
        {
            this.iconItemStack = new ItemStack(this.getTabIconItem(), 1, this.getIconItemDamage());
        }

        return this.iconItemStack;
    }

    protected abstract Item getTabIconItem();

    protected int getIconItemDamage()
    {
        return 0;
    }
    
    public void displayAllReleventItems(List<ItemStack> list)
    {
        for (Item item : ItemRegistry.REGISTRY)
        {
            if (item != null && item.getTab() == this)
            {
                item.getSubItems(item, this, list);
            }
        }
    }
}
