package common.init;

import java.util.Map;
import java.util.Set;
import java.util.function.Function;

import common.block.Block;
import common.block.BlockBed;
import common.block.BlockButton;
import common.block.BlockDirt;
import common.block.BlockDoor;
import common.block.BlockDoublePlant;
import common.block.BlockFence;
import common.block.BlockFlower;
import common.block.BlockLeaves;
import common.block.BlockOre;
import common.block.BlockSand;
import common.block.BlockSandStone;
import common.block.BlockSapling;
import common.block.BlockSlab;
import common.block.BlockStoneBrick;
import common.block.BlockWall;
import common.collect.Maps;
import common.collect.Sets;
import common.color.DyeColor;
import common.color.TextColor;
import common.entity.item.EntityCart;
import common.entity.npc.CharacterInfo;
import common.entity.npc.SpeciesInfo;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemAmmo;
import common.item.ItemAnvilBlock;
import common.item.ItemAppleGold;
import common.item.ItemArmor;
import common.item.ItemAxe;
import common.item.ItemBanHammer;
import common.item.ItemBanner;
import common.item.ItemBed;
import common.item.ItemBlock;
import common.item.ItemBoat;
import common.item.ItemBoltgun;
import common.item.ItemBook;
import common.item.ItemBow;
import common.item.ItemBucket;
import common.item.ItemBucketMilk;
import common.item.ItemButton;
import common.item.ItemCamera;
import common.item.ItemCarrotOnAStick;
import common.item.ItemChargedOrb;
import common.item.ItemChest;
import common.item.ItemCloth;
import common.item.ItemCoal;
import common.item.ItemColored;
import common.item.ItemDie;
import common.item.ItemDispenser;
import common.item.ItemDoor;
import common.item.ItemDoublePlant;
import common.item.ItemDye;
import common.item.ItemDynamite;
import common.item.ItemEditWand;
import common.item.ItemEffect;
import common.item.ItemEgg;
import common.item.ItemEnchantedBook;
import common.item.ItemExpBottle;
import common.item.ItemExterminator;
import common.item.ItemFence;
import common.item.ItemFireball;
import common.item.ItemFirework;
import common.item.ItemFireworkCharge;
import common.item.ItemFishFood;
import common.item.ItemFishingRod;
import common.item.ItemFlintAndSteel;
import common.item.ItemFood;
import common.item.ItemFragile;
import common.item.ItemGlassBottle;
import common.item.ItemHoe;
import common.item.ItemHorseArmor;
import common.item.ItemHugeMushroom;
import common.item.ItemInfoWand;
import common.item.ItemKey;
import common.item.ItemLead;
import common.item.ItemLeaves;
import common.item.ItemLightning;
import common.item.ItemLilyPad;
import common.item.ItemMagnet;
import common.item.ItemMagnetic;
import common.item.ItemMetal;
import common.item.ItemMetalBlock;
import common.item.ItemMinecart;
import common.item.ItemMonsterPlacer;
import common.item.ItemMultiTexture;
import common.item.ItemNameTag;
import common.item.ItemNpcSpawner;
import common.item.ItemNugget;
import common.item.ItemPickaxe;
import common.item.ItemPiston;
import common.item.ItemPotion;
import common.item.ItemPressurePlate;
import common.item.ItemRecord;
import common.item.ItemRedstone;
import common.item.ItemReed;
import common.item.ItemRod;
import common.item.ItemSaddle;
import common.item.ItemSeedFood;
import common.item.ItemSeeds;
import common.item.ItemShears;
import common.item.ItemSign;
import common.item.ItemSkull;
import common.item.ItemSlab;
import common.item.ItemSmall;
import common.item.ItemSnow;
import common.item.ItemSnowball;
import common.item.ItemSoup;
import common.item.ItemSpaceNavigator;
import common.item.ItemSpade;
import common.item.ItemStack;
import common.item.ItemStick;
import common.item.ItemSword;
import common.item.ItemTNT;
import common.item.ItemTiny;
import common.item.ItemWall;
import common.item.ItemWeatherToken;
import common.potion.Potion;
import common.potion.PotionHelper;
import common.world.Weather;

public abstract class ItemRegistry {
	public static final RegistryNamespaced<String, Item> REGISTRY = new RegistryNamespaced();
	public static final Map<Block, ItemBlock> BLOCKMAP = Maps.<Block, ItemBlock>newHashMap();
	public static final Set<Block> SPECIALIZED = Sets.<Block>newHashSet();
	
	private static int nextItemId = 4096;

	public static int getIdFromItem(Item item) {
		return item == null ? 0 : REGISTRY.getIDForObject(item);
	}

	public static Item getItemById(int id) {
		return REGISTRY.getObjectById(id);
	}

	public static ItemBlock getItemFromBlock(Block block) {
		return BLOCKMAP.get(block);
	}

	public static Item getRegisteredItem(String name) {
		return REGISTRY.getObject(name);
	}

	private static ItemBlock registerFlat(Block block) {
		ItemBlock item = new ItemBlock(block, "");
		registerBlock(block, item);
		return item;
	}

	private static ItemBlock registerFlat(Block block, String texture) {
		ItemBlock item = new ItemBlock(block, texture.indexOf('/') == -1 ? "blocks/" + texture : texture);
		registerBlock(block, item);
		return item;
	}

	private static void registerBlock(Block block, ItemBlock item) {
		REGISTRY.register(BlockRegistry.getIdFromBlock(block), BlockRegistry.REGISTRY.getNameForObject(block), item);
		BLOCKMAP.put(block, item);
	}

	private static void registerSpecial(Block block) {
		if(BLOCKMAP.containsKey(block) || SPECIALIZED.contains(block))
			throw new IllegalArgumentException("Block " + BlockRegistry.REGISTRY.getNameForObject(block) + " ist bereits registriert");
		SPECIALIZED.add(block);
	}

