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/24 14:20] – Cleanup & formatting. Info on appendItems. More details. virtuoel | tutorial:itemgroup [2020/06/09 23:44] – formatting changes (newline -> same line brackets) draylar | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Item Groups ====== | ====== Item Groups ====== | ||
==== Creating a simple Item Group ==== | ==== Creating a simple Item Group ==== | ||
- | To have your '' | + | To have your '' |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
- | public class ExampleMod implements ModInitializer | + | public class ExampleMod implements ModInitializer { |
- | { | + | |
- | // ... | + | |
public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build( | public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build( | ||
- | new Identifier(" | + | new Identifier(" |
() -> new ItemStack(Blocks.COBBLESTONE)); | () -> new ItemStack(Blocks.COBBLESTONE)); | ||
public static final ItemGroup OTHER_GROUP = FabricItemGroupBuilder.create( | public static final ItemGroup OTHER_GROUP = FabricItemGroupBuilder.create( | ||
- | new Identifier(" | + | new Identifier(" |
.icon(() -> new ItemStack(Items.BOWL)) | .icon(() -> new ItemStack(Items.BOWL)) | ||
.build(); | .build(); | ||
Line 22: | Line 21: | ||
=== Adding your Items to your Item Group === | === Adding your Items to your Item Group === | ||
- | To add an item to your item group, call '' | + | When creating a custom Item, call '' |
<code java> | <code java> | ||
- | public static final Item YOUR_ITEM = new Item(new Item.Settings().itemGroup(ExampleMod.ITEM_GROUP)); | + | public static final Item YOUR_ITEM = new Item(new Item.Settings().group(ExampleMod.ITEM_GROUP)); |
</ | </ | ||
Line 30: | Line 29: | ||
Call '' | Call '' | ||
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
- | public class ExampleMod implements ModInitializer | + | public class ExampleMod implements ModInitializer { |
- | { | + | |
- | // ... | + | |
public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build( | public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build( | ||
- | new Identifier(" | + | new Identifier(" |
() -> new ItemStack(Blocks.COBBLESTONE)); | () -> new ItemStack(Blocks.COBBLESTONE)); | ||
public static final ItemGroup OTHER_GROUP = FabricItemGroupBuilder.create( | public static final ItemGroup OTHER_GROUP = FabricItemGroupBuilder.create( | ||
- | new Identifier(" | + | new Identifier(" |
.icon(() -> new ItemStack(Items.BOWL)) | .icon(() -> new ItemStack(Items.BOWL)) | ||
- | .appendItems(stacks -> | + | .appendItems(stacks -> { |
- | { | + | |
stacks.add(new ItemStack(Blocks.BONE_BLOCK)); | stacks.add(new ItemStack(Blocks.BONE_BLOCK)); | ||
stacks.add(new ItemStack(Items.APPLE)); | stacks.add(new ItemStack(Items.APPLE)); |
tutorial/itemgroup.txt · Last modified: 2023/10/01 03:21 by haykam