Creating Our Own Creative Tab - shauncjones/Community-Mod GitHub Wiki
Note: This tutorial is created on windows and commands may vary on other systems.
In this tutorial we are going ton be creating a custom creative tab to house all of our items and blocks.
Getting Started
First we are going to be creating a new class in our com.shauncjones.communitymod.util
package. This new class should be named CommunityModTab
we are going to populate our class with the following:
package com.shauncjones.communitymod.util;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import com.shauncjones.communitymod.items.CommunityModItems;
public class CommunityModTab extends CreativeTabs{
public CommunityModTab(){
super(Reference.MODID);
}
@Override
public ItemStack getTabIconItem(){
return new ItemStack(CommunityModItems.ingotCopper);
}
}
Now let's break it down.
The string passed in our constructor is to give the tab a localized name. For this we used our MODID.
getTabIconItem
tells Minecraft which item to show on our creative tab in game. For this we used our Copper Ingot that we created.
Now inside of our CommunityMod
class we are going to add the following line after the @SidedProxy
public static final CommunityModTab CMTab = new CommunityModTab();
Updating our created Items
Now that we have created our creative tab we need to update our items to actually go in there. Inside of our BlockBase
& ItemBase
classes in the constructor we are going to add setCreativeTab(CommunityMod.CMTab);
Then inside of our CommunityModItems
& CommunityModBlocks
we just need to remove the .setCreativeTab(CreativeTabs.MISC)
from the created items.
Adding Localization
The final step will be to make sure our creative tab has a name, so inside of our en_US.lang
file we will need to add another line like the following: itemGroup.communitytab=Community Tab
. You will notice this one does not need the .name
attribute, in fact if you use it the game will not load your name.
Going Forward
You now have a mod that adds a simple item and block, and puts them into our own creative tab. You can find the next tutorials here.