	private static void registerItem(String name, Item item) {
		if(item.getBlock() != null)
			throw new IllegalArgumentException("Item " + name + " darf keinen Block besitzen");
		REGISTRY.register(nextItemId++, name, item);
	}

	private static void registerItem(Item item) {
		if(item.getBlock() == null)
			throw new IllegalArgumentException("Unbenanntes Item benötigt einen Block");
		registerSpecial(item.getBlock());
		REGISTRY.register(BlockRegistry.getIdFromBlock(item.getBlock()), BlockRegistry.REGISTRY.getNameForObject(item.getBlock()), item);
	}
	
	private static void registerTools(ToolMaterial material, String name, String prefix) {
//		String loc = name.substring(0, 1).toUpperCase() + name.substring(1);
		if(material.hasTools()) {
			registerItem(name + "_shovel", (new ItemSpade(material)).setDisplay(prefix + "schaufel"));
			registerItem(name + "_pickaxe", (new ItemPickaxe(material)).setDisplay(prefix + "spitzhacke"));
			registerItem(name + "_axe", (new ItemAxe(material)).setDisplay(prefix + "axt"));
			registerItem(name + "_hoe", (new ItemHoe(material)).setDisplay(prefix + "hacke"));
		}
		if(material.hasExtras()) {
			registerItem(name + "_shears", (new ItemShears(material)).setDisplay(prefix + "schere"));
			registerItem(name + "_horse_armor", (new ItemHorseArmor(material, name)).setDisplay(prefix + "pferderüstung"));
		}
		if(material.hasWeapons()) {
			registerItem(name + "_sword", (new ItemSword(material)).setDisplay(prefix + "schwert"));
		}
		if(material.hasArmor()) {
			registerItem(name + "_helmet", (new ItemArmor(material, name, 0)).setDisplay(prefix == null ? "Kappe" : prefix + "helm"));
			registerItem(name + "_chestplate", (new ItemArmor(material, name, 1)).setDisplay(prefix == null ? "Jacke" : prefix + "brustpanzer"));
			registerItem(name + "_leggings", (new ItemArmor(material, name, 2)).setDisplay(prefix == null ? "Hose" : prefix + "beinschutz"));
			registerItem(name + "_boots", (new ItemArmor(material, name, 3)).setDisplay(prefix == null ? "Stiefel" : prefix + "stiefel"));
		}
	}

