tutorial:itemgroup
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:itemgroup [2022/12/11 22:06] – Update to 1.19.3 item group API haykam | tutorial:itemgroup [2023/10/01 03:21] (current) – Remove semicolon to nowhere haykam | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Item Groups ====== | ====== Item Groups ====== | ||
+ | |||
+ | //This is the 1.20+ version of this tutorial. For the 1.19 version, see [[tutorial: | ||
So far, you have used ''/ | So far, you have used ''/ | ||
Line 5: | Line 7: | ||
==== Adding to Item Groups ==== | ==== 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 ''< | + | 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, in your '' | + | Next, you will have to create an event handler for modifying item groups. |
+ | |||
+ | < | ||
+ | ItemGroupEvents.modifyEntriesEvent(class_7706.field_40195).register(content -> { | ||
+ | content.add(CUSTOM_ITEM); | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | The modification event also allows more fine-grained control such as placing | ||
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. | 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. | ||
Line 26: | Line 36: | ||
< | < | ||
- | private static final class_1761 ITEM_GROUP = FabricItemGroup.builder(new class_2960(" | + | private static final class_1761 ITEM_GROUP = FabricItemGroup.builder() |
.icon(() -> new class_1799(CUSTOM_ITEM)) | .icon(() -> new class_1799(CUSTOM_ITEM)) | ||
+ | .displayName(class_2561.method_43469(" | ||
+ | .entries((context, | ||
+ | entries.add(CUSTOM_ITEM); | ||
+ | }) | ||
.build(); | .build(); | ||
</ | </ | ||
- | You can use '' | + | 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. | ||
< | < | ||
- | ItemGroupEvents.modifyEntriesEvent(ITEM_GROUP).register(content -> { | + | class_2378.method_10230(class_7923.field_44687, |
- | content.add(CUSTOM_ITEM); | + | |
- | }); | + | |
</ | </ | ||
{{: | {{: |
tutorial/itemgroup.1670796401.txt.gz · Last modified: 2022/12/11 22:06 by haykam