User Tools

Site Tools


tutorial:itemgroup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
tutorial:itemgroup [2019/09/18 10:32] – .group instead of .itemGroup yanis48tutorial:itemgroup [2020/06/09 23:44] – formatting changes (newline -> same line brackets) draylar
Line 3: Line 3:
 To have your ''ItemGroup'' properly show up in the creative menu, use the ''FabricItemGroupBuilder'' to create them: To have your ''ItemGroup'' properly show up in the creative menu, use the ''FabricItemGroupBuilder'' to create them:
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
-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("tutorial", "general"),  new Identifier("tutorial", "general"),
Line 30: Line 29:
 Call ''FabricItemGroupBuilder#appendItems'' and pass any ''Consumer<List<ItemStack//>//>''. You can then add whatever stacks you want to the given list in some order. ''ItemStack.EMPTY'' can be used to place empty spaces in your group. Call ''FabricItemGroupBuilder#appendItems'' and pass any ''Consumer<List<ItemStack//>//>''. You can then add whatever stacks you want to the given list in some order. ''ItemStack.EMPTY'' can be used to place empty spaces in your group.
 <code java [enable_line_numbers="true",highlight_lines_extra="11,12,13,14,15,16,17,18"]> <code java [enable_line_numbers="true",highlight_lines_extra="11,12,13,14,15,16,17,18"]>
-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("tutorial", "general"),  new Identifier("tutorial", "general"),
Line 40: Line 38:
  new Identifier("tutorial", "other"))  new Identifier("tutorial", "other"))
  .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