Class FabricCreativeModeTab

java.lang.Object
net.fabricmc.fabric.api.creativetab.v1.FabricCreativeModeTab

public final class FabricCreativeModeTab extends Object
Contains a method to create a creative mode tab builder.
  • Method Details

    • builder

      public static net.minecraft.world.item.CreativeModeTab.Builder builder()
      Creates a new builder for CreativeModeTab. Creative Mode Tab 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 ResourceKey<CreativeModeTab> CREATIVE_MODE_TAB = ResourceKey.create(Registries.CREATIVE_MODE_TAB, Identifier.fromNamespaceAndPath("modid", "custom_group"));
      
      @Override
      public void onInitialize() {
         Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, CREATIVE_MODE_TAB, FabricCreativeModeTab.builder()
            .title(Component.translatable("modid.test_group"))
            .icon(() -> new ItemStack(Items.DIAMOND))
            .displayItems((context, output) -> {
               output.accept(TEST_ITEM);
            })
            .build()
         );
      }
      
      Returns:
      a new CreativeModeTab.Builder instance