Jump to content

Not Understanding How to Register Items


Recommended Posts

I am brand new to modding and I am having trouble understanding the Registry Events to add some items and blocks. I have crated my registerItems method and I am not sure what or how to call it during game Initialization.


Initialization Class:

@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, acceptedMinecraftVersions = "1.12")
public class ExampleMod {
	public static ExampleMod instance;
	@SidedProxy(clientSide = Reference.CLIENT_PROXY, serverSide = Reference.SERVER_PROXY)
	public static CommonProxy proxy;
	public void preInit(FMLPreInitializationEvent event) {
		System.err.println("PreINIT started");
		//Register Items
		//REgister Tile Entities
		//Register Entities
		//Assign Ore dictionary
	public void init(FMLInitializationEvent event) {
		System.err.println("INIT started");
		//Register World Gens
		//Register recipes
		//Register EventHandlers
		//Sending IMC Messages
	public void postInit(FMLPostInitializationEvent event) {
		System.err.println("PostINIT started");
		//Mod Compatibility


RegistryEventHandler class:

@Mod.EventBusSubscriber(modid = Reference.MODID)
public class RegistryEventHandler {
	public void registerItems(RegistryEvent.Register<Item> event) {
		for(Block block : ModBlocks.BLOCKS) {
			event.getRegistry().register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
		System.err.print("Registered Items");
	public static void registerModels(ModelRegistryEvent event)
		for (Block block: ModBlocks.BLOCKS)
			ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
		for (Item item: ModItems.ITEMS)
			ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));


My Mod Items class has the Item array for registration. Please help me understand how these work! Thanks in advance!

Link to comment
Share on other sites

5 minutes ago, CoderAtParadise said:

Your register items isn't static.

also this will crash on a dedicated server as ModelRegistryEvent is only on the client

Does ModelRegistryEvent get called on the server?  I would think it would never fire on the server so this code would be safe.

Link to comment
Share on other sites

You can have ModelRegistryEvent handlers on the server side, because the ModelRegistryEvent class does exist on the server but won't be fired there and nothing else in the method signature uses client only classes, however, it's best practice to keep your client-side code entirely separated from common code so it's harder to accidentally introduce client sided-ness bugs.

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.