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 ItemGroup.Builder
builder()
Creates a new builder forItemGroup
.
-
Method Details
-
builder
Creates a new builder forItemGroup
. Item groups are used to group items in the creative inventory.You must register the newly created
ItemGroup
to theRegistries.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, Identifier.of(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
-