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] – [Add items into existing item groups] solidblock | tutorial:itemgroup [2024/08/23 13:03] (current) – solidblock | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ~~REDIRECT> | ||
| + | |||
| ====== Item Groups ====== | ====== Item Groups ====== | ||
| Line 43: | Line 45: | ||
| </ | </ | ||
| - | In practice, considering items you register | + | In practice, considering items you register |
| < | < | ||
| Line 49: | Line 51: | ||
| // [...] | // [...] | ||
| | | ||
| - | 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 58: | 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 72: | 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 90: | Line 93: | ||
| < | < | ||
| - | public | + | public final class TutorialItemGroups { |
| // .... | // .... | ||
| | | ||
| Line 105: | 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 128: | Line 131: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | :!: The screenshot below is outdated. | ||
| {{: | {{: | ||
tutorial/itemgroup.1719986574.txt.gz · Last modified: 2024/07/03 06:02 by solidblock