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/19 14:44] mcrafterzztutorial:itemgroup [2019/02/21 13:17] mcrafterzz
Line 2: Line 2:
 Do you want your blocks and items blocks to have their own group in the creative inventory? Then that can easly be fixed. The most common way to create one is to use //FabricItemGroupBuilder.create//. Like items and blocks this has to be done in //onInitialize// method to work correctly. Do you want your blocks and items blocks to have their own group in the creative inventory? Then that can easly be fixed. The most common way to create one is to use //FabricItemGroupBuilder.create//. Like items and blocks this has to be done in //onInitialize// method to work correctly.
  
 +   public static final ItemGroup ITEM_GROUP;
    @Override    @Override
    public void onInitialize() {    public void onInitialize() {
-       ItemGroup itemGroup = FabricItemGroupBuilder.create("modid:name")})).icon(() -> new ItemStack   +       ITEM_GROUP = FabricItemGroupBuilder.create(new Identifier("modid", "name")})).icon(() -> new ItemStack(block)).build();
-       (block)).build();+
    }    }
  
-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. To add blocks to your item group use //.itemGroup(itemGroup)// when creating it.+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 //Blocks.Grass//. To add blocks to your item group use //.itemGroup(itemGroup)// when creating it.
  
-   public static final Item FABRIC_ITEM = new Item(new Item.Settings().itemGroup(itemGroup));+   public static final Item FABRIC_ITEM = new Item(new Item.Settings().itemGroup(ITEM_GROUP));
  
 Creating an item group is as easy as that! Creating an item group is as easy as that!
tutorial/itemgroup.txt · Last modified: 2024/06/17 12:49 by solidblock