tutorial:itemgroup
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
tutorial:itemgroup [2019/02/21 13:17] – mcrafterzz | tutorial:itemgroup [2019/02/24 14:20] – Cleanup & formatting. Info on appendItems. More details. virtuoel | ||
---|---|---|---|
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 = FabricItemGroupBuilder.build( | ||
+ | new Identifier(" | ||
+ | () -> new ItemStack(Blocks.COBBLESTONE)); | ||
+ | |||
+ | public static final ItemGroup OTHER_GROUP = FabricItemGroupBuilder.create( | ||
+ | new Identifier(" | ||
+ | .icon(() -> new ItemStack(Items.BOWL)) | ||
+ | .build(); | ||
+ | // ... | ||
+ | } | ||
+ | </code> | ||
+ | Once '' | ||
- | | + | Make sure you replace the arguments |
- | | + | |
- | | + | |
- | | + | |
- | } | + | |
- | The modid is the id of your mod, name is the name of the creative tabs (must be lowercase | + | === Adding |
+ | To add an item to your item group, call '' | ||
+ | <code java> | ||
+ | public static final Item YOUR_ITEM = new Item(new Item.Settings().itemGroup(ExampleMod.ITEM_GROUP)); | ||
+ | </code> | ||
- | public static final Item FABRIC_ITEM | + | ==== Making an Item Group display specific Items in a particular order ==== |
- | + | Call '' | |
- | Creating an item group is as easy as that! | + | <code java [enable_line_numbers=" |
+ | public class ExampleMod implements ModInitializer | ||
+ | { | ||
+ | // ... | ||
+ | public static final ItemGroup ITEM_GROUP | ||
+ | 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