package common.item;

import java.util.List;

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

public enum CheatTab {
	BLOCKS("Baumaterial") {
		protected Item getIconItem() {
			return Items.glass;
		}
	},
	NATURE("Gestein und Natur") {
		protected Item getIconItem() {
			return Items.grass;
		}
	},
	WOOD("Holz") {
		protected Item getIconItem() {
			return Items.maple_planks;
		}
	},
	PLANTS("Pflanzen") {
		protected Item getIconItem() {
			return Items.oak_leaves_spring;
		}
	},
	DECORATION("Dekoration") {
		protected Item getIconItem() {
			return Items.hay_block;
		}
	},
	TECHNOLOGY("Redstone & Technik") {
		protected Item getIconItem() {
			return Items.tnt;
		}
	},
	GEMS("Erze & Teure Blöcke") {
		protected Item getIconItem() {
			return Items.diamond_block;
		}
	},
	SPAWNERS("Mob & Itemspawner") {
		protected Item getIconItem() {
			return Items.minecart;
		}
	},
	TOOLS("Werkzeug") {
		protected Item getIconItem() {
			return Items.flint_and_steel;
		}
	},
	LIQUIDS("Flüssigkeiten") {
		protected Item getIconItem() {
			return Items.water_bucket;
		}
	},
	COMBAT("Kampf") {
		protected Item getIconItem() {
			return Items.bow;
		}
	},
	MAGIC("Tränke & Verzauberungen") {
		protected Item getIconItem() {
			return Items.potion;
		}
	},
	MATERIALS("Werkstoffe") {
		protected Item getIconItem() {
			return Items.leather;
		}
	},
	METALS("Metalle und Juwelen") {
		protected Item getIconItem() {
			return Items.iron_ingot;
		}
	},
	MISC("Verschiedenes & Nahrung") {
		protected Item getIconItem() {
			return Items.charge_crystal;
		}
	};

	private final String name;

	private ItemStack icon;

	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 getIcon() {
		if(this.icon == null)
			this.icon = new ItemStack(this.getIconItem());
		return this.icon;
	}

	protected abstract Item getIconItem();

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