tutorial:itemgroup
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:itemgroup [2022/04/13 08:04] – map2fabricyarn daomephsta | tutorial:itemgroup [2023/06/11 08:33] – Add link to 1.19 version mcrafterzz | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Item Groups ====== | ====== Item Groups ====== | ||
- | ==== Creating a simple Item Group ==== | ||
- | To have your ''< | ||
- | < | ||
- | public class ExampleMod implements ModInitializer { | ||
- | public static final class_1761 ITEM_GROUP = FabricItemGroupBuilder.build( | + | //This is the 1.20+ version of this tutorial. For the 1.19 version, see [[tutorial: |
- | new class_2960(" | + | |
- | | + | |
- | public static final class_1761 OTHER_GROUP = FabricItemGroupBuilder.create( | + | So far, you have used '' |
- | new class_2960(" | + | |
- | .icon(() -> new class_1799(class_1802.field_8428)) | + | |
- | .build(); | + | |
- | // ... | + | |
- | } | + | |
- | </ | + | |
- | Once '' | + | |
- | Make sure you replace the arguments ((Remember that the arguments you pass to the ''< | + | ==== Adding |
- | === Adding your Items to your Item Group === | + | 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 ''< |
- | When creating a custom Item, call ''< | + | |
- | < | + | Next, you can simply use '' |
- | public static final class_1792 YOUR_ITEM = new class_1792(new class_1792.class_1793().method_7892(ExampleMod.ITEM_GROUP)); | + | |
+ | But if you want to put your custom item in other 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, | ||
+ | }); | ||
</ | </ | ||
- | ==== Making | + | ==== Creating |
- | Call '' | + | |
- | < | + | |
- | public class ExampleMod implements ModInitializer { | + | |
- | public static final class_1761 ITEM_GROUP = FabricItemGroupBuilder.build( | + | 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. |
- | new class_2960(" | + | |
- | () -> new class_1799(class_2246.field_10445)); | + | |
- | public | + | If you think that your own item group is needed, you can use the '' |
- | | + | |
- | .icon(() -> new class_1799(class_1802.field_8428)) | + | < |
- | | + | private |
- | stacks.add(new class_1799(class_2246.field_10166)); | + | .icon(() -> new class_1799(CUSTOM_ITEM)) |
- | stacks.add(new class_1799(class_1802.field_8279)); | + | .build(); |
- | stacks.add(class_1844.method_8061(new class_1799(class_1802.field_8574), | + | |
- | stacks.add(class_1799.field_8037); | + | |
- | stacks.add(new class_1799(class_1802.field_8699)); | + | |
- | }) | + | |
- | | + | |
- | // ... | + | |
- | } | + | |
</ | </ | ||
+ | |||
+ | You can use '' | ||
+ | |||
+ | < | ||
+ | ItemGroupEvents.modifyEntriesEvent(ITEM_GROUP).register(content -> { | ||
+ | content.add(CUSTOM_ITEM); | ||
+ | }); | ||
+ | </ | ||
+ | |||
{{: | {{: |
tutorial/itemgroup.txt · Last modified: 2024/06/17 12:49 by solidblock