-
Notifications
You must be signed in to change notification settings - Fork 0
Tab Categories and Styling
Butterfly API's creative tab builder supports categories and custom visual styling.
Use:
MOD.tabBuilder("main")when a creative tab needs more control than a basic item group.
Add a category with:
.category(
"materials",
Text.translatable(
"itemGroup.example_mod.category.materials"
),
category -> category
.add(SILK_SCRAP)
.add(POLISHED_SILK)
)The first value:
materials
is the category ID.
The second value is the category's displayed name.
Use Text.translatable(...) when the category should use your language files.
Text.translatable(
"itemGroup.example_mod.category.materials"
)Then add the translation:
{
"itemGroup.example_mod.category.materials": "Materials"
}Category names may also use literal Text values if translation is not required.
Categories can be aligned to the left with:
.alignLeft()Example:
.category(
"materials",
Text.translatable(
"itemGroup.example_mod.category.materials"
),
category -> category
.alignLeft()
.add(SILK_SCRAP)
)Set a category background color with:
.backgroundColor("#35303A")Set the category border with:
.borderColor("#665578")Set the category name color with:
.textColor("#FFE8F5").category(
"materials",
Text.translatable(
"itemGroup.example_mod.category.materials"
),
category -> category
.alignLeft()
.backgroundColor("#35303A")
.borderColor("#665578")
.textColor("#FFE8F5")
.add(SILK_SCRAP)
.add(POLISHED_SILK)
)Add items to a category with:
.add(SILK_SCRAP)Multiple entries can be added:
.add(SILK_SCRAP)
.add(POLISHED_SILK)
.add(EXAMPLE_TOOL)An individual entry can override its slot color.
.entry(
POLISHED_SILK,
entry -> entry
.slotColor("#463B51")
)This allows individual items to visually differ from the normal slots in the tab.
Use:
.categoryOrder(
"materials",
"tools"
)to specify the order categories appear in.
The values correspond to the category IDs supplied when the categories were created.
Set a custom background texture with:
.backgroundTexture(
MOD.id(
"textures/gui/example_tab.png"
)
)Example resource:
assets/example_mod/textures/gui/example_tab.png
Change the normal slot background with:
.slotBackgroundColor("#222222")Change the area between item slots with:
.betweenSlotsColor("#111111")Set the displayed tab name color with:
.tabNameColor("#FFE8F5")An item can be searchable without appearing inside one of the visible categories.
.searchOnly(HIDDEN_DEBUG_ITEM)public static final ItemGroup EXAMPLE_TAB =
MOD.tabBuilder("main")
.icon(SILK_SCRAP)
.translationKey(
"itemGroup.example_mod.main"
)
.backgroundTexture(
MOD.id(
"textures/gui/example_tab.png"
)
)
.slotBackgroundColor("#222222")
.betweenSlotsColor("#111111")
.tabNameColor("#FFE8F5")
.category(
"materials",
Text.translatable(
"itemGroup.example_mod.category.materials"
),
category -> category
.alignLeft()
.backgroundColor("#35303A")
.borderColor("#665578")
.textColor("#FFE8F5")
.add(SILK_SCRAP)
.entry(
POLISHED_SILK,
entry -> entry
.slotColor("#463B51")
)
)
.category(
"tools",
Text.translatable(
"itemGroup.example_mod.category.tools"
),
category -> category
.backgroundColor("#2F3740")
.add(EXAMPLE_TOOL)
)
.categoryOrder(
"materials",
"tools"
)
.searchOnly(HIDDEN_DEBUG_ITEM)
.build();