[Java] Let's create a mod for Minecraft 1.14.4 [3. Add creative tab]

(This article is one of a series of commentary articles)

First article: Introduction Previous article: 2. Add Blocks Next article: 4. Add Tools

Add creative tab

I've added items and blocks so far, but it seems a bit strange to see them in the same tab as the vanilla [^ 1] items in the creative. Besides, it's nice to have additional items organized in their own tabs. Here we will add a creative tab for our mod.

\src\main\java\jp\koteko\example_mod\
   ├ ExampleItemGroup.java
   ├ ExampleMod.java
   └ lists

ExampleItemGroup.java


package jp.koteko.example_mod;

import jp.koteko.example_mod.lists.ItemList;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class ExampleItemGroup extends ItemGroup {
    public static final ExampleItemGroup DEFAULT = new ExampleItemGroup();

    public ExampleItemGroup() {
        super("example_mod");
    }

    @Override
    @OnlyIn(Dist.CLIENT)
    public ItemStack createIcon() {
        return new ItemStack(ItemList.ExampleIngot);
    }
}

Define your own class that inherits from ʻItemGroup. Set the tab icon with createIcon(this method is required). Note that the" example_mod "` specified here is not the ModID, but the internal ID of this ItemGroup.

Modify existing additional item settings to use this tab.

ItemList.java


// ...
import jp.koteko.example_mod.ExampleItemGroup; //add to
//import net.minecraft.item.ItemGroup; //Delete
// ...
@Mod.EventBusSubscriber(modid = ExampleMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ItemList {
    //Change the argument of group
    public static Item ExampleIngot = new Item(new Item.Properties().group(ExampleItemGroup.DEFAULT))
            .setRegistryName(new ResourceLocation(ExampleMod.MOD_ID, "example_ingot"));
    // ...
}

BlockList.java


// ...
import jp.koteko.example_mod.ExampleItemGroup; //add to
//import net.minecraft.item.ItemGroup; //Delete
// ...
@Mod.EventBusSubscriber(modid = ExampleMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class BlockList {
    // ...
    //Change the argument of group
    @SubscribeEvent
    public static void registerBlockItems(RegistryEvent.Register<Item> event) {
        event.getRegistry().registerAll(
                new BlockItem(ExampleBlock, new Item.Properties().group(ExampleItemGroup.DEFAULT))
                        .setRegistryName(new ResourceLocation(ExampleMod.MOD_ID, "example_block"))
        );
    }
}

Next, since the display name is not set as it is, add it to the lang file.

en_us.json


{
  "itemGroup.example_mod": "Example Mod",
  "item.example_mod.example_ingot": "Example Ingot",
  "block.example_mod.example_block": "Example Block"
}

ja_jp.json


{
  "itemGroup.example_mod": "Example Mod",
  "item.example_mod.example_ingot": "Example ingot",
  "block.example_mod.example_block": "Example block"
}

Start the game. キャプチャ.PNG ** You have added a new tab just for your mod. ** **

reference

Creating Minecraft 1.14.4 Forge Mod Part 5 [Adding Creative Tab]

Next article

4. Add tools

[^ 1]: A plain Minecraft without mods

Recommended Posts

[Java] Let's create a mod for Minecraft 1.14.4 [3. Add creative tab]
[Java] Let's create a mod for Minecraft 1.14.4 [4. Add tools]
[Java] Let's create a mod for Minecraft 1.14.4 [5. Add armor]
[Java] Let's create a mod for Minecraft 1.14.4 [7. Add progress]
[Java] Let's create a mod for Minecraft 1.14.4 [6. Add recipe]
[Java] Let's create a mod for Minecraft 1.16.1 [Add item]
[Java] Let's create a mod for Minecraft 1.14.4 [1. Add items]
[Java] Let's create a mod for Minecraft 1.14.4 [2. Add block]
[Java] Let's create a mod for Minecraft 1.16.1 [Add block]
[Java] Let's create a mod for Minecraft 1.14.4 [Introduction]
[Java] Let's create a mod for Minecraft 1.16.1 [Introduction]
[Java] Let's create a mod for Minecraft 1.14.4 [99. Mod output]
[Java] Let's create a mod for Minecraft 1.16.1 [Add and generate trees]
[Java] Let's create a mod for Minecraft 1.14.4 [9. Add and generate trees]
[Java] Let's create a mod for Minecraft 1.14.4 [8. Add and generate ore]
[Java] Let's create a mod for Minecraft 1.14.4 [0. Basic file]
[Java] Let's create a mod for Minecraft 1.14.4 [Extra edition]
[Java] Let's create a mod for Minecraft 1.16.1 [Basic file]
Let's create a Java development environment (updating)
Let's create a timed process with Java Timer! !!
Let's create a custom tab view in SwiftUI 2.0
Let's create a super-simple web framework in Java
Create an extension for Burp. ~ Simply add tab ~
[Java] Create a filter
[Java basics] Let's make a triangle with a for statement
How to create a lightweight container image for Java apps
[Java twig] Create a parser combinator for recursive descent parsing 2
Create a java method [Memo] [java11]
[Java] Create a temporary file
Create a MOB using the Minecraft Java Mythicmobs plugin | Preparation 1
Let's create a TODO application in Java 4 Implementation of posting function
Let's create a TODO application in Java 6 Implementation of search function
Let's create a TODO application in Java 8 Implementation of editing function
Let's create a TODO application in Java 1 Brief explanation of MVC
Let's create a TODO application in Java 5 Switch the display of TODO
How to sign a Minecraft MOD
Create a Java project using Eclipse
[Java] How to create a folder
Create a fluentd server for testing
[Java twig] Create a parser combinator for recursive descent parsing (also memoize)
Let's go with Watson Assistant (formerly Conversation) ⑤ Create a chatbot with Watson + Java + Slack
Create a java web application development environment with docker for mac part2
[Java] Create and apply a slide master
How to create a Maven repository for 2020
Create a TODO app in Java 7 Create Header
[Rails] Let's create a super simple Rails API
[Java] Let's make a DB access library!
Let's make a calculator application with Java ~ Create a display area in the window
Let's create a versatile file storage (?) Operation library by abstracting file storage / acquisition in Java
[Azure] I tried to create a Java application for free-Web App creation- [Beginner]