tutorial:itemgroup
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:itemgroup [2019/02/19 14:44] – mcrafterzz | tutorial:itemgroup [2023/10/01 03:21] (current) – Remove semicolon to nowhere haykam | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | 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 // | + | |
- | | + | //This is the 1.20+ version of this tutorial. For the 1.19 version, see [[tutorial:1.19: |
- | | + | |
- | | + | |
- | | + | |
- | } | + | |
- | The modid is the id of your mod, name is the name of the creative tabs (must be lowercase | + | So far, you have used ''/ |
- | | + | ==== Adding to Item Groups ==== |
- | Creating | + | 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 registry keys of vanilla item groups are stored in the ''< |
+ | |||
+ | Next, you will have to create | ||
+ | |||
+ | < | ||
+ | ItemGroupEvents.modifyEntriesEvent(class_7706.field_40195).register(content -> { | ||
+ | content.add(CUSTOM_ITEM); | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | The modification event also allows more fine-grained control such as placing your custom item in a specific location(eg. after of ''< | ||
+ | |||
+ | 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, | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | ==== 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, | ||
+ | |||
+ | If you think that your own item group is needed, you can use the '' | ||
+ | |||
+ | < | ||
+ | private static final class_1761 ITEM_GROUP = FabricItemGroup.builder() | ||
+ | .icon(() -> new class_1799(CUSTOM_ITEM)) | ||
+ | .displayName(class_2561.method_43469(" | ||
+ | .entries((context, | ||
+ | entries.add(CUSTOM_ITEM); | ||
+ | }) | ||
+ | .build(); | ||
+ | </ | ||
+ | |||
+ | You can add entries to your item group within the '' | ||
+ | |||
+ | It is important to set the display name, otherwise it will cause a crash. | ||
+ | |||
+ | The next step is to register your item group. | ||
+ | |||
+ | < | ||
+ | class_2378.method_10230(class_7923.field_44687, | ||
+ | </ | ||
+ | |||
+ | {{: |
tutorial/itemgroup.1550587446.txt.gz · Last modified: 2019/02/19 14:44 by mcrafterzz