Class FabricItemGroupBuilder

java.lang.Object
net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder

public final class FabricItemGroupBuilder extends Object
  • Method Details

    • create

      public static FabricItemGroupBuilder create(net.minecraft.util.Identifier identifier)
      Create a new Item Group Builder.
      Parameters:
      identifier - the id will become the name of the ItemGroup and will be used for the translation key
      Returns:
      a FabricItemGroupBuilder
    • icon

      public FabricItemGroupBuilder icon(Supplier<net.minecraft.item.ItemStack> stackSupplier)
      This is used to add an icon to to the item group.
      Parameters:
      stackSupplier - the supplier should return the item stack that you wish to show on the tab
      Returns:
      a reference to the FabricItemGroupBuilder
    • stacksForDisplay

      @Deprecated public FabricItemGroupBuilder stacksForDisplay(Consumer<List<net.minecraft.item.ItemStack>> appender)
      Deprecated.
      This allows for a custom list of items to be displayed in a tab, this enabled tabs to be created with a custom set of items.
      Parameters:
      appender - Add ItemStack's to this list to show in the ItemGroup
      Returns:
      a reference to the FabricItemGroupBuilder
    • appendItems

      public FabricItemGroupBuilder appendItems(Consumer<List<net.minecraft.item.ItemStack>> stacksForDisplay)
      Set the item stacks of this item group, by having the consumer add them to the passed list. This bypasses Item.appendStacks(net.minecraft.item.ItemGroup, net.minecraft.util.collection.DefaultedList<net.minecraft.item.ItemStack>). If you want to append stacks from your items, consider using the other overload.
      Parameters:
      stacksForDisplay - Add ItemStack's to this list to show in the ItemGroup
      Returns:
      a reference to the FabricItemGroupBuilder
    • appendItems

      public FabricItemGroupBuilder appendItems(BiConsumer<List<net.minecraft.item.ItemStack>,net.minecraft.item.ItemGroup> stacksForDisplay)
      Set the item stacks of this item group, by having the consumer add them to the passed list. Compared to the other overload, this one also passes the new ItemGroup. This allows you to call Item.appendStacks(net.minecraft.item.ItemGroup, net.minecraft.util.collection.DefaultedList<net.minecraft.item.ItemStack>) yourself if you want.
      Parameters:
      stacksForDisplay - Add ItemStack's to this list to show in the ItemGroup, and check if the item is in the ItemGroup
      Returns:
      a reference to the FabricItemGroupBuilder
    • build

      public static net.minecraft.item.ItemGroup build(net.minecraft.util.Identifier identifier, Supplier<net.minecraft.item.ItemStack> stackSupplier)
      This is a single method that makes creating an ItemGroup with an icon one call.
      Parameters:
      identifier - the id will become the name of the ItemGroup and will be used for the translation key
      stackSupplier - the supplier should return the item stack that you wish to show on the tab
      Returns:
      An instance of the built ItemGroup
    • build

      public net.minecraft.item.ItemGroup build()
      Create an instance of the ItemGroup.
      Returns:
      An instance of the built ItemGroup