package common.init;

import java.util.Map;

import common.collect.Maps;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityBanner;
import common.tileentity.TileEntityBeacon;
import common.tileentity.TileEntityBrewingStand;
import common.tileentity.TileEntityChest;
import common.tileentity.TileEntityComparator;
import common.tileentity.TileEntityDaylightDetector;
import common.tileentity.TileEntityDispenser;
import common.tileentity.TileEntityDropper;
import common.tileentity.TileEntityEnchantmentTable;
import common.tileentity.TileEntityFurnace;
import common.tileentity.TileEntityHopper;
import common.tileentity.TileEntityMobSpawner;
import common.tileentity.TileEntityNote;
import common.tileentity.TileEntityPiston;
import common.tileentity.TileEntitySign;
import common.tileentity.TileEntitySkull;
import common.tileentity.TileEntityTianReactor;

public abstract class TileRegistry {
	public static final Map<String, Class<? extends TileEntity>> nameToClassMap = Maps.<String, Class<? extends TileEntity>>newHashMap();
	public static final Map<Class<? extends TileEntity>, String> classToNameMap = Maps.<Class<? extends TileEntity>, String>newHashMap();
	public static final Map<Class<? extends TileEntity>, Integer> classToIdMap = Maps.<Class<? extends TileEntity>, Integer>newHashMap();
	private static int nextId;

	private static void addMapping(Class<? extends TileEntity> cl, String id) {
		if(nameToClassMap.containsKey(id))
			throw new IllegalArgumentException("Duplicate id: " + id);
		nameToClassMap.put(id, cl);
		classToNameMap.put(cl, id);
		classToIdMap.put(cl, ++nextId);
	}

	static void register() {
		addMapping(TileEntityFurnace.class, "Furnace");
		addMapping(TileEntityChest.class, "Chest");
//		addMapping(TileEntityWarpChest.class, "WarpChest");
//		addMapping(BlockJukebox.TileEntityJukebox.class, "RecordPlayer");
		addMapping(TileEntityDispenser.class, "Trap");
		addMapping(TileEntityDropper.class, "Dropper");
		addMapping(TileEntitySign.class, "Sign");
		addMapping(TileEntityMobSpawner.class, "MobSpawner");
		addMapping(TileEntityNote.class, "Music");
		addMapping(TileEntityPiston.class, "Piston");
		addMapping(TileEntityBrewingStand.class, "Cauldron");
		addMapping(TileEntityEnchantmentTable.class, "EnchantTable");
//		addMapping(TileEntityPortal.class, "Portal");
//		addMapping(TileEntityCommandBlock.class, "Control");
		addMapping(TileEntityBeacon.class, "Beacon");
		addMapping(TileEntitySkull.class, "Skull");
		addMapping(TileEntityDaylightDetector.class, "DLDetector");
		addMapping(TileEntityHopper.class, "Hopper");
		addMapping(TileEntityComparator.class, "Comparator");
//		addMapping(TileEntityFlowerPot.class, "FlowerPot");
		addMapping(TileEntityBanner.class, "Banner");
		addMapping(TileEntityTianReactor.class, "TianReactor");
	}
}
