Use the CreativeModeTabEvent.Register
event to register your tab, the items will appear in the order you declare them.
The accept method has an optional parameter to specify if the items also appear in the search tab or not. Defaults to appearing in both.
public static CreativeModeTab MY_TAB;
private void registerTabs(CreativeModeTabEvent.Register event)
{
MY_TAB = event.registerCreativeModeTab(new ResourceLocation(MODID, "main_tab"), builder -> builder
.icon(() -> new ItemStack(ITEM1.get()))
.title(Component.translatable("tabs.modid.main_tab"))
.displayItems((featureFlags, output, hasOp) -> {
output.accept(ITEM1.get());
output.accept(ITEM2.get(), CreativeModeTab.TabVisibility.SEARCH_TAB_ONLY);
})
);
}
Use the CreativeModeTabEvent.BuildContents
event to register your tab, the items will appear in the order you declare them.
The accept method has an optional parameter to specify if the items also appear in the search tab or not. Defaults to appearing in both.
You can insert ordered by using event.getEntries().putBefore
or putAfter
.
private void addItemsToTabs(CreativeModeTabEvent.BuildContents event)
{
if (event.getTab() == CreativeModeTabs.TOOLS_AND_UTILITIES)
{
event.accept(ITEM1);
event.accept(ITEM2, CreativeModeTab.TabVisibility.SEARCH_TAB_ONLY);
}
}
Is there something that has changed since the last versions? I'm trying to add my items to an existing tab but I can't get it to work for me?!
I'm in version 44.1.0. The item is registered and I can /give them to myself but it doesn't show up in the creative tabs...