	static void register() {
		registerBlock(Blocks.grass, new ItemColored(Blocks.grass, false));
		registerBlock(Blocks.dirt, (new ItemMultiTexture(Blocks.dirt, Blocks.dirt, new Function<ItemStack, String>() {
			public String apply(ItemStack p_apply_1_) {
				return BlockDirt.DirtType.byMetadata(p_apply_1_.getMetadata()).getDisplay();
			}
		})).setDisplay("Erde"));
//		registerBlock(Blocks.planks, (new ItemMultiTexture(Blocks.planks, Blocks.planks, new Function<ItemStack, String>() {
//			public String apply(ItemStack p_apply_1_) {
//				return BlockPlanks.EnumType.byMetadata(p_apply_1_.getMetadata()).getUnlocalizedName();
//			}
//		})).setUnlocalizedName("wood"));
//		registerBlock(Blocks.sapling, (new ItemMultiTexture(Blocks.sapling, Blocks.sapling, true, new Function<ItemStack, String>() {
//			public String apply(ItemStack p_apply_1_) {
//				return BlockPlanks.EnumType.byMetadata(p_apply_1_.getMetadata()).getUnlocalizedName();
//			}
//		})).setUnlocalizedName("sapling"));
		registerBlock(Blocks.sand, (new ItemMultiTexture(Blocks.sand, Blocks.sand, new Function<ItemStack, String>() {
			public String apply(ItemStack p_apply_1_) {
				return BlockSand.EnumType.byMetadata(p_apply_1_.getMetadata()).getDisplay();
			}
		})).setDisplay("Sand"));
//		registerBlock(Blocks.log, (new ItemMultiTexture(Blocks.log, Blocks.log, new Function<ItemStack, String>() {
//			public String apply(ItemStack p_apply_1_) {
//				return BlockPlanks.EnumType.byMetadata(p_apply_1_.getMetadata()).getUnlocalizedName();
//			}
//		})).setUnlocalizedName("log"));
//		registerBlock(Blocks.log2, (new ItemMultiTexture(Blocks.log2, Blocks.log2, new Function<ItemStack, String>() {
//			public String apply(ItemStack p_apply_1_) {
//				return BlockPlanks.EnumType.byMetadata(p_apply_1_.getMetadata() + 4).getUnlocalizedName();
//			}
//		})).setUnlocalizedName("log"));
		registerBlock(Blocks.dispenser, new ItemDispenser(Blocks.dispenser));
		registerBlock(Blocks.sandstone, (new ItemMultiTexture(Blocks.sandstone, Blocks.sandstone, new Function<ItemStack, String>() {
			public String apply(ItemStack p_apply_1_) {
				return BlockSandStone.EnumType.byMetadata(p_apply_1_.getMetadata()).getDisplay();
			}
		})).setDisplay("Sandstein"));
		registerFlat(Blocks.golden_rail);
		registerFlat(Blocks.detector_rail);
		registerBlock(Blocks.sticky_piston, new ItemPiston(Blocks.sticky_piston));
		registerFlat(Blocks.web);
		registerBlock(Blocks.tallgrass, (new ItemColored(Blocks.tallgrass, true, "")).setSubtypeNames(new String[] {"Busch", "Gras", "Farn"}));
		registerFlat(Blocks.deadbush);
		registerBlock(Blocks.piston, new ItemPiston(Blocks.piston));
		registerBlock(Blocks.wool, (new ItemCloth(Blocks.wool, -1)).setDisplay("Wolle"));
		registerBlock(Blocks.flower, (new ItemMultiTexture(Blocks.flower, Blocks.flower, true, new Function<ItemStack, String>() {
			public String apply(ItemStack stack) {
				return BlockFlower.EnumFlowerType.getType(BlockFlower.EnumFlowerColor.BASE, stack.getMetadata()).getDisplay();
			}
		})).setDisplay("Blume"));
		registerFlat(Blocks.brown_mushroom);
		registerFlat(Blocks.red_mushroom);
		registerBlock(Blocks.tnt, new ItemTNT(Blocks.tnt));
		registerBlock(Blocks.nuke, new ItemBlock(Blocks.nuke).setColor(TextColor.RED));
		registerFlat(Blocks.torch);
		registerBlock(Blocks.chest, new ItemChest(Blocks.chest));
		registerFlat(Blocks.ladder);
		registerFlat(Blocks.rail);
		registerFlat(Blocks.lever, "lever");
		registerBlock(Blocks.stone_pressure_plate, new ItemPressurePlate(Blocks.stone_pressure_plate));
		registerBlock(Blocks.wooden_pressure_plate, new ItemPressurePlate(Blocks.wooden_pressure_plate));
		registerFlat(Blocks.redstone_torch);
//		registerBlock(Blocks.stone_button, new ItemButton(Blocks.stone_button));
		registerBlock(Blocks.snow_layer, new ItemSnow(Blocks.snow_layer));
//		registerBlock(Blocks.oak_fence, new ItemFence(Blocks.oak_fence));
//		registerBlock(Blocks.spruce_fence, new ItemFence(Blocks.spruce_fence));
//		registerBlock(Blocks.birch_fence, new ItemFence(Blocks.birch_fence));
//		registerBlock(Blocks.jungle_fence, new ItemFence(Blocks.jungle_fence));
//		registerBlock(Blocks.dark_oak_fence, new ItemFence(Blocks.dark_oak_fence));
//		registerBlock(Blocks.acacia_fence, new ItemFence(Blocks.acacia_fence));
		registerBlock(Blocks.stonebrick, (new ItemMultiTexture(Blocks.stonebrick, Blocks.stonebrick, new Function<ItemStack, String>() {
			public String apply(ItemStack p_apply_1_) {
				return BlockStoneBrick.EnumType.byMetadata(p_apply_1_.getMetadata()).getDisplay();
			}
		})).setDisplay("Steinziegel"));
		registerBlock(Blocks.brown_mushroom_block, new ItemHugeMushroom(Blocks.brown_mushroom_block));
		registerBlock(Blocks.red_mushroom_block, new ItemHugeMushroom(Blocks.red_mushroom_block));
		registerFlat(Blocks.iron_bars);
		registerFlat(Blocks.glass_pane, "glass");
		registerBlock(Blocks.vine, new ItemColored(Blocks.vine, false, ""));
		registerBlock(Blocks.waterlily, new ItemLilyPad(Blocks.waterlily));
//		registerBlock(Blocks.blood_brick_fence, new ItemFence(Blocks.blood_brick_fence));
//		registerBlock(Blocks.black_brick_fence, new ItemFence(Blocks.black_brick_fence));
		registerFlat(Blocks.tripwire_hook, "tripwire_hook");
		registerBlock(Blocks.cobblestone_wall,
				(new ItemWall(Blocks.cobblestone_wall, Blocks.cobblestone_wall, new Function<ItemStack, String>() {
					public String apply(ItemStack p_apply_1_) {
						return BlockWall.EnumType.byMetadata(p_apply_1_.getMetadata()).getDisplay();
					}
				})).setDisplay("Bruchsteinmauer"));
//		registerBlock(Blocks.wooden_button, new ItemButton(Blocks.wooden_button));
		registerBlock(Blocks.anvil, (new ItemAnvilBlock(Blocks.anvil)).setDisplay("Amboss"));
		registerBlock(Blocks.trapped_chest, new ItemChest(Blocks.trapped_chest));
		registerBlock(Blocks.light_weighted_pressure_plate, new ItemPressurePlate(Blocks.light_weighted_pressure_plate));
		registerBlock(Blocks.heavy_weighted_pressure_plate, new ItemPressurePlate(Blocks.heavy_weighted_pressure_plate));
		registerFlat(Blocks.hopper, "items/hopper");
		registerBlock(Blocks.quartz_block,
				(new ItemMultiTexture(Blocks.quartz_block, Blocks.quartz_block, new String[] {"Quarzblock", "Gemeißelter Quarzblock", "Quarzsäule"}))
						.setDisplay("Quarzblock"));
		registerBlock(Blocks.black_quartz_block,
				(new ItemMultiTexture(Blocks.black_quartz_block, Blocks.black_quartz_block, new String[] {"Schwarzer Quarzblock", "Schwarzer gemeißelter Quarzblock", "Schwarze Quarzsäule"}))
						.setDisplay("Schwarzer Quarzblock"));
		registerFlat(Blocks.activator_rail);
		registerBlock(Blocks.dropper, new ItemDispenser(Blocks.dropper));
		registerBlock(Blocks.stained_hardened_clay, (new ItemCloth(Blocks.stained_hardened_clay, null)).setDisplay("gefärbter Ton"));
		registerBlock(Blocks.carpet, (new ItemCloth(Blocks.carpet, 1)).setDisplay("Teppich"));
		registerBlock(Blocks.double_plant, (new ItemDoublePlant(Blocks.double_plant, Blocks.double_plant, new Function<ItemStack, String>() {
			public String apply(ItemStack p_apply_1_) {
				return BlockDoublePlant.EnumPlantType.byMetadata(p_apply_1_.getMetadata()).getDisplay();
			}
		})).setDisplay("Pflanze"));
		registerBlock(Blocks.stained_glass, (new ItemCloth(Blocks.stained_glass, null)).setDisplay("Glas"));
		registerBlock(Blocks.stained_glass_pane, (new ItemCloth(Blocks.stained_glass_pane, null, "glass")).setDisplay("Glasscheibe"));
//		registerBlock(Blocks.cherry_fence, new ItemFence(Blocks.cherry_fence));
//		registerBlock(Blocks.maple_fence, new ItemFence(Blocks.maple_fence));
		registerFlat(Blocks.blue_mushroom);
//		registerBlock(Blocks.red_button, new ItemButton(Blocks.red_button));
		registerBlock(Blocks.rock, (new ItemMultiTexture(Blocks.rock, Blocks.rock, new Function<ItemStack, String>() {
			public String apply(ItemStack stack) {
				return stack.getMetadata() == 1 ? "Glatter Felsen" : "Felsen";
			}
		})).setDisplay("Felsen"));

		for(BlockLeaves leaves : BlockLeaves.LEAVES) {
			registerBlock(leaves, new ItemLeaves(leaves)); // .setDisplay(BlockRegistry.REGISTRY.getNameForObject(leaves)));
		}
		for(BlockSlab slab : BlockSlab.SLABS) {
			registerBlock(slab, new ItemSlab(slab));
		}
        for(BlockFence fence : BlockFence.FENCES) {
        	registerBlock(fence, new ItemFence(fence));
        }
        for(BlockButton button : BlockButton.BUTTONS) {
        	registerBlock(button, new ItemButton(button));
        }
        for(BlockSapling sapling : BlockSapling.SAPLINGS) {
        	registerFlat(sapling);
        }
		

		Item bucket = (new ItemBucket(null, false)).setDisplay("Eimer");
		registerItem("bucket", bucket);
		for(int z = 0; z < FluidRegistry.getNumFluids(); z++) {
			registerItem(BlockRegistry.REGISTRY.getNameForObject(FluidRegistry.getStaticBlock(z)) + 
					"_bucket", new ItemBucket(FluidRegistry.getFluidBlock(z), false).setDisplay("Eimer")
					.setContainerItem(bucket));
		}
		registerItem("recursive_bucket", (new ItemBucket(null, true)).setDisplay("Unendlicher Eimer"));
		for(int z = 0; z < FluidRegistry.getNumFluids(); z++) {
			registerItem("recursive_" + BlockRegistry.REGISTRY.getNameForObject(FluidRegistry.getStaticBlock(z)) + 
					"_bucket", new ItemBucket(FluidRegistry.getFluidBlock(z), true).setDisplay("Flutender Eimer"));
		}
		registerItem("milk_bucket", (new ItemBucketMilk()).setDisplay("Milch").setContainerItem(bucket));

//		registerItem("painting", (new ItemHangingEntity(EntityPainting.class)).setDisplay("Gemälde"));
//		registerItem("item_frame", (new ItemHangingEntity(EntityFrame.class)).setDisplay("Rahmen"));
		registerItem("boat", (new ItemBoat()).setDisplay("Boot"));
		registerItem("minecart", (new ItemMinecart(EntityCart.EnumMinecartType.RIDEABLE)).setDisplay("Lore"));
		registerItem("chest_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.CHEST)).setDisplay("Güterlore"));
		registerItem("hopper_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.HOPPER)).setDisplay("Trichterlore"));
		registerItem("tnt_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.TNT)).setDisplay("TNT-Lore")
				.setColor(TextColor.RED));
        for(EntityEggInfo egg : EntityRegistry.SPAWN_EGGS.values()) {
        	registerItem(egg.spawnedID.toLowerCase() + "_spawner", (new ItemMonsterPlacer(egg.spawnedID))
        			.setDisplay("Spawner").setMaxStackSize(ItemStack.MAX_SIZE));
        }
        for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) {
	        for(CharacterInfo charinfo : species.chars) {
	        	if(charinfo.spawner)
		        	registerItem(charinfo.skin + "_spawner", (new ItemNpcSpawner(charinfo)).setDisplay("NSC-Spawner")
		        			.setMaxStackSize(ItemStack.MAX_SIZE));
	        }
        }
		
		registerItem("wand", (new ItemEditWand()).setDisplay("Bearbeitungswerkzeug"));
		registerItem("info_wand", (new ItemInfoWand()).setDisplay("Infowerkzeug"));
		registerItem("lightning_wand", (new ItemLightning()).setDisplay("Geladenes Zepter"));
		registerItem("banhammer", (new ItemBanHammer()).setDisplay("Hammer der Verbannung").setTab(CheatTab.tabTools));
		registerItem("key", (new ItemKey()).setDisplay("Schlüssel").setTab(CheatTab.tabTools).setMaxStackSize(128));
		registerItem("die", (new ItemDie()).setDisplay("Würfel").setMaxStackSize(128));
		registerItem("chick_magnet", (new ItemMagnet(true)).setDisplay("Kükenmagnet"));
		registerItem("magnet", (new ItemMagnet(false)).setDisplay("Magnet"));
		registerItem("camera", (new ItemCamera()).setDisplay("Kamera").setTab(CheatTab.tabTools));
		
		for(Weather weather : Weather.values()) {
			registerItem("weather_token_" + weather.getName(), new ItemWeatherToken(weather).setDisplay("Wetterkristall").setTab(CheatTab.tabTools));
		}
		
		registerItem("flint_and_steel", (new ItemFlintAndSteel()).setDisplay("Feuerzeug"));
		registerItem("apple", (new ItemFood(4, false)).setDisplay("Apfel").setMaxStackSize(128));
		registerItem("bow", (new ItemBow()).setDisplay("Bogen"));
		registerItem("boltgun", (new ItemBoltgun()).setDisplay("Bolter"));
		registerItem("bolt", (new ItemAmmo(5, 1.0f, 128)).setDisplay("Bolter-Munition"));
		registerItem("arrow", (new Item()).setDisplay("Pfeil").setTab(CheatTab.tabCombat).setMaxStackSize(128));
		Item coal = (new ItemCoal()).setDisplay("Kohle");
		registerItem("coal", coal);
		registerItem("stick", (new ItemStick()).setDisplay("Stock").setTab(CheatTab.tabMaterials).setMaxStackSize(256));
		registerItem("bowl", (new ItemSmall()).setDisplay("Schüssel").setTab(CheatTab.tabMisc));
		registerItem("mushroom_stew", (new ItemSoup(6)).setDisplay("Pilzsuppe"));
		registerItem((new ItemReed(Blocks.string)).setDisplay("Faden").setTab(CheatTab.tabTech).setMaxStackSize(1024));
		registerItem("feather", (new Item()).setDisplay("Feder").setTab(CheatTab.tabMaterials).setMaxStackSize(512));
		registerItem("gunpowder", (new Item()).setDisplay("Schwarzpulver").setPotionEffect(PotionHelper.gunpowderEffect).setTab(CheatTab.tabMaterials).setMaxStackSize(256));
		registerItem((new ItemSeeds(Blocks.wheat, Blocks.farmland)).setDisplay("Weizenkörner").setMaxStackSize(256));
		registerItem("wheats", (new Item()).setDisplay("Weizen").setTab(CheatTab.tabMaterials).setMaxStackSize(128));
		registerItem("bread", (new ItemFood(5, false)).setDisplay("Brot"));
		registerItem("flint", (new Item()).setDisplay("Feuerstein").setTab(CheatTab.tabMaterials).setMaxStackSize(128));
		registerItem("porkchop", (new ItemFood(3, true)).setDisplay("Rohes Schweinefleisch"));
		registerItem("cooked_porkchop", (new ItemFood(8, true)).setDisplay("Gebratenes Schweinefleisch"));
		registerItem("golden_apple", (new ItemAppleGold(4, false)).setPotionEffect(Potion.REGENERATION, 5, 1, 1.0F)
				.setDisplay("Goldener Apfel"));
		registerItem((new ItemSign()).setDisplay("Schild"));
//		registerItem("oak_door", (new ItemDoor(Blocks.oak_door)).setUnlocalizedName("doorOak"));
//		registerItem("water_bucket", (new ItemBucket(Blocks.flowing_water)).setUnlocalizedName("bucketWater").setContainerItem(bucket));
//		registerItem("lava_bucket", (new ItemBucket(Blocks.flowing_lava)).setUnlocalizedName("bucketLava").setContainerItem(bucket));
		registerItem("saddle", (new ItemSaddle()).setDisplay("Sattel"));
//		registerItem("iron_door", (new ItemDoor(Blocks.iron_door)).setUnlocalizedName("doorIron"));
		registerItem((new ItemRedstone()).setDisplay("Redstone").setPotionEffect(PotionHelper.redstoneEffect).setMaxStackSize(256));
		registerItem("snowball", (new ItemSnowball()).setDisplay("Schneeball").setMaxStackSize(128));
		registerItem("leather", (new Item()).setDisplay("Leder").setTab(CheatTab.tabMaterials));
		registerItem("brick", (new Item()).setDisplay("Ziegel").setTab(CheatTab.tabMaterials));
		registerItem("clay_ball", (new Item()).setDisplay("Ton").setTab(CheatTab.tabMaterials).setMaxStackSize(128));
		registerItem((new ItemReed(Blocks.reeds)).setDisplay("Zuckerrohr").setTab(CheatTab.tabPlants).setMaxStackSize(128));
		registerItem("paper", (new Item()).setDisplay("Papier").setTab(CheatTab.tabMaterials).setMaxStackSize(256));
		registerItem("book", (new ItemBook()).setDisplay("Buch").setTab(CheatTab.tabMisc));
		registerItem("slime_ball", (new Item()).setDisplay("Schleimball").setTab(CheatTab.tabMaterials).setMaxStackSize(128));
		registerItem("egg", (new ItemEgg()).setDisplay("Ei").setMaxStackSize(128));
		registerItem("navigator", (new ItemSpaceNavigator()).setDisplay("Elektronischer Navigator").setTab(CheatTab.tabTools));
		registerItem("exterminator", (new ItemExterminator()).setDisplay("Weltenzerstörer").setTab(CheatTab.tabTools));
		registerItem("fishing_rod", (new ItemFishingRod()).setDisplay("Angel"));
		registerItem("glowstone_dust", (new Item()).setDisplay("Glowstonestaub").setPotionEffect(PotionHelper.glowstoneEffect)
				.setTab(CheatTab.tabMaterials).setMaxStackSize(256));
		registerItem("fish", (new ItemFishFood(false)).setDisplay("Fisch").setHasSubtypes(true));
		registerItem("cooked_fish", (new ItemFishFood(true)).setDisplay("Fisch").setHasSubtypes(true));
		Item dye = (new ItemDye()).setDisplay("Farbstoff").setMaxStackSize(512);
		registerItem("dye", dye);
		registerItem("bone", (new ItemStick()).setDisplay("Knochen").setTab(CheatTab.tabMaterials).setMaxStackSize(128));
		registerItem("sugar", (new Item()).setDisplay("Zucker").setPotionEffect(PotionHelper.sugarEffect).setTab(CheatTab.tabMaterials).setMaxStackSize(512));
		registerItem((new ItemReed(Blocks.cake)).setMaxStackSize(1).setDisplay("Kuchen").setTab(CheatTab.tabDeco));
		registerItem((new ItemReed(Blocks.repeater)).setDisplay("Redstone-Verstärker").setTab(CheatTab.tabTech));
		registerItem("cookie", (new ItemFood(2, false)).setDisplay("Keks").setMaxStackSize(128));
		registerItem("melon", (new ItemFood(2, false)).setDisplay("Melone"));
		registerItem((new ItemSeeds(Blocks.pumpkin_stem, Blocks.farmland)).setDisplay("Kürbiskerne").setMaxStackSize(256));
		registerItem((new ItemSeeds(Blocks.melon_stem, Blocks.farmland)).setDisplay("Melonenkerne").setMaxStackSize(256));
		registerItem("beef", (new ItemFood(3, true)).setDisplay("Rohes Rindfleisch"));
		registerItem("cooked_beef", (new ItemFood(8, true)).setDisplay("Steak"));
		registerItem("chicken", (new ItemFood(2, true)).setDisplay("Rohes Hühnchen"));
		registerItem("cooked_chicken", (new ItemFood(6, true)).setDisplay("Gebratenes Hühnchen"));
		registerItem("rotten_flesh", (new ItemFood(4, true)).setDisplay("Verrottetes Fleisch"));
		registerItem("orb", (new ItemFragile()).setDisplay("Kugel").setTab(CheatTab.tabTools));
		registerItem("blaze_rod", (new ItemRod()).setDisplay("Lohenrute").setTab(CheatTab.tabMaterials).setMaxStackSize(256));
		registerItem("ghast_tear", (new ItemTiny()).setDisplay("Ghastträne").setPotionEffect(PotionHelper.ghastTearEffect).setTab(CheatTab.tabMaterials).setMaxStackSize(256));
		registerItem("gold_nugget", (new ItemNugget()).setDisplay("Goldnugget").setTab(CheatTab.tabMetals).setMaxStackSize(256));
		registerItem((new ItemSeeds(Blocks.soul_wart, Blocks.soul_sand)).setDisplay("Seelenwarze").setPotionEffect("+4").setMaxStackSize(128));
		registerItem("potion", (new ItemPotion()).setDisplay("Trank"));
		registerItem("glass_bottle", (new ItemGlassBottle()).setDisplay("Glasflasche"));
		registerItem("spider_eye", (new ItemFood(2, false)).setPotionEffect(Potion.POISON, 5, 0, 1.0F).setDisplay("Spinnenauge")
				.setPotionEffect(PotionHelper.spiderEyeEffect).setMaxStackSize(128));
		registerItem("fermented_spider_eye", (new Item()).setDisplay("Fermentiertes Spinnenauge")
				.setPotionEffect(PotionHelper.fermentedSpiderEyeEffect).setTab(CheatTab.tabMisc).setMaxStackSize(128));
		registerItem("blaze_powder", (new Item()).setDisplay("Lohenstaub").setPotionEffect(PotionHelper.blazePowderEffect)
				.setTab(CheatTab.tabMaterials).setMaxStackSize(256));
		registerItem("magma_cream", (new Item()).setDisplay("Magmacreme").setPotionEffect(PotionHelper.magmaCreamEffect).setTab(CheatTab.tabMaterials).setMaxStackSize(128));
		registerItem((new ItemReed(Blocks.brewing_stand)).setDisplay("Braustand").setTab(CheatTab.tabTech));
		registerItem((new ItemReed(Blocks.cauldron)).setDisplay("Kessel").setTab(CheatTab.tabTech));
		registerItem("charged_orb", (new ItemChargedOrb()).setDisplay("Geladene Kugel"));
		registerItem("speckled_melon", (new Item()).setDisplay("Glitzernde Melone").setPotionEffect(PotionHelper.speckledMelonEffect)
				.setTab(CheatTab.tabMisc));
		registerItem("experience_bottle", (new ItemExpBottle()).setDisplay("Erfahrungsfläschchen"));
		registerItem("fire_charge", (new ItemFireball()).setDisplay("Feuerkugel"));
		registerItem("writable_book", (new Item()).setDisplay("Buch und Feder").setTab(CheatTab.tabTools));
		registerItem("written_book", (new Item()).setDisplay("Beschriebenes Buch").setTab(CheatTab.tabMisc));
		Item emerald = (new Item()).setDisplay("Smaragd").setTab(CheatTab.tabMetals);
		registerItem("emerald", emerald);
		registerItem((new ItemReed(Blocks.flower_pot)).setDisplay("Blumentopf").setTab(CheatTab.tabDeco));
		registerItem((new ItemSeedFood(3, Blocks.carrot, Blocks.farmland)).setDisplay("Karotte").setMaxStackSize(128));
		registerItem((new ItemSeedFood(1, Blocks.potato, Blocks.farmland)).setDisplay("Kartoffel").setMaxStackSize(128));
		registerItem("baked_potato", (new ItemFood(5, false)).setDisplay("Ofenkartoffel").setMaxStackSize(128));
		registerItem("poisonous_potato", (new ItemFood(2, false)).setPotionEffect(Potion.POISON, 5, 0, 0.6F).setDisplay("Giftige Kartoffel").setMaxStackSize(128));
		registerItem("golden_carrot", (new ItemFood(6, false)).setDisplay("Goldene Karotte")
				.setPotionEffect(PotionHelper.goldenCarrotEffect).setTab(CheatTab.tabMisc));
		registerItem((new ItemSkull()).setDisplay("Kopf"));
		registerItem("carrot_on_a_stick", (new ItemCarrotOnAStick()).setDisplay("Karottenrute"));
		registerItem("charge_crystal", (new ItemEffect()).setDisplay("Energiekristall").setTab(CheatTab.tabMisc).setColor(TextColor.DMAGENTA));
		registerItem("pumpkin_pie", (new ItemFood(8, false)).setDisplay("Kürbiskuchen").setTab(CheatTab.tabMisc));
		registerItem("fireworks", (new ItemFirework()).setDisplay("Feuerwerksrakete"));
		registerItem("firework_charge", (new ItemFireworkCharge()).setDisplay("Feuerwerksstern").setTab(CheatTab.tabMaterials));
		registerItem("enchanted_book", (new ItemEnchantedBook()).setMaxStackSize(1).setDisplay("Verzaubertes Buch").setTab(CheatTab.tabMagic));
		registerItem((new ItemReed(Blocks.comparator)).setDisplay("Redstone-Komparator").setTab(CheatTab.tabTech));
		registerItem("bloodbrick", (new Item()).setDisplay("Blutroter Ziegel").setTab(CheatTab.tabMaterials));
		registerItem("blackbrick", (new Item()).setDisplay("Schwarzer Ziegel").setTab(CheatTab.tabMaterials));
		Item quartz = (new Item()).setDisplay("Quarz").setTab(CheatTab.tabMetals);
		registerItem("quartz", quartz);
		Item bquartz = (new Item()).setDisplay("Schwarzes Quarz").setTab(CheatTab.tabMetals);
		registerItem("black_quartz", bquartz);
		registerItem("lead", (new ItemLead()).setDisplay("Leine").setMaxStackSize(128));
		registerItem("name_tag", (new ItemNameTag()).setDisplay("Namensschild"));
		registerItem((new ItemBanner()).setDisplay("Banner"));
//		registerItem("spruce_door", (new ItemDoor(Blocks.spruce_door)).setUnlocalizedName("doorSpruce"));
//		registerItem("birch_door", (new ItemDoor(Blocks.birch_door)).setUnlocalizedName("doorBirch"));
//		registerItem("jungle_door", (new ItemDoor(Blocks.jungle_door)).setUnlocalizedName("doorJungle"));
//		registerItem("acacia_door", (new ItemDoor(Blocks.acacia_door)).setUnlocalizedName("doorAcacia"));
//		registerItem("dark_oak_door", (new ItemDoor(Blocks.dark_oak_door)).setUnlocalizedName("doorDarkOak"));
		registerItem("dynamite", (new ItemDynamite()).setDisplay("Dynamit").setColor(TextColor.RED));
//		registerItem("cherry_door", (new ItemDoor(Blocks.cherry_door)).setUnlocalizedName("doorCherry"));
//		registerItem("maple_door", (new ItemDoor(Blocks.maple_door)).setUnlocalizedName("doorMaple"));
		registerItem("chain", (new ItemMagnetic()).setDisplay("Kette").setTab(CheatTab.tabMaterials));
		
		for(OreType ore : OreType.values()) {
//			String loc = ore.name.substring(0, 1).toUpperCase() + ore.name.substring(1);
//			registerItemBlock(BlockRegistry.getRegisteredBlock(ore.name + "_ore"));
//			registerItemBlock(BlockRegistry.getRegisteredBlock(ore.name + "_block"));
//			if(ore.gem != null) {
			Item itm = (new Item()).setDisplay(ore.itemDisplay).setTab(CheatTab.tabMetals);
			registerItem(ore.item, itm);
			((BlockOre)BlockRegistry.getRegisteredBlock(ore.name + "_ore")).setDropItem(new ItemStack(itm, ore.dropQuantity),
					ore.bonusChance, ore.experience);
//			}
//			else {
//				Item itm = (new Item()).setUnlocalizedName("ingot" + loc).setCreativeTab(CreativeTab.tabMaterialsFood);
//				registerItem(ore.name + "_ingot", itm);
//				((BlockOre)BlockRegistry.getRegisteredBlock(ore.name + "_ore")).setSmeltItem(new ItemStack(itm));
//			}
			registerTools(ore.material, ore.name, ore.display);
		}
		for(MetalType metal : MetalType.values()) {
//			String loc = metal.name.substring(0, 1).toUpperCase() + metal.name.substring(1);
			Block oreBlock = BlockRegistry.getRegisteredBlock(metal.name + "_ore");
			ItemBlock ore = new ItemMetalBlock(oreBlock, metal, true);
			registerBlock(oreBlock, ore);
			Block fullBlock = BlockRegistry.getRegisteredBlock(metal.name + "_block");
			ItemBlock block = new ItemMetalBlock(fullBlock, metal, false);
			registerBlock(fullBlock, block);
			if(metal.isPowder) {
				Item itm = (new ItemMetal(metal)).setDisplay(metal.display + "pulver").setTab(CheatTab.tabMetals);
				registerItem(metal.name + "_powder", itm);
				((BlockOre)BlockRegistry.getRegisteredBlock(metal.name + "_ore")).setDropItem(new ItemStack(itm), 0, 2);
			}
			else {
				Item itm = (new ItemMetal(metal)).setDisplay(metal.display + "barren").setTab(CheatTab.tabMetals);
				registerItem(metal.name + "_ingot", itm);
				((BlockOre)BlockRegistry.getRegisteredBlock(metal.name + "_ore")).setSmeltItem(new ItemStack(itm));
			}
			if(metal.material != null)
				registerTools(metal.material, metal.name, metal.display);
		}
		for(ToolType tool : ToolType.values()) {
			registerTools(tool.material, tool.name, tool.display);
		}
        for(BlockDoor door : BlockDoor.DOORS) {
        	registerItem(new ItemDoor(door)); // .setDisplay(door.getDisplay()));
        }
        for(DyeColor color : BlockBed.COLORS) {
        	registerItem(new ItemBed((BlockBed)BlockRegistry.getRegisteredBlock(color.getName() + "_bed")).setMaxStackSize(1).setDisplay(color.getSubject(0) + " Bett"));
        }

		registerItem("record_13", (new ItemRecord()).setDisplay("Protokoll #1 - 13 Tage ohne Kaffee"));
		registerItem("record_cat", (new ItemRecord()).setDisplay("Protokoll #2 - Versuchskatzen"));
		registerItem("record_blocks", (new ItemRecord()).setDisplay("Protokoll #3 - Blöcke und mehr Experimente"));
		registerItem("record_chirp", (new ItemRecord()).setDisplay("Protokoll #4 - Experimente mit Vögeln: Eine gute Idee?"));
		registerItem("record_far", (new ItemRecord()).setDisplay("Protokoll #5 - Haben wir es mit dem Design übertrieben?"));
		registerItem("record_mall", (new ItemRecord()).setDisplay("Protokoll #6 - Wocheneinkauf und mehr Kaffee"));
		registerItem("record_mellohi", (new ItemRecord()).setDisplay("Protokoll #7 - Explosion: Hoffe auf Versicherungsersatz"));
		registerItem("record_stal", (new ItemRecord()).setDisplay("Protokoll #8 - Fortschritt stagniert"));
		registerItem("record_strad", (new ItemRecord()).setDisplay("Protokoll #9 - Neue Strategie"));
		registerItem("record_ward", (new ItemRecord()).setDisplay("Protokoll #10 - Neue Lösung: Seelenwarzen??"));
		registerItem("record_11", (new ItemRecord()).setDisplay("Protokoll #11 - Wir waren erfolgreich"));
		registerItem("record_wait", (new ItemRecord()).setDisplay("Protokoll #12 - Warte auf Bezahlung"));
		registerItem("record_delay", (new ItemRecord()).setDisplay("Protokoll #13 - Verzögerung der Umsetzung"));
		registerItem("record_extend", (new ItemRecord()).setDisplay("Protokoll #14 - Explosive Erweiterung unseres Labors"));

		((BlockOre)BlockRegistry.getRegisteredBlock("coal_ore")).setDropItem(new ItemStack(coal), 0);
		((BlockOre)BlockRegistry.getRegisteredBlock("emerald_ore")).setDropItem(new ItemStack(emerald), 3);
		((BlockOre)BlockRegistry.getRegisteredBlock("lapis_ore")).setDropItem(new ItemStack(dye, 4, DyeColor.BLUE.getDyeDamage()), 4, 2);
		((BlockOre)BlockRegistry.getRegisteredBlock("quartz_ore")).setDropItem(new ItemStack(quartz), 2);
		((BlockOre)BlockRegistry.getRegisteredBlock("black_quartz_ore")).setDropItem(new ItemStack(bquartz), 3);
		
		
		for(int z = 0; z < FluidRegistry.getNumFluids(); z++) {
			registerSpecial(FluidRegistry.getFluidBlock(z));
			registerSpecial(FluidRegistry.getStaticBlock(z));
		}
//        for(EnumDyeColor color : BlockBed.COLORS) {
//        	registerSpecial(BlockRegistry.getRegisteredBlock(color.getName() + "_bed"));
//        }
//        for(BlockDoor door : BlockDoor.DOORS) {
//        	registerSpecial(door);
//        }
        
        registerSpecial(Blocks.air);
        
//        registerSpecial(Blocks.flowing_water);
//        registerSpecial(Blocks.water);
//        registerSpecial(Blocks.flowing_lava);
//        registerSpecial(Blocks.lava);
        
//        registerSpecial(Blocks.wheat);
//        registerSpecial(Blocks.carrots);
//        registerSpecial(Blocks.potatoes);
//        registerSpecial(Blocks.soul_wart);
//        registerSpecial(Blocks.pumpkin_stem);
//        registerSpecial(Blocks.melon_stem);
        registerSpecial(Blocks.cocoa);
//        registerSpecial(Blocks.reeds);

        registerSpecial(Blocks.fire);
        registerSpecial(Blocks.portal);
        registerSpecial(Blocks.floor_portal);
//        registerSpecial(Blocks.standing_sign);
        registerSpecial(Blocks.wall_sign);
//        registerSpecial(Blocks.standing_banner);
        registerSpecial(Blocks.wall_banner);
//        registerSpecial(Blocks.cake);
//        registerSpecial(Blocks.brewing_stand);
//        registerSpecial(Blocks.cauldron);
//        registerSpecial(Blocks.flower_pot);
//        registerSpecial(Blocks.skull);

//        registerSpecial(Blocks.tripwire);
        registerSpecial(Blocks.piston_head);
        registerSpecial(Blocks.piston_extension);
        registerSpecial(Blocks.lit_redstone_ore);
        registerSpecial(Blocks.lit_redstone_lamp);
//        registerSpecial(Blocks.redstone_wire);
        registerSpecial(Blocks.unlit_redstone_torch);
//        registerSpecial(Blocks.unpowered_repeater);
        registerSpecial(Blocks.powered_repeater);
//        registerSpecial(Blocks.unpowered_comparator);
        registerSpecial(Blocks.powered_comparator);
        registerSpecial(Blocks.daylight_detector_inverted);
		
		for(Block block : BlockRegistry.REGISTRY) {
			if(!BLOCKMAP.containsKey(block) && !SPECIALIZED.contains(block))
				registerBlock(block, new ItemBlock(block));
//				Log.info("Block " + BlockRegistry.REGISTRY.getNameForObject(block) + " hat kein Item");
		}
	}
}
