Creative Mode Tab

Creative Mode is one of the main game modes in Minecraft. It takes away the survival aspects of the game and leaves the player to easily create and destroy blocks, allowing them to create almost anything they want. Entities are spawned in through a menu, with tabs to organize items and blocks. In this tutorial, I'm going to show you how to make a Creative Mode tab for your mod, and how to put your entities into it.

Overview
To make a Creative tab, we are going to:
 * 1) Create a class to handle the tab
 * 2) Give the tab a name, icon, and background
 * 3) Put items and blocks into the tab

Creating the Tab Class
Go to your com.name.mod package and create a new class in it called ModTab or whatever name you want. Make sure the class extends CreativeTabs and import it. Add the mandatory constructor and methods so your class looks something like this: public class ModTab extends CreativeTabs { public ModTab(String label) { super(label); } @Override public Item getTabIconItem { return null; } } The getTabIconItem method is where we will define the image for the tab itself, and the constructor is where we can specify the background image for the entire menu. To define a background image for the entire creative menu, put this line in the constructor underneath the 'super(label);' line: this.setBackgroundImageName("your image name here"); You can replace the bold with the file name of your background, something like "background.png". To set the item to be displayed in the tab of the menu, replace 'null' with this line in the getTabIconItem method: ModItems. ; So here is my class after the changes were made: public class ModTab extends CreativeTabs { public ModTab(String label) { super(label); this.setBackgroundImageName("background.png"); } @Override public Item getTabIconItem { return ModItems.test_item; } } We are now going to create a new package to put our image in, while referencing the vanilla Minecraft inventory screen, so go to your src/main/resources package and create a new package there called assets.minecraft.textures..gui.container.creative_inventory.

Now you will need to make a texture for your entire menu (not including the tab), and drag/drop it into the package we just created. You could use the regular gui, or you could make your own, it's up to you. Whenever you have the image in the package, rename it tab_mod.png, however you can change the 'mod' part to whatever you want, just make sure it has the 'tab_' part before it. This may seem wrong since the string parameter in the constructor says different, but it's necessary for the game to process it.

Adding Entities to Your Tab
Now in the ModClass, create an object of the class we just created somewhere near the top. public static final ModTab tabMod = new ModTab("tabMod"); Go to the ModItems class and right after the initialization statement in the init method, add the folllowing line of code: test_item = new Item.setUnlocalizedName("test_item").setCreativeTab(ModClass.tabMod); Now copy the bit in bold and just go to the ModBlocks class and paste it in the same spot: test_block = new BlockTest(Material.cloth).setUnlocalizedName("test_block").setCreativeTab(ModClass.tabMod); Now if you run that, open the creative menu, and scroll to the side, you should see that it has applied the background and add the items and blocks to the menu.

Making the Language File
A language file is what allows you to change the names of blocks and items in the game itself. You may remember we gave names to variables in the code, but those were to be used solely for the code and as reference. To be able to change the names of the entities in-game you need to create your own language file.

Go to the assets.tm package inside the src/main/resources package and create a new sub-package called lang right next to the blockstates package. Inside the new package, create a new file called en_US.lang file. Be sure to redefine the .lang extension so you can open it like a text file and change the names of your items, blocks, and tabs according to this layout: tile. .name = " " item. .name = " " itemGroup.tabMod = Save the file and if you start the game, it should show the fixed names that you put in instead of the UnlocalizedNames.

And there you have it! You now have a place where you can store your entities and grab them without having to use commands. Happy modding!