User Tools

Site Tools


tutorial:itemgroup

This is an old revision of the document!


Adding an item group

Do you want your blocks and items blocks to have their own group in the creative inventory? Then that can easly be fixed. The most common way to create one is to use FabricItemGroupBuilder.create. Like items and blocks this has to be done in onInitialize method to work correctly.

 @Override
 public void onInitialize() {
     ItemGroup itemGroup = FabricItemGroupBuilder.create("modid:name")})).icon(() -> new ItemStack  
     (block)).build();
 }

The modid is the id of your mod, name is the name of the creative tabs (must be lowercase to not crash). The icon is should be an itemstack, created with either an item or a block like in this case for example Blocks.Grass. To add blocks to your item group use .itemGroup(itemGroup) when creating it.

 public static final Item FABRIC_ITEM = new Item(new Item.Settings().itemGroup(itemGroup));

Creating an item group is as easy as that!

tutorial/itemgroup.1550587835.txt.gz · Last modified: 2019/02/19 14:50 by mcrafterzz