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 net.minecraft.world.item.CreativeModeTab.Builder builder()
      Creates a new builder for CreativeModeTab. Item groups are used to group items in the creative inventory.

      You must register the newly created CreativeModeTab to the BuiltInRegistries.CREATIVE_MODE_TAB registry.

      You must also set a display name by calling CreativeModeTab.Builder.title(Component)

      Example:

      
       private static final RegistryKey<ItemGroup> ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, Identifier.fromNamespaceAndPath("modid", "custom_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 CreativeModeTab.Builder instance