package common.init;

import common.block.*;
import common.color.DyeColor;
import common.init.FluidRegistry.LiquidType;
import common.item.CheatTab;
import common.material.Material;
import common.world.State;

public abstract class BlockRegistry {
	private static final String AIR_ID = "air";
	public static final RegistryNamespacedDefaultedByKey<String, Block> REGISTRY = new RegistryNamespacedDefaultedByKey(AIR_ID);
	public static final ObjectIntIdentityMap<State> STATEMAP = new ObjectIntIdentityMap();

	public static int getIdFromBlock(Block block) {
		return REGISTRY.getIDForObject(block);
	}

	public static int getStateId(State state) {
		Block block = state.getBlock();
		return getIdFromBlock(block) + (block.getMetaFromState(state) << 12);
	}

	public static Block getBlockById(int id) {
		return (Block)REGISTRY.getObjectById(id);
	}

	public static State getStateById(int id) {
		int i = id & 4095;
		int j = id >> 12 & 15;
		return getBlockById(i).getStateFromMeta(j);
	}

	public static Block getByNameOrId(String name) {
		Block block = REGISTRY.getObjectExact(name);
		if(block == null) {
			try {
				return REGISTRY.getObjectExact(Integer.parseInt(name));
			}
			catch(NumberFormatException e) {
			}
		}
		return block;
	}

	public static Block getByIdFallback(String name) {
//		String loc = StringUtils.trimColon(name);
		if(REGISTRY.containsKey(name)) {
			return REGISTRY.getObject(name);
		}
		else {
			try {
				return REGISTRY.getObjectById(Integer.parseInt(name));
			}
			catch(NumberFormatException e) {
				return null;
			}
		}
	}

	public static String toIdName(State block) {
		int meta = block.getBlock().getMetaFromState(block);
		return REGISTRY.getNameForObject(block.getBlock()).toString() + 
				((meta == block.getBlock().getMetaFromState(block.getBlock().getState())) ? "" : (":" + meta));
	}

	public static State getFromIdName(String name, State def) {
		if(name == null) {
			return def;
		}
		String[] tok = name.split(":");
		if(tok.length < 1 || tok.length > 2) {
			return def;
		}
		Block block = getByNameOrId(tok[0]);
//		if(block == null) {
//			try {
//				block = getBlockById(Integer.parseUnsignedInt(tok[0]));
//			}
//			catch(NumberFormatException e) {
//			}
//		}
		if(block == null) {
			return def;
		}
		byte data;
		if(tok.length == 2) {
			try {
				int i = (byte)Integer.parseUnsignedInt(tok[1]);
				if(i >= 16) {
					return def;
				}
				data = (byte)i;
			}
			catch(NumberFormatException e) {
				return def;
			}
		}
		else {
			data = (byte)block.getMetaFromState(block.getState());
		}
		return block.getStateFromMeta(data);
	}

	public static Block getRegisteredBlock(String name) {
		return REGISTRY.getObject(name);
	}

	static void register() {
		REGISTRY.register(0, BlockRegistry.AIR_ID, (new BlockAir()).setDisplay("Luft"));
		registerBlocks();
		REGISTRY.validateKey();

		for(Block block : REGISTRY) {
			if(block.getMaterial() != Material.air
					&& ((block instanceof BlockStairs) || /* (block instanceof BlockSlab) || */ (block instanceof BlockSlab)
							|| (block instanceof BlockFarmland) || block.isTranslucent() || block.getLightOpacity() == 0)) {
				block.setSumBrightness();
			}
		}

		for(Block block : REGISTRY) {
			for(State state : block.getValidStates()) {
				STATEMAP.put(state, REGISTRY.getIDForObject(block) << 4 | block.getMetaFromState(state));
			}
		}
	}

	private static void registerBlock(int id, String name, Block block) {
		BlockRegistry.REGISTRY.register(id, name, block);
	}
	
	private static void registerFluid(int idd, int ids, String name, String display, boolean infinite, LiquidType type, boolean opaque, 
			int light, int rate, float radiation, Object still, Object flowing) {
		BlockDynamicLiquid dy = (BlockDynamicLiquid)(new BlockDynamicLiquid(type.material, infinite, opaque, rate)).setHardness(100.0F)
				.setLightOpacity(opaque ? 0 : 3).setLightLevel((float)light / 15.0f).setDisplay(display)
				.setRadiation(radiation);
		registerBlock(idd, "flowing_" + name, dy);
		BlockStaticLiquid st = (BlockStaticLiquid)(new BlockStaticLiquid(type.material, opaque, rate)).setHardness(100.0F)
				.setLightOpacity(opaque ? 0 : 3).setLightLevel((float)light / 15.0f).setDisplay(display)
				.setRadiation(radiation);
		registerBlock(ids, name, st);
		FluidRegistry.registerFluid(st, dy, still, flowing);
	}

