-
Notifications
You must be signed in to change notification settings - Fork 0
Creative Tabs
Butterfly API can create both simple Minecraft creative tabs and more heavily customized categorized tabs.
Create a basic creative tab with:
import net.minecraft.item.ItemGroup;
public static final ItemGroup EXAMPLE_TAB =
MOD.tab(
"main",
SILK_SCRAP,
SILK_SCRAP,
POLISHED_SILK
);The first item after the tab path is used as the icon.
The remaining items are added as entries.
The default translation key is:
itemGroup.<modid>.<path>
For example:
itemGroup.example_mod.main
Add the translation to:
assets/example_mod/lang/en_us.json
{
"itemGroup.example_mod.main": "Example Mod"
}Use MOD.tabBuilder(...) for tabs that need categories or custom styling.
import net.minecraft.item.ItemGroup;
import net.minecraft.text.Text;
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();Category names can use translatable text:
Text.translatable(
"itemGroup.example_mod.category.materials"
)Add the matching translations:
{
"itemGroup.example_mod.category.materials": "Materials",
"itemGroup.example_mod.category.tools": "Tools"
}Category names may also use literal text when translation is not needed.
Use:
.categoryOrder(
"materials",
"tools"
)to control the order that categories appear in the tab.
Items can be added to the tab's search results without placing them inside a visible category.
.searchOnly(HIDDEN_DEBUG_ITEM)Butterfly API can also add entries to vanilla or other existing item groups.
import net.minecraft.item.ItemGroups;
MOD.addTo(
ItemGroups.INGREDIENTS,
SILK_SCRAP
);
MOD.addTo(
ItemGroups.BUILDING_BLOCKS,
POLISHED_SILK
);Categorized tabs support additional visual customization for:
- Tab background textures
- Slot backgrounds
- Space between slots
- Tab name colors
- Category backgrounds
- Category borders
- Category text
- Individual entry slot colors
See Tab Categories and Styling for the styling reference.