Minecraft 1.12 modding with forge – 3 – custom item

Hello everyone,

Today we are going to make a custom item, I am going to show you how to register your items, register item models, and work with RegistryEvents.

First we are going to create some packages and files.

  1. Create a package in your mod package and call it items. This package will contain all of the custom item classes.
  2. Create another package inside the mod package and call it init. In this package we will put all of our item, block etc. initialization classes.
  3. Inside the items package create a class ItemBasic.
  4. Inside the init package create a class ModItems.

Your package structure should now look a little like this:

The ItemBasic class should extend Item (When importing make sure to import “net.minecraft.item.Item”). Now add a constructor with a String name. Inside of the constructor call the methods: “setUnlocalizedName and setRegistryName” and pass them the name variable. The setUnlocalizedName method will set the unlocalizedName of the item, this will add item. in front of the name (item.name). The setRegistryName will set the registryName of the item. This name is used internally and should never be changed after assigning the item.

This class will be the most basic item possible, it won’t have any special effects.

In the ModItems class we will be instantiating and registring our objects. In the ModItems class create a static variable of type Item, I will call it tutorial_item and a public static method called init. This method will be called in the preInit function of our Main class and initialize all of our items. It will return nothing and it doesn’t need any arguments.
In the init function initialize the tutorial_item variable. I will pass it the name tutorial_item.

Now we need to let forge know we have an item to register, this is done in the RegistryEvent. Add a public static method called registerItems it has to have an argument of type RegistryEvent.Register<Item>. Above the method add an annotation @SubscribeEvent and above the class declaration add an annotation @Mod.EventBusSubscriber and add an modid attribute.
In the registerItems method register your item by calling the register method like this:

In the Main class’ init method call the init method of the ModItems class.

This is technically enough for forge to load the item. When you start the game, and load a world you can give yourself the item with the command: “/give @p modid:itemname”. When you do this you will see that it doesn’t have a model and texture yet. So lets add those right now!

In the ModItems class we will use another event to register the model location of the item. This is done in the ModelRegistryEvent. Add a public static method called registerRenders with as argument ModelRegistryEvent. Don’t forget to add an @SubscribeEvent annotation above the method!

Add another method, this method is also static and takes an Item as argument, I will call it registerRender (without an “s”!). In this method add the following line:

ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation( item.getRegistryName(), "inventory")); 

This line will set the location of the item model.
In the registerRenders method call the registerRender method and pass it your custom item.
Your item will now have a location registered, we haven’t added a model and texture yet so forge will change it with a custom model telling you the location.

To add a model and texture create a new package in the src/main/resources folder called assets.modid and ofcourse replace modid with your modid. In this package we have to create some more packages. Create: models.item and textures.items (make sure you don’t have a “s” behind item after models).
In the textures.items package you can add a texture (make sure its size is a power of 2, 16×16, 32×32, etc.). It doesn’t matter what you call it but it has to be lowercase and you have to remember the name. I will call it tutorial_item.png and I will use this texture:
In the models.item package create a new text file. In the text file add the following json code:

Save it under the same name as your item but make sure it is all lowercase or it won’t work, also remember to save it as NAME.json. You have to replace the words in capslock with the corresponding values. The texture name shouldn’t contain the extension (.png).
You may have noticed that the name isn’t displaying correct. That is because we haven’t added a lang file yet, so lets do that. In the assets.modid package create a new package called lang, in this package create a new text file. In this text file add the following line:


And again, replace the words in caps with your own values. Save this file in the lang package and call it en_us.lang.
One last thing before we can launch the game and admire our new item, in the src/main/resources folder create a new textfile, give it the following contents and save it as pack.mcmeta:

This will make sure forge uses version 3 of the pack versions. (This is recommended for 1.12)

Now you can start the game and you should have an item with texture and name!

It would probably be smart to add it to a creative tab, in the ModItems class’ init method you can change some simple things about the item. Because of the way forge is made you can chain method calls after eachother. Call the method setCreativeTab on the item, I will put it in the miscellaneous creative tab. So I will pass the method CreativeTabs.MISC. Just to show you how to chain methods I make it stack to 32. I will do this by calling setMaxStackSize. This is the line I have now:

tutorialItem = new ItemBasic("tutorial_item").setCreativeTab(CreativeTabs.MISC).setMaxStackSize(32);

Well that was it for this part! In the next part we will add a custom block. By clicking here you will be send to the code of this part.
As always if you have any question don’t hesitate to ask in the comments! Also if you saw any errors in the tutorial please let me know so I can fix it!


Posted in Forge tutorial, Forge Tutorial 1.12.


    • registerItem is called by forge, we listen to the register event and forge fires that event. Forge finds the method using some java magic.

  1. Hi I’ve followed this tutorial in IntelliJ and for some reason Minecraft won’t load showing this error:
    Error:(16, 41) java: cannot find symbol
    symbol: variable ruby
    location: class com.elky.mingems.Items.ItemBasic
    I have changed every single tutorial_mod for ruby but it still shows this error, please help.


  2. It does not work! I’ve did what you did and it does not! The Modid “tm” doesn’t work, modid “graka” doesn’t work! What am i doing wrong!

    • Please post your code. And explain what doesn’t work. You should use whatever modid you use. I’d not recommend using tm

        • Oopsie! Nevermind! I missed some codes and i fixed it! BTW, what do i must do to add more item? There’s alot of codes that only respond to tutorialItem though.

          • Every item needs at least a model file. (They can use the same texture file tho if you want them to look the same). You also need to register a new item for each item type you want. But you can re use the class made here.

  3. I have created the item but I cant get the texture to show up. My code matches what is posted on GitHub.
    Any ideas?

    • Post your code on github, make sure your names are correct and that your file is in the right location. (Also some IDEs like intellij like to create folders with the name assets.modid.blablabla instead of a folder structure like assets/modid/blablabla, make sure your folder structure is correct).


    • Make sure you have the right names and they are in the right folder, if you want to you can join the discord (By clicking connect on the discord widget on the right), it is easier to help on the discord server and other people will also be available to help.

  4. Hey suppergerrie2,

    great tutorial so far 🙂

    I got stuck for a while on rendering the texture, because I didn’t save my tutorialitem file with an .json extension. So my request to you is if you can specify this more clearly in the text.

    Also there is a tiny typo in the sentence “One last thing before we can launch the game and admire our new item, in the src/main/resources folder create a new textile, give it the following contents and save it as pack.mcmeta:”

    Anyway, I’ll be making my first block now. Keep up the good work!

    • Thank you!
      I fixed the typo and added a line to tell you have to save it as NAME.json. I hope that helps!
      Good luck with making a block!


Leave a Reply

Your email address will not be published. Required fields are marked *