CUSTOM CREATIVE TAB inside of Minecraft with Forge
MAPPINGS for this Tutorial: mappings channel: 'snapshot', version: '20210309-1.16.5'

A new creative tab is very easy to add into our Mod. To do this, we simply need to make one more class and one little change.

The new class is going to be called ModItemGroup and will hold static ItemGroup variables that will be our custom creative tabs. ItemGroup is the technical term for creative tab and will be used hereafter. I will simply paste in the class and explain:

public class ModItemGroup {

    public static final ItemGroup TUTORIAL_MOD = new ItemGroup("tutorialModTab") {
        @Override
        public ItemStack createIcon() {
            return new ItemStack(ModItems.AMETHYST.get());
        }
    };
}

This is the entire class with one ItemGroup currently created, namely TUTORIAL_MOD. You need to supply the constructor with a label. This is important later to set the name when we hover over the tab inside our inventory.

For people with intermediate to advanced Java knowledge, you will recognize this as an anonymous class. Reason why we have to do this is because the ItemGroup class is actually abstract. We only need to override the createIcon method as this specifies the Item shown on the tab. In this case I create a new ItemStack of my amethyst Item we created in the last post.

No we also want our Item to show up in there, so instead of calling .group(ItemGroup.MATERIALS) when we create our Item, we will call .group(ModItemGroup.TUTORIAL_MOD) instead. So our Item declaration now looks like this:

    public static final RegistryObject<Item> AMETHYST = ITEMS.register("amethyst",
            () -> new Item(new Item.Properties().group(ModItemGroup.TUTORIAL_MOD)));

We will also navigate to our en_us.json file and add a translation value to our text:

  "itemGroup.tutorialModTab": "Tutorial Mod"

This is what needs to be added. And now off we go to check whether or not it worked.

The working ItemGroup (Creative Tab)

So there you go, that’s already all you need to do for you to create a new Creative Tab. I hope this article was useful to you. Also take a look at the video version of this article.

Was this helpful?

29 / 5

Leave a Reply 0

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