====== Item Groups (1.19) ====== So far, you have used ''/give @s tutorial:custom_item'' to obtain your item. To make obtaining your item easier, you can add it to item groups within the creative inventory. You can also add your own item group. All items added to any group will also be searchable within the creative inventory. ==== Adding to Item Groups ==== First, choose the item group that the item should be added to. For this example, that item group will be the building blocks group. The vanilla item groups are stored in the '''' class. Next, you can simply use ''group'' method in ''FabricItemSettings'' with Fabric API. This will locate your custom item on last of item group. But if you want to put your custom item in other location(eg. after of '''') or other advanced modification, you can register the event handler for each item group that you would like to modify in your ''onInitialize'' method. Each item group that you would like to modify requires its own event handler, but the same event handler can be used to add multiple items to one item group. Items can be positioned relative to the existing vanilla items. Think carefully about where your mod's users would expect the item to be. For example, if you are adding a new type of wood, placing your item after the existing types of wood would make the most sense. For example, this event handler will place your mod's item after the oak door in the building blocks item group: ItemGroupEvents.modifyEntriesEvent(class_7706.field_40195).register(content -> { content.addAfter(class_1802.field_8691, CUSTOM_ITEM); }); ==== Creating an Item Group ==== Before you create an item group, determine whether it would have enough content to warrant its own group. Your item group will be placed on a separate page of tabs, impacting its discoverability, and users may be confused if the item is not where similar items are in the creative inventory. If you think that your own item group is needed, you can use the ''FabricItemGroup.builder'' method to create a builder for an item group. Make sure to call the ''build'' method as well: private static final class_1761 ITEM_GROUP = FabricItemGroup.builder(new class_2960("tutorial", "test_group")) .icon(() -> new class_1799(CUSTOM_ITEM)) .build(); You can use ''ITEM_GROUP'' to modify entries just like a vanilla item group. Note that you must add the items in order since there are no vanilla items to position them relative to: ItemGroupEvents.modifyEntriesEvent(ITEM_GROUP).register(content -> { content.add(CUSTOM_ITEM); }); {{:tutorial:item_group_append_items.png?nolink&400|}}