Skip to content

Add to CreativeModeTab Event

Maksym Uimanov edited this page Feb 12, 2026 · 1 revision

Add to CreativeModeTab Event

The @AddCreativeModeTab annotation is used to automatically add items and blocks to specific creative mode tabs during mod initialization. This annotation eliminates the need for manual creative tab registration by programmatically mapping items and blocks to vanilla creative tabs.

Responsibilities / Purpose

  • Automates creative tab placement: Adds items/blocks to creative tabs without manual registration
  • Supports multiple tabs: Allows items/blocks to appear in multiple creative tabs
  • Integrates with initialization: Works seamlessly with Temporal API's initialization system
  • Vanilla compatibility: Uses standard Minecraft creative tab organization

How it works

  1. Annotation processing: The framework scans fields annotated with @AddCreativeModeTab
  2. Item/block extraction: Extracts item or block from the annotated field
  3. Tab resolution: Resolves specified creative tab types to their resource keys
  4. Registration: Maps items/blocks to creative tabs in CreativeModeTabEventHandler

Annotation Structure

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface AddCreativeModeTab {
    CreativeModeTabType[] value();
}

Parameters

  • value (required): Array of creative tab types to add the item/block to

Creative Mode Tab Types

Building and Construction

  • CreativeModeTabType.BUILDING_BLOCKS: Building blocks like bricks, concrete, glass
  • CreativeModeTabType.COLORED_BLOCKS: Colored variants like wool, concrete powder, glass
  • CreativeModeTabType.NATURAL_BLOCKS: Natural blocks like dirt, stone, wood, ores

Functional and Utility

  • CreativeModeTabType.FUNCTIONAL_BLOCKS: Functional blocks like chests, furnaces, crafting tables
  • CreativeModeTabType.TOOLS_AND_UTILITIES: Tools, utility items, and miscellaneous items

Combat and Equipment

  • CreativeModeTabType.COMBAT: Weapons, armor, and combat-related items

Food and Ingredients

  • CreativeModeTabType.FOOD_AND_DRINKS: Food items and drinks
  • CreativeModeTabType.INGREDIENTS: Raw materials, ingredients, and crafting components

Redstone and Special

  • CreativeModeTabType.REDSTONE_BLOCKS: Redstone components and mechanisms
  • CreativeModeTabType.SPAWN_EGGS: Spawn eggs for mobs
  • CreativeModeTabType.OP_BLOCKS: Operator blocks and special items

Usage Examples

Building Blocks

@AddCreativeModeTab(CreativeModeTabType.BUILDING_BLOCKS)
public static final DeferredBlock<?> EXAMPLE_BLOCK = BLOCK_FACTORY.create("example_block", BlockPropertiesFactory.empty());

@AddCreativeModeTab(CreativeModeTabType.BUILDING_BLOCKS)
public static final DeferredItem<?> EXAMPLE_SIGN = ITEM_FACTORY.createSign("example_sign", ExampleBlocks.EXAMPLE_SIGN, ExampleBlocks.EXAMPLE_WALL_SIGN);

Natural Blocks

@AddCreativeModeTab(CreativeModeTabType.NATURAL_BLOCKS)
public static final DeferredBlock<?> EXAMPLE_ORE = BLOCK_FACTORY.create("example_ore", BlockPropertiesFactory.stone());

Functional Blocks

@AddCreativeModeTab(CreativeModeTabType.FUNCTIONAL_BLOCKS)
public static final DeferredBlock<StandingSignBlock> EXAMPLE_SIGN = BLOCK_FACTORY.createStandingSignWithoutItem("example_sign", 1f, ExampleWoodTypes.EXAMPLE_WOOD_TYPE);

Combat Items

@AddCreativeModeTab(CreativeModeTabType.COMBAT)
public static final DeferredItem<?> EXAMPLE_SWORD = ITEM_FACTORY.createSword("example_sword", Tiers.NETHERITE, 1, 1f);

@AddCreativeModeTab(CreativeModeTabType.COMBAT)
public static final DeferredItem<?> EXAMPLE_HELMET = ITEM_FACTORY.createArmor("example_helmet", ExampleArmorMaterials.EXAMPLE_ARMOR_MATERIAL, ArmorItem.Type.HELMET);

Tools and Utilities

@AddCreativeModeTab(CreativeModeTabType.TOOLS_AND_UTILITIES)
public static final DeferredItem<?> EXAMPLE_BOAT = ITEM_FACTORY.createBoat("example_boat", "EXAMPLE");

@AddCreativeModeTab(CreativeModeTabType.TOOLS_AND_UTILITIES)
public static final DeferredItem<?> EXAMPLE_MUSIC_DISC = ITEM_FACTORY.createMusicDisc("example_music_disc", ExampleJukeboxSongs.EXAMPLE_JUKEBOX_SONG);

Ingredients

@AddCreativeModeTab(CreativeModeTabType.INGREDIENTS)
public static final DeferredItem<?> EXAMPLE_INGOT = ITEM_FACTORY.create("example_ingot");

@AddCreativeModeTab(CreativeModeTabType.INGREDIENTS)
public static final DeferredItem<?> EXAMPLE_FUEL = ITEM_FACTORY.create("example_fuel");

Spawn Eggs

@AddCreativeModeTab(CreativeModeTabType.SPAWN_EGGS)
public static final DeferredItem<?> EXAMPLE_SPAWN_EGG = ITEM_FACTORY.createSpawnEgg("example_spawn_egg", ExampleEntityTypes.EXAMPLE_ENTITY, 0x473A24FF, 0x71634FFF);

Redstone Blocks

@AddCreativeModeTab(CreativeModeTabType.REDSTONE_BLOCKS)
public static final DeferredBlock<?> EXAMPLE_REDSTONE_BLOCK = BLOCK_FACTORY.create("example_redstone_block", BlockPropertiesFactory.stone());

Multiple Tab Placement

Items in Multiple Tabs

@AddCreativeModeTab({CreativeModeTabType.INGREDIENTS, CreativeModeTabType.BUILDING_BLOCKS})
public static final DeferredItem<?> MULTI_TAB_ITEM = ITEM_FACTORY.create("multi_tab_item");

Best Practices

Tab Selection

  • Logical grouping: Place items in their most logical category
  • User expectations: Consider where players would look for items
  • Multiple tabs: Use sparingly for items that truly belong in multiple categories
  • Vanilla consistency: Follow vanilla Minecraft's organization patterns

Multi-tab Usage

  • Cross-functional items: Tools that are both utility and building materials
  • Armor sets: Sometimes fit in both combat and building categories
  • Special blocks: Functional blocks that are also decorative

When to use

  • All custom items: Every custom item should be placed in an appropriate tab
  • All custom blocks: Every custom block should be placed in an appropriate tab
  • Multi-category items: Items that logically belong in multiple tabs
  • Vanilla replacement: Items that replace or extend vanilla functionality
  • Mod organization: Ensuring proper organization for user experience

Extension Points

The annotation system integrates with Temporal API's metadata processing:

  • Automatic registration: No manual event registration required
  • Multi-tab support: Items can appear in multiple creative tabs
  • Type safety: Uses reflection to ensure proper item/block types
  • Strategy pattern: Uses AddCreativeModeTabStrategy for processing
  • Event handler integration: Works with CreativeModeTabEventHandler
  • Vanilla compatibility: Uses standard Minecraft creative tab system

The annotation maps to AddCreativeModeTabStrategy that handles creative tab registration logic, allowing for easy extension and customization of the creative mode tab system.

Clone this wiki locally