I created a class called ModBlocks for my blocks. There are two blocks, arock and brock.
As you can see I created a method called registerBlocks() to register my blocks and also their ItemBlocks. And finally, use the register() method to register all of them in my main class.
But the following exception occurs:
package Sixs.FirstMod.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class ModBlocks {
public static Block arock = new Block(Material.rock).setUnlocalizedName("arock").setRegistryName("arock");
public static Block brock = new Block(Material.rock).setUnlocalizedName("brock").setRegistryName("brock");
public static void init() {
}
public static void register() {
registerBlocks(arock,brock);
}
public static void registerBlocks(Block... blocks) {
for (Block block1 : blocks) {
GameRegistry.registerBlock(block1);
ItemBlock itemBlock = new ItemBlock(block1);
itemBlock.setRegistryName(block1.getRegistryName());
GameRegistry.registerItem(itemBlock);
}
}
}
It says that I use the name fm:arock to register ItemBlocks twice, but I don't know how. The ItemBlocks's registry names are the same from their corresponding blocks.
Help will be appreciated.