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 [2019/02/21 13:17] – mcrafterzz | tutorial:itemgroup [2020/06/09 23:44] – formatting changes (newline -> same line brackets) draylar | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | Do you want your blocks and items blocks to have their own group in the creative | + | ==== Creating a simple Item Group ==== |
+ | To have your '' | ||
+ | <code java [enable_line_numbers=" | ||
+ | public class ExampleMod implements ModInitializer { | ||
- | public static final ItemGroup ITEM_GROUP; | + | public static final ItemGroup ITEM_GROUP |
- | @Override | + | new Identifier(" |
- | public void onInitialize() { | + | () -> new ItemStack(Blocks.COBBLESTONE)); |
- | ITEM_GROUP | + | |
- | | + | public static final ItemGroup OTHER_GROUP |
+ | new Identifier(" | ||
+ | .icon(() -> new ItemStack(Items.BOWL)) | ||
+ | .build(); | ||
+ | // ... | ||
+ | } | ||
+ | </ | ||
+ | Once '' | ||
- | The modid is the id of your mod, name is the name of the creative tabs (must be lowercase to not crash). The icon is should be an itemstack, created with either an item or a block like in this case for example | + | Make sure you replace |
- | public static final Item FABRIC_ITEM | + | === Adding your Items to your Item Group === |
+ | When creating a custom Item, call '' | ||
+ | <code java> | ||
+ | public static final Item YOUR_ITEM | ||
+ | </ | ||
- | Creating | + | ==== Making |
+ | Call '' | ||
+ | <code java [enable_line_numbers=" | ||
+ | public class ExampleMod implements ModInitializer { | ||
+ | |||
+ | public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build( | ||
+ | new Identifier(" | ||
+ | () -> new ItemStack(Blocks.COBBLESTONE)); | ||
+ | |||
+ | public static final ItemGroup OTHER_GROUP = FabricItemGroupBuilder.create( | ||
+ | new Identifier(" | ||
+ | .icon(() -> new ItemStack(Items.BOWL)) | ||
+ | .appendItems(stacks -> { | ||
+ | stacks.add(new ItemStack(Blocks.BONE_BLOCK)); | ||
+ | stacks.add(new ItemStack(Items.APPLE)); | ||
+ | stacks.add(PotionUtil.setPotion(new ItemStack(Items.POTION), | ||
+ | stacks.add(ItemStack.EMPTY); | ||
+ | stacks.add(new ItemStack(Items.IRON_SHOVEL)); | ||
+ | }) | ||
+ | .build(); | ||
+ | // ... | ||
+ | } | ||
+ | </ | ||
+ | {{: |
tutorial/itemgroup.txt · Last modified: 2023/10/01 03:21 by haykam