Class FabricItemGroup

java.lang.Object
net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup

public final class FabricItemGroup extends Object
Contains a method to create an item group builder.
  • Method Details

    • builder

      public static ItemGroup.Builder builder()
      Creates a new builder for ItemGroup. Item groups are used to group items in the creative inventory.

      You must register the newly created ItemGroup to the Registries.ITEM_GROUP registry.

      You must also set a display name by calling ItemGroup.Builder.displayName(Text)

      Example:

      
       private static final RegistryKey<ItemGroup> ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, new Identifier(MOD_ID, "test_group"));
      
       @Override
       public void onInitialize() {
          Registry.register(Registries.ITEM_GROUP, ITEM_GROUP, FabricItemGroup.builder()
             .displayName(Text.translatable("modid.test_group"))
             .icon(() -> new ItemStack(Items.DIAMOND))
             .entries((context, entries) -> {
                entries.add(TEST_ITEM);
             })
             .build()
          );
       }
       
      Returns:
      a new ItemGroup.Builder instance