Advanced Modding - Creative Tabs

Goal

I want to show you how to create a custom creative tab.

Difficulty


1/10 - Pretty Simple

Prerequisites

Forge Version

This Tutorial was created with Forge 11.14.3.1450 for Minecraft 1.8. If anything doesn't work with other versions, please contact me!


Creating a custom CreativeTab

Creating a custom creative tab is really easy.

You just need to create a new object, override one method and there you go!

But lets start from the beginning.


You should put your creative tab objects either into your item class or into a special class that you have created for that purpose.

To create a creative tab, all you need to do is instantiating CreativeTabs:

ModItems.java:
public static final CreativeTabs tabMyMod = new CreativeTabs("myMod");

Once you do this, eclipse will yell at you saying "Cannot instantiate type CreativeTabs".

That's because CreativeTabs is abstract; we need to override one method: getTabIconItem():

ModItems.java:
public static final CreativeTabs tabMyMod = new CreativeTabs("myMod") {
    @Override public Item getTabIconItem() {
        return Items.diamond;
    }
};

Here you can return whatever Item should be dispalyed on the button for your creative tab.

If the Item should be displayed with a different metadata than zero, you need to override getIconItemDamage():

ModItems.java:
public static final CreativeTabs tabMyMod = new CreativeTabs("myMod") {
    @Override public Item getTabIconItem() {
        return Items.dye;
    }
    @Override public int getItemIconDamage() {
        return 4;
    }
};

This tab here will be displayed with Lapis Lazuli as the icon.


The last thing to do is to add the title translation to your language file:

Language file:
itemGroup.myMod=My Mod's Creative Tab!

You can now add items to your tab using item.setCreativeTab(ModItems.tabMyMod);


Recommended tutorials to continue with

Take a look at the tutorial overview and decide what you want to do next.


Comments and Questions:

If you want to report modding problems, please make sure to include the code in a pastebin link or something else! Don't just write "It doesn't work", otherwise your post will be deleted. For more complicated problems, please use the troubleshooter form.