Amalgamation Wiki
Fabric + NeoForge
Library · Fabric & NeoForge

Custom Creative Mode Tabs

This cannot be explained in a simple form, so you will have to refer to the examples below. Each one shows how to make a colored section and a textured section.

Fabric Example

package com.example.examplemod.init;

import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;
import net.minecraft.world.item.CreativeModeTab;
import org.mythic_goose.amalgamation.library.creative_tab_v1.SectionStyle;
import org.mythic_goose.amalgamation.library.creative_tab_v1.SectionTabBuilder;

public class ExampleCreativeModeTab {

    public static CreativeModeTab EXAMPLE_TAB;

    /** Call once from the testmod's entrypoint, after TestBlocks/TestItems are registered. */
    public static void registerTestTab() {
        SectionTabBuilder builder = SectionTabBuilder.create(
                        Identifier.fromNamespaceAndPath(ExampleMod.MOD_ID, "test_tab"))
                .icon(ExampleItems.EXAMPLE_RUBY.get())
                .title(Component.literal("Example Tab"))
                .displaySection("colored_section" // renders like "itemGroup.mod_id.colored_section", SectionStyle.colored(0xFF97119f), output -> { // gets the color in hex and converts it to a color for the section (0xAARRGGBB)
                    output.add(ExampleBlocks.TEST_ORE.get());
                    output.add(ExampleItems.TEST_RUBY.get());
                    output.add(ExampleItems.TEST_ORE_ITEM.get());
                })
                .displaySection("textured_section" // // renders like "itemGroup.mod_id.textured_section", SectionStyle.textured(), output -> { // get the texture found at "assets/examplemod/textures/gui/tab_overlay/textured_section.png" and uses it for the section. Size has to be 158x16 for the banner
                    output.add(ExampleItems.TEST_RUBY.get());
                });

        EXAMPLE_TAB = Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, builder.id(), builder.build());
    }
}

NeoForge Example

package com.example.examplemod.init;

import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.ItemStack;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredRegister;
import org.mythic_goose.amalgamation.library.creative_tab_v1.SectionStyle;
import org.mythic_goose.amalgamation.library.creative_tab_v1.SectionTabBuilder;

public class ExampleCreativeModeTab {

    private static final DeferredRegister TABS =
        DeferredRegister.create(Registries.CREATIVE_MODE_TAB, ExampleMod.MOD_ID);
    public static DeferredHolder EXAMPLE_TAB =
        TABS.register("example_tab", () -> builder.build());

        SectionTabBuilder builder = SectionTabBuilder.create(
                        Identifier.fromNamespaceAndPath(ExampleMod.MOD_ID, "test_tab"))
                .icon(ExampleItems.EXAMPLE_RUBY.get())
                .title(Component.literal("Example Tab"))
                .displaySection("colored_section" // renders like "itemGroup.mod_id.colored_section", SectionStyle.colored(0xFF97119f), output -> { // gets the color in hex and converts it to a color for the section (0xAARRGGBB)
                    output.add(ExampleBlocks.TEST_ORE.get());
                    output.add(ExampleItems.TEST_RUBY.get());
                    output.add(ExampleItems.TEST_ORE_ITEM.get());
                })
                .displaySection("textured_section" // // renders like "itemGroup.mod_id.textured_section", SectionStyle.textured(), output -> { // get the texture found at "assets/examplemod/textures/gui/tab_overlay/textured_section.png" and uses it for the section. Size has to be 158x16 for the banner
                    output.add(ExampleItems.TEST_RUBY.get());
                }); 

    /** Call once from your mod's entrypoint, after Blocks/Items are registered. */
    public static void registerCreativeModeTabs(IEventBus eventBus) {
        TABS.register(eventBus);
    }
}