So, I am trying to get an ItemBlock to register alongside my Block when it gets registered. I have come up with this so far. Is there a better way to be doing this? If so, please show me some example code! I'm not really happy with the itemBlock.setRegistryName part inside registerBlock() !
public class ModBlocks {
public static Block tinBlock;
public static void init(){
tinBlock = new BlockTinBlock("tin_block", "tin_block");
}
public static void register(){
registerBlock(tinBlock);
}
public static void registerRenders(){
registerRender(tinBlock);
}
public static void registerBlock(Block block){
GameRegistry.register(block);
ItemBlock itemBlock = new ItemBlock(block);
itemBlock.setRegistryName(Reference.MODID, block.getUnlocalizedName().substring(5));
GameRegistry.register(itemBlock);
}
public static void registerRender(Block block){
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(new ResourceLocation(Reference.MODID, block.getUnlocalizedName().substring(5)), "inventory"));
}
}
Solution by Ugdhar: [Register Items and Blocks like in the post below! Super neat and up to date!]