tutorial:itemgroup
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:itemgroup [2024/07/03 06:02] – solidblock | tutorial:itemgroup [2024/08/23 13:03] (current) – solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ~~REDIRECT> | ||
+ | |||
====== Item Groups ====== | ====== Item Groups ====== | ||
Line 16: | Line 18: | ||
< | < | ||
- | ItemGroupEvents.modifyEntriesEvent(class_7706.field_40195).register(content -> { | + | public class ExampleMod implements ModInitializer { |
- | content.add(CUSTOM_ITEM); | + | @Override |
- | }); | + | public void onInitialize() { |
+ | | ||
+ | content.add(TutorialItems.CUSTOM_ITEM); | ||
+ | }); | ||
+ | } | ||
+ | } | ||
</ | </ | ||
Line 38: | Line 45: | ||
</ | </ | ||
- | In practice, considering items you register | + | In practice, considering items you register |
< | < | ||
public final class TutorialItems { | public final class TutorialItems { | ||
// [...] | // [...] | ||
| | ||
- | public static void registerItemGroups() { | + | public static void registerToVanillaItemGroups() { |
ItemGroupEvents.modifyEntriesEvent(class_7706.field_40195).register(content -> { | ItemGroupEvents.modifyEntriesEvent(class_7706.field_40195).register(content -> { | ||
content.addAfter(class_1802.field_8691, | content.addAfter(class_1802.field_8691, | ||
Line 52: | Line 60: | ||
Then, remember to refer to that method in your '' | Then, remember to refer to that method in your '' | ||
< | < | ||
- | public class ExampleMod implements ModInitializer | + | public class ExampleMod implements ModInitializer |
@Override | @Override | ||
public void onInitialize() { | public void onInitialize() { | ||
- | TutorialItems.registerItemGroups(); | + | TutorialItems.registerToVanillaItemGroups(); |
} | } | ||
+ | } | ||
</ | </ | ||
Line 66: | Line 75: | ||
< | < | ||
- | public | + | public final class TutorialItemGroups { |
public static final class_1761 TEST_GROUP = FabricItemGroup.builder() | public static final class_1761 TEST_GROUP = FabricItemGroup.builder() | ||
- | .icon(() -> new class_1799(CUSTOM_ITEM)) | + | .icon(() -> new class_1799(TutorialItems.CUSTOM_ITEM)) |
.displayName(class_2561.method_43469(" | .displayName(class_2561.method_43469(" | ||
.entries((context, | .entries((context, | ||
- | entries.add(CUSTOM_ITEM); | + | entries.add(TutorialItems.CUSTOM_ITEM); |
}) | }) | ||
.build(); | .build(); | ||
Line 84: | Line 93: | ||
< | < | ||
- | public | + | public final class TutorialItemGroups { |
// .... | // .... | ||
| | ||
Line 99: | Line 108: | ||
Of course, you can directly register them when assigning the fields: | Of course, you can directly register them when assigning the fields: | ||
< | < | ||
- | public | + | public final class TutorialItemGroups { |
public static final class_1761 TEST_GROUP = class_2378.method_10230(class_7923.field_44687, | public static final class_1761 TEST_GROUP = class_2378.method_10230(class_7923.field_44687, | ||
.icon(() -> new class_1799(CUSTOM_ITEM)) | .icon(() -> new class_1799(CUSTOM_ITEM)) | ||
.displayName(class_2561.method_43469(" | .displayName(class_2561.method_43469(" | ||
.entries((context, | .entries((context, | ||
- | entries.add(CUSTOM_ITEM); | + | entries.add(TutorialItems.CUSTOM_ITEM); |
}) | }) | ||
.build()); | .build()); | ||
Line 122: | Line 131: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | :!: The screenshot below is outdated. | ||
{{: | {{: |
tutorial/itemgroup.1719986521.txt.gz · Last modified: 2024/07/03 06:02 by solidblock