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 revision
Previous revision
Next revisionBoth sides next revision
tutorial:itemgroup [2019/02/24 14:20] – Cleanup & formatting. Info on appendItems. More details. virtuoeltutorial:itemgroup [2019/09/18 10:32] – .group instead of .itemGroup yanis48
Line 1: Line 1:
 ====== Item Groups ====== ====== Item Groups ======
 ==== Creating a simple Item Group ==== ==== Creating a simple Item Group ====
-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
Line 7: Line 7:
  // ...  // ...
  public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build(  public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build(
- new Identifier("mod_id", "general"),+ new Identifier("tutorial", "general"),
  () -> 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("mod_id", "other"))+ new Identifier("tutorial", "other"))
  .icon(() -> new ItemStack(Items.BOWL))  .icon(() -> new ItemStack(Items.BOWL))
  .build();  .build();
Line 22: Line 22:
  
 === Adding your Items to your Item Group === === Adding your Items to your Item Group ===
-To add an item to your item group, call ''Item.Settings#itemGroup'' when creating the item in the same way as adding it to a vanilla item group:+When creating a custom Item, call ''Item.Settings#group'' on your settings and pass in your custom group:
 <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));
 </code> </code>
  
Line 34: Line 34:
  // ...  // ...
  public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build(  public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build(
- new Identifier("mod_id", "general"),+ new Identifier("tutorial", "general"),
  () -> 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("mod_id", "other"))+ new Identifier("tutorial", "other"))
  .icon(() -> new ItemStack(Items.BOWL))  .icon(() -> new ItemStack(Items.BOWL))
  .appendItems(stacks ->  .appendItems(stacks ->
tutorial/itemgroup.txt · Last modified: 2023/10/01 03:21 by haykam