Class FabricItemGroup
java.lang.Object
net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup
Contains a method to create an item group builder.
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.world.item.CreativeModeTab.Builderbuilder()Creates a new builder forCreativeModeTab.
-
Method Details
-
builder
public static net.minecraft.world.item.CreativeModeTab.Builder builder()Creates a new builder forCreativeModeTab. Item groups are used to group items in the creative inventory.You must register the newly created
CreativeModeTabto theBuiltInRegistries.CREATIVE_MODE_TABregistry.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.Builderinstance
-