	private static void registerBlocks() {
		Block stone = (new BlockStone()).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Stein");
		registerBlock(1, "stone", stone);
		registerBlock(2, "bedrock", (new BlockBedrock()).setHardness(1000.0F).setResistance(100000.0F).setStepSound(SoundType.STONE)
				.setDisplay("Grundgestein").setTab(CheatTab.tabNature).setMiningLevel(6));
		registerBlock(3, "rock",
				(new BlockRock()).setHardness(2.0F).setResistance(15.0F).setStepSound(SoundType.STONE).setDisplay("Felsen"));
		registerBlock(4, "hellrock", (new BlockHellRock()).setHardness(0.4F).setStepSound(SoundType.STONE).setDisplay("Höllenstein"));
		registerBlock(5, "cell_rock", (new Block(Material.clay)).setHardness(1.0F).setResistance(3.0F)
				.setStepSound(SoundType.SLIME).setDisplay("Zellstein").setTab(CheatTab.tabNature));
		registerBlock(6, "moon_rock", (new Block(Material.rock)).setHardness(2.5F).setResistance(10.0F)
				.setStepSound(SoundType.STONE).setDisplay("Mondgestein").setTab(CheatTab.tabNature));
		Block cobblestone = (new Block(Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE)
				.setDisplay("Bruchstein").setTab(CheatTab.tabNature);
		registerBlock(7, "cobblestone", cobblestone);
		registerBlock(8, "mossy_cobblestone", (new Block(Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE)
				.setDisplay("Bemooster Bruchstein").setTab(CheatTab.tabNature));
		Block sandstone = (new BlockSandStone()).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Sandstein");
		registerBlock(9, "sandstone", sandstone);
		registerBlock(10, "obsidian", (new BlockObsidian()).setHardness(50.0F).setResistance(2000.0F).setStepSound(SoundType.STONE)
				.setDisplay("Obsidian").setMiningLevel(3));
		registerBlock(11, "clay",
				(new BlockClay()).setHardness(0.6F).setStepSound(SoundType.GRAVEL).setDisplay("Ton").setShovelHarvestable());
		registerBlock(12, "hardened_clay",
				(new BlockHardenedClay()).setHardness(1.25F).setResistance(7.0F).setStepSound(SoundType.STONE).setDisplay("Gebrannter Ton"));
		registerBlock(13, "stained_hardened_clay", (new BlockColored(Material.rock)).setHardness(1.25F).setResistance(7.0F)
				.setStepSound(SoundType.STONE).setDisplay("gefärbter Ton").setTab(CheatTab.tabNature));
		registerBlock(14, "coal_block", (new Block(Material.rock)).setHardness(5.0F).setResistance(10.0F)
				.setStepSound(SoundType.STONE).setDisplay("Kohleblock").setTab(CheatTab.tabNature));
		registerBlock(15, "sand", (new BlockSand()).setHardness(0.5F).setStepSound(SoundType.SAND).setDisplay("Sand").setShovelHarvestable());
		registerBlock(16, "gravel",
				(new BlockGravel()).setHardness(0.6F).setStepSound(SoundType.GRAVEL).setDisplay("Kies").setShovelHarvestable());
		registerBlock(17, "ash",
				(new Block(Material.sand)).setHardness(0.2F).setStepSound(SoundType.SAND).setDisplay("Asche")
				.setTab(CheatTab.tabNature).setShovelHarvestable());
		registerBlock(18, "snow_layer", (new BlockSnow()).setHardness(0.1F).setStepSound(SoundType.SNOW).setDisplay("Schnee").setLightOpacity(0)
				.setShovelHarvestable());
		registerBlock(19, "snow",
				(new BlockSnowBlock()).setHardness(0.2F).setStepSound(SoundType.SNOW).setDisplay("Schnee").setShovelHarvestable());
		registerBlock(20, "ice",
				(new BlockIce()).setHardness(0.5F).setLightOpacity(3).setStepSound(SoundType.GLASS).setDisplay("Eis").setMiningLevel(0));
		registerBlock(21, "packed_ice",
				(new BlockPackedIce()).setHardness(0.5F).setStepSound(SoundType.GLASS).setDisplay("Packeis").setMiningLevel(0));
		registerBlock(22, "soul_sand",
				(new BlockSoulSand()).setHardness(0.5F).setStepSound(SoundType.SAND).setDisplay("Seelensand").setShovelHarvestable());
		registerBlock(23, "glowstone", (new BlockGlowstone(Material.glass)).setHardness(0.3F).setStepSound(SoundType.GLASS).setLightLevel(1.0F)
				.setDisplay("Glowstone"));
		registerBlock(24, "blackened_stone", (new BlockBlackenedStone()).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Schwarzstein"));
		registerBlock(25, "blackened_cobble", (new Block(Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE)
				.setDisplay("Schwarzbruchstein").setTab(CheatTab.tabNature));
		
		
		registerFluid(32, 33, "water", "Wasser", true, LiquidType.WATER, false, 0, 5, 0.0f, "water", "waterflow");
		registerFluid(34, 35, "lava", "Lava", false, LiquidType.LAVA, true, 15, -30, 0.0f, 2, 3);
		registerFluid(36, 37, "magma", "Magma", false, LiquidType.HOT, true, 15, 40, 0.0f, "lava", "lavaflow");
        registerFluid(38, 39, "mercury", "Quecksilber", false, LiquidType.COLD, true, 0, 40, 0.0f, 8, 4);
        registerFluid(40, 41, "hydrogen", "Wasserstoff", false, LiquidType.COLD, true, 0, 50, 0.0f, 8, 4);
        registerFluid(42, 43, "acid", "Säure", false, LiquidType.HOT, false, 0, 5, 0.0f, 1, 1);
        registerFluid(44, 45, "slime", "Schleim", false, LiquidType.COLD, true, 0, 50, 0.0f, 8, 4);
        registerFluid(46, 47, "goo", "Klebrige Masse", false, LiquidType.COLD, true, 0, 60, 0.0f, 10, 5);
        registerFluid(48, 49, "nukage", "Radioaktive Masse", false, LiquidType.COLD, true, 10, 10, 4.0f, 2, 2);
        registerFluid(50, 51, "blood", "Blut", false, LiquidType.COLD, false, 0, 10, 0.0f, 2, 1);
        

		registerBlock(60, "coal_ore",
				(new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE).setDisplay("Steinkohle"));
		registerBlock(61, "lapis_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE)
				.setDisplay("Lapislazulierz").setMiningLevel(1));
		registerBlock(62, "emerald_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE)
				.setDisplay("Smaragderz").setMiningLevel(2));
		registerBlock(63, "quartz_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE)
				.setDisplay("Quarzerz"));
		registerBlock(64, "black_quartz_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE)
				.setDisplay("Schwarzes Quarzerz"));

		registerBlock(68, "redstone_ore", (new BlockRedstoneOre(false)).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE)
				.setDisplay("Redstone-Erz").setTab(CheatTab.tabGems).setMiningLevel(2));
		registerBlock(69, "lit_redstone_ore", (new BlockRedstoneOre(true)).setLightLevel(0.625F).setHardness(3.0F).setResistance(5.0F)
				.setStepSound(SoundType.STONE).setDisplay("Redstone-Erz").setMiningLevel(2));
		int bid = 70;
		for(MetalType metal : MetalType.values()) {
//			String loc = metal.name.substring(0, 1).toUpperCase() + metal.name.substring(1);
			registerBlock(bid++, metal.name + "_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE)
					.setDisplay(metal.display + "erz").setMiningLevel(1).setLightLevel(metal.radioactivity > 0.0F ? 0.25F : 0.0F)
					.setRadiation(metal.radioactivity * 0.5f));
		}
		bid = 110;
		for(OreType ore : OreType.values()) {
//			String loc = ore.name.substring(0, 1).toUpperCase() + ore.name.substring(1);
			registerBlock(bid++, ore.name + "_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE)
					.setDisplay(ore.display + "erz").setMiningLevel(ore.material.getHarvestLevel() - 1));
		}

		
		

		registerBlock(128, "dirt",
				(new BlockDirt()).setHardness(0.5F).setStepSound(SoundType.GRAVEL).setDisplay("Erde").setShovelHarvestable());
		registerBlock(129, "grass",
				(new BlockGrass()).setHardness(0.6F).setStepSound(SoundType.GRASS).setDisplay("Gras").setShovelHarvestable());
		registerBlock(130, "mycelium",
				(new BlockMycelium()).setHardness(0.6F).setStepSound(SoundType.GRASS).setDisplay("Myzel").setShovelHarvestable());
		registerBlock(131, "tian", (new Block(Material.rock)).setHardness(2.0F).setResistance(15.0F).setStepSound(SoundType.STONE)
				.setDisplay("Tian").setTab(CheatTab.tabNature));
		registerBlock(132, "tian_soil", (new BlockTianSoil()).setHardness(2.0F).setResistance(15.0F).setStepSound(SoundType.STONE)
				.setDisplay("Tianerde").setTab(CheatTab.tabNature));
		registerBlock(133, "moon_cheese", (new BlockTreasure(Material.gourd)).setHardness(1.5F).setResistance(5.0F)
				.setStepSound(SoundType.CLOTH).setDisplay("Mondkäse").setTab(CheatTab.tabNature));
		registerBlock(134, "slime_block", (new BlockSlime()).setDisplay("Schleimblock").setStepSound(SoundType.SLIME));
		registerBlock(135, "blackened_dirt",
				(new BlockBlackenedDirt()).setHardness(0.5F).setStepSound(SoundType.GRAVEL).setDisplay("Schwarzerde").setShovelHarvestable());
		registerBlock(136, "blackened_soil",
				(new BlockBlackenedSoil()).setHardness(0.6F).setStepSound(SoundType.GRASS).setDisplay("Schwarzgrund").setShovelHarvestable());
		
		

		
		registerBlock(140, "tallgrass",
				(new BlockTallGrass()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Gras").setShearsEfficiency(0));
		registerBlock(141, "deadbush", (new BlockDeadBush()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Toter Busch"));
		registerBlock(142, "flower", (new BlockBaseFlower()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Blume"));
		registerBlock(143, "double_plant", new BlockDoublePlant().setDisplay("Pflanze"));
		registerBlock(144, "cactus", (new BlockCactus()).setHardness(0.4F).setStepSound(SoundType.CLOTH).setDisplay("Kaktus"));
		registerBlock(145, "reeds", (new BlockReed()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Zuckerrohr"));
		registerBlock(146, "vine",
				(new BlockVine()).setHardness(0.2F).setStepSound(SoundType.GRASS).setDisplay("Ranken").setShearsEfficiency(0));
		registerBlock(147, "waterlily", (new BlockLilyPad()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Seerosenblatt"));
		registerBlock(148, "cocoa",
				(new BlockCocoa()).setHardness(0.2F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay("Kakao"));
		
		

		Block brownMushroom = (new BlockMushroom()).setHardness(0.0F).setStepSound(SoundType.GRASS).setLightLevel(0.125F)
				.setDisplay("Pilz");
		registerBlock(160, "brown_mushroom", brownMushroom);
		registerBlock(161, "brown_mushroom_block", (new BlockHugeMushroom(Material.wood, brownMushroom)).setHardness(0.2F)
				.setStepSound(SoundType.WOOD).setDisplay("Pilzblock").setTab(CheatTab.tabPlants));
		Block redMushrooom = (new BlockMushroom()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Pilz");
		registerBlock(162, "red_mushroom", redMushrooom);
		registerBlock(163, "red_mushroom_block", (new BlockHugeMushroom(Material.wood, redMushrooom)).setHardness(0.2F)
				.setStepSound(SoundType.WOOD).setDisplay("Pilzblock").setTab(CheatTab.tabPlants));
		registerBlock(164, "blue_mushroom", (new BlockBlueShroom()).setHardness(0.0F).setStepSound(SoundType.GRASS).setLightLevel(0.5F)
				.setDisplay("Tianpilz"));

		Block pumpkin = (new BlockPumpkin()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Kürbis");
		registerBlock(170, "pumpkin", pumpkin);
		registerBlock(172, "pumpkin_stem", (new BlockStem(pumpkin)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Kürbisstamm"));
		Block melon = (new BlockMelon()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Melone");
		registerBlock(173, "melon_block", melon);
		registerBlock(174, "melon_stem", (new BlockStem(melon)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Melonenstamm"));
		

		registerBlock(179, "dry_leaves", (new BlockDryLeaves()).setDisplay("Vertrocknetes Laub"));
		bid = 180;
		for(WoodType wood : WoodType.values()) {
			registerBlock(bid++, wood.getName() + "_log", (new BlockLog()).setDisplay(wood.getDisplay() + "holz"));
			registerBlock(bid++, wood.getName() + "_leaves", (new BlockLeaves(wood)).setDisplay(wood.getDisplay() + "laub"));
			registerBlock(bid++, wood.getName() + "_sapling", (new BlockSapling(wood)).setHardness(0.0F).setStepSound(SoundType.GRASS)
					.setDisplay(wood.getDisplay() + "setzling"));
		}

		registerBlock(254, "web", (new BlockWeb()).setLightOpacity(1).setHardness(4.0F).setDisplay("Spinnennetz"));
		registerBlock(255, "fire",
				(new BlockFire()).setHardness(0.0F).setLightLevel(1.0F).setStepSound(SoundType.CLOTH).setDisplay("Feuer"));
        
        
		
		registerBlock(256, "lapis_block", (new Block(Material.iron)).setHardness(3.0F).setResistance(5.0F)
				.setStepSound(SoundType.STONE).setDisplay("Lapislazuliblock").setTab(CheatTab.tabGems).setMiningLevel(1));
		registerBlock(257, "emerald_block", (new Block(Material.iron)).setHardness(5.0F).setResistance(10.0F)
				.setStepSound(SoundType.STONE).setDisplay("Smaragdblock").setTab(CheatTab.tabGems).setMiningLevel(2));
		registerBlock(258, "redstone_block", (new BlockCompressedPowered(Material.iron)).setHardness(5.0F).setResistance(10.0F)
				.setStepSound(SoundType.STONE).setDisplay("Redstone-Block").setTab(CheatTab.tabTech));
		
		registerBlock(270, "glass",
				(new BlockGlass(Material.glass, false)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Glas"));
		registerBlock(271, "stained_glass",
				(new BlockStainedGlass(Material.glass)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("gefärbtes Glas"));
		registerBlock(272, "glass_pane",
				(new BlockPane(Material.glass, false)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Glasscheibe"));
		registerBlock(273, "stained_glass_pane",
				(new BlockStainedGlassPane()).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("gefärbte Glasscheibe"));
		
		
		
		registerBlock(280, "wool", (new BlockColored(Material.cloth)).setHardness(0.8F).setStepSound(SoundType.CLOTH).setDisplay("Wolle")
				.setShearsEfficiency(1));
		registerBlock(281, "carpet",
				(new BlockCarpet()).setHardness(0.1F).setStepSound(SoundType.CLOTH).setDisplay("Teppich").setLightOpacity(0));
		bid = 282;
        for(DyeColor color : BlockBed.COLORS) {
        	registerBlock(bid++, color.getName() + "_bed", (new BlockBed(color)).setStepSound(SoundType.WOOD).setHardness(0.2F).setDisplay(color.getSubject(0) + " Bett"));
        }

		registerBlock(300, "ladder",
				(new BlockLadder()).setHardness(0.4F).setStepSound(SoundType.LADDER).setDisplay("Leiter").setAxeHarvestable());
		registerBlock(301, "torch",
				(new BlockTorch()).setHardness(0.0F).setLightLevel(0.9375F).setStepSound(SoundType.WOOD).setDisplay("Fackel"));
		registerBlock(302, "lamp", (new Block(Material.glass)).setHardness(0.3F).setStepSound(SoundType.GLASS).setLightLevel(1.0F)
				.setDisplay("Lampe").setTab(CheatTab.tabTech));
		registerBlock(304, "bookshelf", (new BlockBookshelf()).setHardness(1.5F).setStepSound(SoundType.WOOD).setDisplay("Bücherregal"));
		registerBlock(305, "cake", (new BlockCake()).setHardness(0.5F).setStepSound(SoundType.CLOTH).setDisplay("Kuchen"));
		registerBlock(306, "dragon_egg", (new BlockDragonEgg()).setHardness(3.0F).setResistance(15.0F).setStepSound(SoundType.STONE)
				.setLightLevel(0.125F).setDisplay("Drachenei").setTab(CheatTab.tabDeco));
		registerBlock(307, "flower_pot", (new BlockFlowerPot()).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Blumentopf"));
		registerBlock(308, "sponge", (new Block(Material.sponge)).setHardness(0.6F).setStepSound(SoundType.GRASS).setDisplay("Schwamm")
				.setTab(CheatTab.tabDeco));
		registerBlock(309, "skull", (new BlockSkull()).setHardness(1.0F).setStepSound(SoundType.STONE).setDisplay("Kopf"));
		registerBlock(310, "lit_pumpkin",
				(new BlockPumpkin()).setHardness(1.0F).setStepSound(SoundType.WOOD).setLightLevel(1.0F).setDisplay("Kürbislaterne"));
		registerBlock(311, "hay_block", (new BlockHay()).setHardness(0.5F).setStepSound(SoundType.GRASS).setDisplay("Strohballen")
				.setTab(CheatTab.tabDeco));
		registerBlock(312, "sign",
				(new BlockStandingSign()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Schild"));
		registerBlock(313, "wall_sign",
				(new BlockWallSign()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Schild"));
		registerBlock(314, "banner",
				(new BlockBanner.BlockBannerStanding()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Banner"));
		registerBlock(315, "wall_banner",
				(new BlockBanner.BlockBannerHanging()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Banner"));
		
		registerBlock(390, "portal",
				(new BlockPortal()).setHardness(0.0F).setStepSound(SoundType.GLASS).setLightLevel(0.75F).setDisplay("Portal"));
		registerBlock(391, "floor_portal", (new BlockFloorPortal(Material.portal)).setHardness(0.0F).setDisplay("Portal"));
		registerBlock(392, "portal_frame", (new BlockPortalFrame()).setStepSound(SoundType.GLASS).setLightLevel(0.125F).setHardness(5.0F)
				.setDisplay("Portalrahmen").setResistance(2000.0F).setTab(CheatTab.tabTech));
		
		registerBlock(400, "farmland", (new BlockFarmland()).setHardness(0.6F).setStepSound(SoundType.GRAVEL).setDisplay("Ackerboden")
				.setShovelHarvestable().setTab(CheatTab.tabPlants));
		registerBlock(401, "wheat", (new BlockCrops()).setDisplay("Getreide"));
		registerBlock(402, "carrot", (new BlockCarrot()).setDisplay("Karotten"));
		registerBlock(403, "potato", (new BlockPotato()).setDisplay("Kartoffeln"));
		registerBlock(404, "soul_wart", (new BlockWart()).setDisplay("Seelenwarze"));
		
		


		bid = 500;
		for(MetalType metal : MetalType.values()) {
//			String loc = metal.name.substring(0, 1).toUpperCase() + metal.name.substring(1);
			registerBlock(bid++, metal.name + "_block",
					(new Block(Material.iron)).setHardness(5.0F).setResistance(10.0F).setStepSound(SoundType.STONE)
					.setDisplay(metal.display + "block").setTab(CheatTab.tabGems).setMiningLevel(1)
					.setLightLevel(metal.radioactivity > 0.0F ? 0.25F : 0.0F).setRadiation(metal.radioactivity * 2.0f));
		}
		bid = 540;
		for(OreType ore : OreType.values()) {
//			String loc = ore.name.substring(0, 1).toUpperCase() + ore.name.substring(1);
			registerBlock(bid++, ore.name + "_block",
					(new Block(Material.iron)).setHardness(5.0F).setResistance(10.0F).setStepSound(SoundType.STONE)
					.setDisplay(ore.display + "block").setTab(CheatTab.tabGems)
					.setMiningLevel(ore.material.getHarvestLevel() - 1));
		}
		




		
		registerBlock(600, "stone_slab",
				(new BlockSlab(Material.rock, "stone_slab_side", "double_stone_top", "double_stone_top"))
				.setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Steinstufe"));
		registerBlock(601, "stone_stairs", (new BlockStairs(stone.getState())).setDisplay("Steintreppe"));
		
		registerBlock(610, "cobblestone_slab",
				(new BlockSlab(Material.rock, "cobblestone"))
				.setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Bruchsteinstufe"));
		registerBlock(611, "cobblestone_stairs", (new BlockStairs(cobblestone.getState())).setDisplay("Bruchsteintreppe"));
		registerBlock(612, "cobblestone_wall", (new BlockWall(cobblestone)).setDisplay("Bruchsteinmauer"));
		
		registerBlock(620, "sandstone_slab",
				(new BlockSlab(Material.rock, "sandstone_normal", "sandstone_bottom", "sandstone_all"))
				.setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Sandsteinstufe"));
		registerBlock(621, "sandstone_stairs",
				(new BlockStairs(sandstone.getState().withProperty(BlockSandStone.TYPE, BlockSandStone.EnumType.DEFAULT),
						"sandstone_bottom", "sandstone_all")) // fix type
						.setDisplay("Sandsteintreppe"));
		
		Block quartz = (new BlockQuartz("")).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Quarzblock");
		registerBlock(630, "quartz_block", quartz);
		registerBlock(631, "quartz_slab",
				(new BlockSlab(Material.rock, "quartz_block_side", "quartz_block_bottom", "quartz_top"))
				.setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Quarzstufe"));
		registerBlock(632, "quartz_stairs",
				(new BlockStairs(quartz.getState().withProperty(BlockQuartz.VARIANT, BlockQuartz.EnumType.DEFAULT),
						"quartz_block_bottom", "quartz_top"))
						.setDisplay("Quarztreppe"));
		
		registerBlock(640, "iron_bars", (new BlockPane(Material.iron, true)).setHardness(5.0F).setResistance(10.0F).setStepSound(SoundType.STONE)
				.setDisplay("Eisengitter"));
		registerBlock(641, "iron_door",
				(new BlockDoor(Material.iron)).setHardness(5.0F).setStepSound(SoundType.STONE).setDisplay("Eisentür"));
		registerBlock(642, "iron_trapdoor",
				(new BlockTrapDoor(Material.iron)).setHardness(5.0F).setStepSound(SoundType.STONE).setDisplay("Eisenfalltür"));

		Block brick = (new Block(Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE)
				.setDisplay("Ziegelsteine").setTab(CheatTab.tabBlocks);
		registerBlock(650, "brick_block", brick);
		registerBlock(651, "brick_slab",
				(new BlockSlab(Material.rock, "brick_block"))
				.setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Ziegelstufe"));
		registerBlock(652, "brick_stairs", (new BlockStairs(brick.getState())).setDisplay("Ziegeltreppe"));

		Block stonebrick = (new BlockStoneBrick()).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE)
				.setDisplay("Steinziegel");
		registerBlock(660, "stonebrick", stonebrick);
		registerBlock(661, "stonebrick_slab",
				(new BlockSlab(Material.rock, "stonebrick_default"))
				.setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Steinziegelstufe"));
		registerBlock(662, "stonebrick_stairs",
				(new BlockStairs(stonebrick.getState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.DEFAULT)))
						.setDisplay("Steinziegeltreppe"));
		

		Block bloodBrick = (new Block(Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE)
				.setDisplay("Blutrote Ziegel").setTab(CheatTab.tabBlocks);
		registerBlock(670, "blood_brick", bloodBrick);
		registerBlock(671, "blood_brick_slab",
				(new BlockSlab(Material.rock, "blood_brick"))
				.setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Blutrote Ziegelstufe"));
		registerBlock(672, "blood_brick_fence", (new BlockFence(Material.rock, "blood_brick")).setHardness(2.0F).setResistance(10.0F)
				.setStepSound(SoundType.STONE).setDisplay("Blutroter Ziegelzaun"));
		registerBlock(673, "blood_brick_stairs", (new BlockStairs(bloodBrick.getState())).setDisplay("Blutrote Ziegeltreppe"));

		
		Block blackBrick = (new Block(Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE)
				.setDisplay("Schwarze Ziegel").setTab(CheatTab.tabBlocks);
		registerBlock(680, "black_brick", blackBrick);
		registerBlock(681, "black_brick_slab",
				(new BlockSlab(Material.rock, "black_brick"))
				.setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Schwarze Ziegelstufe"));
		registerBlock(682, "black_brick_stairs", (new BlockStairs(blackBrick.getState())).setDisplay("Schwarze Ziegeltreppe"));
		registerBlock(683, "black_brick_fence", (new BlockFence(Material.rock, "black_brick")).setHardness(2.0F).setResistance(10.0F)
				.setStepSound(SoundType.STONE).setDisplay("Schwarzer Ziegelzaun"));
		
		Block bquartz = (new BlockQuartz("black_")).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Schwarzer Quarzblock");
		registerBlock(690, "black_quartz_block", bquartz);
		registerBlock(691, "black_quartz_slab",
				(new BlockSlab(Material.rock, "black_quartz_block_side", "black_quartz_block_bottom", "black_quartz_top"))
				.setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Schwarze Quarzstufe"));
		registerBlock(692, "black_quartz_stairs",
				(new BlockStairs(bquartz.getState().withProperty(BlockQuartz.VARIANT, BlockQuartz.EnumType.DEFAULT),
						"black_quartz_block_bottom", "black_quartz_top"))
						.setDisplay("Schwarze Quarztreppe"));

		bid = 700;
		for(DecoType deco : DecoType.values()) {
			registerBlock(bid++, deco.name, (new Block(Material.rock)).setHardness(2.0F).setResistance(10.0F)
					.setStepSound(SoundType.STONE).setDisplay(deco.display).setTab(CheatTab.tabBlocks));
		}
		


		
		registerBlock(1000, "trapdoor",
				(new BlockTrapDoor(Material.wood)).setHardness(3.0F).setStepSound(SoundType.WOOD).setDisplay("Holzfalltür"));
        bid = 1100;
		for(WoodType wood : WoodType.values()) {
			Block planks = (new Block(Material.wood)).setHardness(2.0F).setResistance(5.0F).setStepSound(SoundType.WOOD)
					.setDisplay(wood.getDisplay() + "holzbretter").setTab(CheatTab.tabWood);
			registerBlock(bid++, wood.getName() + "_planks", planks);
			registerBlock(bid++, wood.getName() + "_stairs", (new BlockStairs(planks.getState()))
					.setDisplay(wood.getDisplay() + "holztreppe"));
			registerBlock(bid++, wood.getName() + "_slab", (new BlockSlab(Material.wood, wood.getName() + "_planks"))
					.setHardness(2.0F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzstufe"));
			registerBlock(bid++, wood.getName() + "_fence", (new BlockFence(Material.wood, wood.getName() + "_planks"))
					.setHardness(2.0F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzzaun"));
			registerBlock(bid++, wood.getName() + "_fence_gate", (new BlockFenceGate(wood)).setHardness(2.0F).setResistance(5.0F)
					.setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzzauntor"));
			registerBlock(bid++, wood.getName() + "_door", (new BlockDoor(Material.wood)).setHardness(3.0F).setStepSound(SoundType.WOOD)
					.setDisplay(wood.getDisplay() + "holztür"));
		}
		
		
		registerBlock(2000, "core", new BlockCore().setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE)
				.setDisplay("Chunk-Lade-Kern"));
		registerBlock(2001, "mob_spawner",
				(new BlockMobSpawner()).setHardness(5.0F).setStepSound(SoundType.STONE).setDisplay("Monsterspawner"));
		registerBlock(2002, "crafting_table", (new BlockWorkbench()).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Werkbank"));
		registerBlock(2003, "furnace", (new BlockFurnace(false)).setHardness(3.5F).setStepSound(SoundType.STONE).setDisplay("Ofen")
				.setTab(CheatTab.tabTech));
		registerBlock(2004, "lit_furnace", (new BlockFurnace(true)).setHardness(3.5F).setStepSound(SoundType.STONE).setLightLevel(0.875F)
				.setDisplay("Ofen (Gefeuert)").setTab(CheatTab.tabTech));
		registerBlock(2005, "anvil",
				(new BlockAnvil()).setHardness(5.0F).setStepSound(SoundType.ANVIL).setResistance(2000.0F).setDisplay("Amboss"));
		registerBlock(2006, "enchanting_table",
				(new BlockEnchantmentTable()).setHardness(5.0F).setResistance(2000.0F).setDisplay("Zaubertisch"));
		registerBlock(2007, "brewing_stand", (new BlockBrewingStand()).setHardness(0.5F).setLightLevel(0.125F).setDisplay("Braustand"));
		registerBlock(2008, "cauldron", (new BlockCauldron()).setHardness(2.0F).setDisplay("Kessel"));
		registerBlock(2009, "beacon", (new BlockBeacon()).setDisplay("Leuchtfeuer").setLightLevel(1.0F));
		registerBlock(2010, "noteblock", (new BlockNote()).setHardness(0.8F).setDisplay("Notenblock"));
		registerBlock(2011, "jukebox",
				(new BlockJukebox()).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Plattenspieler"));
		
		registerBlock(2100, "chest", (new BlockChest(0)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Truhe"));
		registerBlock(2101, "trapped_chest", (new BlockChest(1)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Redstonetruhe"));
		registerBlock(2102, "warp_chest", (new BlockWarpChest()).setHardness(22.5F).setResistance(1000.0F).setStepSound(SoundType.STONE)
				.setDisplay("Warptruhe").setLightLevel(0.5F));
		
		registerBlock(2200, "tnt", (new BlockTNT()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("TNT"));
		registerBlock(2201, "nuke", (new BlockNuke()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("T-17"));

		registerBlock(2300, "piston", (new BlockPistonBase(false)).setDisplay("Kolben"));
		registerBlock(2301, "sticky_piston", (new BlockPistonBase(true)).setDisplay("Klebriger Kolben"));
		registerBlock(2302, "piston_head", (new BlockPistonHead()).setDisplay("Kolben"));
		registerBlock(2303, "piston_extension", new BlockPistonMoving().setDisplay("Kolben"));
		registerBlock(2304, "dispenser", (new BlockDispenser()).setHardness(3.5F).setStepSound(SoundType.STONE).setDisplay("Werfer"));
		registerBlock(2305, "dropper", (new BlockDropper()).setHardness(3.5F).setStepSound(SoundType.STONE).setDisplay("Spender"));
		registerBlock(2306, "hopper",
				(new BlockHopper()).setHardness(3.0F).setResistance(8.0F).setStepSound(SoundType.STONE).setDisplay("Trichter"));
		registerBlock(2307, "tian_reactor",
				(new BlockTianReactor()).setHardness(3.0F).setResistance(8.0F).setStepSound(SoundType.STONE).setDisplay("Tianreaktor"));
		
		registerBlock(2400, "rail", (new BlockRail()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Schiene").setMiningLevel(0));
		registerBlock(2401, "golden_rail",
				(new BlockRailPowered()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Antriebsschiene").setMiningLevel(0));
		registerBlock(2402, "detector_rail",
				(new BlockRailDetector()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Sensorschiene").setMiningLevel(0));
		registerBlock(2403, "activator_rail",
				(new BlockRailPowered()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Aktivierungsschiene").setMiningLevel(0));
		
		registerBlock(2500, "lever", (new BlockLever()).setHardness(0.5F).setStepSound(SoundType.WOOD).setDisplay("Hebel"));
		
		registerBlock(2510, "stone_pressure_plate", (new BlockPressurePlate(Material.rock, BlockPressurePlate.Sensitivity.MOBS)).setHardness(0.5F)
				.setStepSound(SoundType.STONE).setDisplay("Steindruckplatte"));
		registerBlock(2511, "wooden_pressure_plate", (new BlockPressurePlate(Material.wood, BlockPressurePlate.Sensitivity.EVERYTHING))
				.setHardness(0.5F).setStepSound(SoundType.WOOD).setDisplay("Holzdruckplatte"));
		registerBlock(2512, "light_weighted_pressure_plate", (new BlockPressurePlateWeighted(Material.iron, 15)).setHardness(0.5F)
				.setStepSound(SoundType.WOOD).setDisplay("Wägeplatte (niedrige Gewichte)"));
		registerBlock(2513, "heavy_weighted_pressure_plate", (new BlockPressurePlateWeighted(Material.iron, 150)).setHardness(0.5F)
				.setStepSound(SoundType.WOOD).setDisplay("Wägeplatte (hohe Gewichte)"));
		
		registerBlock(2520, "stone_button", (new BlockButton(false, 20, "stone")).setHardness(0.5F).setStepSound(SoundType.STONE).setDisplay("Knopf"));
		registerBlock(2521, "wooden_button", (new BlockButton(true, 30, "oak_planks")).setHardness(0.5F).setStepSound(SoundType.WOOD).setDisplay("Knopf"));
		registerBlock(2522, "red_button", (new BlockButton(true, 10, "red_button")).setHardness(0.5F).setStepSound(SoundType.STONE).setDisplay("Knopf"));

		registerBlock(2600, "redstone",
				(new BlockRedstoneWire()).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Redstone-Staub"));
		registerBlock(2601, "unlit_redstone_torch",
				(new BlockRedstoneTorch(false)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Fackel"));
		registerBlock(2602, "redstone_torch", (new BlockRedstoneTorch(true)).setHardness(0.0F).setLightLevel(0.5F).setStepSound(SoundType.WOOD)
				.setDisplay("Redstone-Fackel").setTab(CheatTab.tabTech));
		registerBlock(2603, "repeater",
				(new BlockRedstoneRepeater(false)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Verstärker"));
		registerBlock(2604, "powered_repeater",
				(new BlockRedstoneRepeater(true)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Verstärker"));
		registerBlock(2605, "comparator",
				(new BlockRedstoneComparator(false)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Komparator"));
		registerBlock(2606, "powered_comparator", (new BlockRedstoneComparator(true)).setHardness(0.0F).setLightLevel(0.625F)
				.setStepSound(SoundType.WOOD).setDisplay("Redstone-Komparator"));
		registerBlock(2607, "redstone_lamp", (new BlockRedstoneLight(false)).setHardness(0.3F).setStepSound(SoundType.GLASS)
				.setDisplay("Redstone-Lampe").setTab(CheatTab.tabTech));
		registerBlock(2608, "lit_redstone_lamp",
				(new BlockRedstoneLight(true)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Redstone-Lampe"));
		registerBlock(2609, "daylight_detector", new BlockDaylightDetector(false).setDisplay("Tageslichtsensor"));
		registerBlock(2610, "daylight_detector_inverted", new BlockDaylightDetector(true).setDisplay("Tageslichtsensor"));
		registerBlock(2611, "tripwire_hook", (new BlockTripWireHook()).setDisplay("Haken"));
		registerBlock(2612, "string", (new BlockTripWire()).setDisplay("Stolperdraht").setShearsEfficiency(0));
	}
}
