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/04/13 08:04] – map2fabricyarn daomephsta | tutorial:itemgroup [2023/10/01 03:21] (current) – Remove semicolon to nowhere haykam | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Item Groups ====== | ====== Item Groups ====== | ||
- | ==== Creating a simple | + | |
- | To have your ''< | + | //This is the 1.20+ version of this tutorial. For the 1.19 version, see [[tutorial: |
+ | |||
+ | So far, you have used ''/ | ||
+ | |||
+ | ==== 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 registry keys of vanilla item groups are stored in the ''< | ||
+ | |||
+ | Next, you will have to create | ||
< | < | ||
- | public class ExampleMod implements ModInitializer | + | ItemGroupEvents.modifyEntriesEvent(class_7706.field_40195).register(content -> { |
+ | content.add(CUSTOM_ITEM); | ||
+ | }); | ||
+ | </ | ||
- | public static final class_1761 ITEM_GROUP = FabricItemGroupBuilder.build( | + | The modification event also allows more fine-grained control such as placing your custom item in a specific location(eg. after of ''< |
- | new class_2960(" | + | |
- | () -> new class_1799(class_2246.field_10445)); | + | |
- | public static final class_1761 OTHER_GROUP = FabricItemGroupBuilder.create( | + | 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. |
- | | + | |
- | .icon(() -> new class_1799(class_1802.field_8428)) | + | 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); | ||
+ | }); | ||
</ | </ | ||
- | Once '' | ||
- | Make sure you replace the arguments ((Remember that the arguments you pass to the ''< | + | ==== Creating |
- | === Adding your Items to your Item Group === | + | Before you create an item group, determine whether it would have enough content |
- | When creating | + | |
- | < | + | If you think that your own item group is needed, you can use the '' |
- | public | + | |
+ | < | ||
+ | private | ||
+ | .icon(() -> new class_1799(CUSTOM_ITEM)) | ||
+ | .displayName(class_2561.method_43469(" | ||
+ | | ||
+ | entries.add(CUSTOM_ITEM); | ||
+ | }) | ||
+ | .build(); | ||
</ | </ | ||
- | ==== Making an Item Group display specific Items in a particular order ==== | + | You can add entries to your item group within the '' |
- | Call '' | + | |
- | < | + | |
- | public class ExampleMod implements ModInitializer { | + | |
- | public static final class_1761 ITEM_GROUP = FabricItemGroupBuilder.build( | + | It is important to set the display name, otherwise it will cause a crash. |
- | new class_2960(" | + | |
- | () -> new class_1799(class_2246.field_10445)); | + | |
- | public static final class_1761 OTHER_GROUP | + | The next step is to register your item group. |
- | | + | |
- | .icon(() -> new class_1799(class_1802.field_8428)) | + | < |
- | .appendItems(stacks -> { | + | class_2378.method_10230(class_7923.field_44687, |
- | stacks.add(new class_1799(class_2246.field_10166)); | + | |
- | stacks.add(new class_1799(class_1802.field_8279)); | + | |
- | stacks.add(class_1844.method_8061(new class_1799(class_1802.field_8574), class_1847.field_8991)); | + | |
- | stacks.add(class_1799.field_8037); | + | |
- | stacks.add(new class_1799(class_1802.field_8699)); | + | |
- | }) | + | |
- | .build(); | + | |
- | // ... | + | |
- | } | + | |
</ | </ | ||
+ | |||
{{: | {{: |
tutorial/itemgroup.1649837059.txt.gz · Last modified: 2022/04/13 08:04 by daomephsta