package net.mcft.copy.betterstorage.tile;

import net.mcft.copy.betterstorage.BetterStorage;
import net.mcft.copy.betterstorage.misc.Constants;
import net.mcft.copy.betterstorage.utils.MiscUtils;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import cpw.mods.fml.common.registry.GameRegistry;

public class TileBetterStorage extends Block {
	
	private String name;
	
	public TileBetterStorage(Material material) {
		
		super(material);
		
		setCreativeTab(BetterStorage.creativeTab);
		
		setBlockName(getTileName());
		registerBlock();
		
	}
	
	/** Returns the name of this tile, for example "craftingStation". */
	public String getTileName() {
		return ((name != null) ? name : (name = MiscUtils.getName(this)));
	}
	
	/** Returns the item class used for this block. <br>
	 *  Doesn't have to be an ItemBlock. */
	protected Class<? extends Item> getItemClass() { return ItemBlock.class; }
	
	/** Registers the block in the GameRegistry. */
	protected void registerBlock() {
		Class<? extends Item> itemClass = getItemClass();
		if (ItemBlock.class.isAssignableFrom(itemClass)) {
			GameRegistry.registerBlock(this, (Class<? extends ItemBlock>)itemClass, getTileName(), Constants.modId);
		} else {
			GameRegistry.registerBlock(this, ItemBlock.class, getTileName(), Constants.modId);
			Item.itemsList[blockID] = null;
			try { itemClass.getConstructor(int.class).newInstance(blockID); }
			catch (Exception e) { throw new RuntimeException(e); }
		}
	}
	
}

@@ -334,24 +334,70 @@
 .ItemBlock;%0A
+import cpw.mods.fml.common.registry.GameData;%0A
 import cpw.m
@@ -1340,24 +1340,38 @@
 %7D else %7B%0A%09%09%09
+Block block = 
 GameRegistry
@@ -1391,31 +1391,20 @@
 k(this, 
-ItemBlock.class
+null
 , getTil
@@ -1441,34 +1441,13 @@
 Item
-.
+ 
 item
-sList%5BblockID%5D = null
 ;%0A%09%09
@@ -1452,16 +1452,23 @@
 %09%09%09try %7B
+ item =
  itemCla
@@ -1512,15 +1512,8 @@
 nce(
-blockID
 ); %7D
@@ -1571,16 +1571,96 @@
 n(e); %7D%0A
+%09%09%09GameData.itemRegistry.add(Block.getIdFromBlock(block), getTileName(), item);%0A
 %09%09%7D%0A%09%7D%0A%09

Fix custom block/item registration