Skip to content

Registration

Moth edited this page Aug 9, 2026 · 2 revisions

Registration

Butterfly API provides registration helpers through ModContext and Registrar.

For most normal registrations, you can use the shortcut methods directly on your ModContext.

public static final ModContext MOD =
        ButterflyApi.mod("example_mod", "Example Mod");

Items

Register an item with:

public static final Item EXAMPLE_ITEM = MOD.item(
        "example_item",
        settings -> new Item(settings)
);

This registers:

example_mod:example_item

The factory receives item settings containing the correct 1.21.11 registry key.

Blocks

Register a block and matching block item with:

public static final Block EXAMPLE_BLOCK = MOD.block(
        "example_block",
        settings -> new Block(settings)
);

By default, block(...) registers both:

example_mod:example_block

as a block and as an item.

Blocks Without Items

Use blockOnly(...) when the block should not receive a matching item.

Block block = new Block(MOD.blockSettings("example_block"));

MOD.blockOnly("example_block", block);

Doors

The door(...) helper registers a block with a TallBlockItem instead of a normal BlockItem.

MOD.door("example_door", EXAMPLE_DOOR);

Block Builder

For more control, use blockBuilder(...).

public static final BlockRegistration<Block> EXAMPLE_BLOCK =
        MOD.blockBuilder("example_block", Block::new)
                .settings(settings -> settings.strength(2.0F))
                .register();

The builder uses a normal block item by default.

Change Item Settings

MOD.blockBuilder("example_block", Block::new)
        .itemSettings(settings -> settings.maxCount(16))
        .register();

No Block Item

MOD.blockBuilder("example_block", Block::new)
        .noItem()
        .register();

Tall Block Item

MOD.blockBuilder("example_door", settings -> new DoorBlock(...))
        .tallBlockItem()
        .register();

Custom Item Factory

MOD.blockBuilder("example_block", Block::new)
        .itemFactory(block -> new CustomBlockItem(
                block,
                MOD.itemSettings("example_block")
        ))
        .register();

register() returns a BlockRegistration containing:

registration.block();
registration.item();

The item may be null when .noItem() is used.

Sounds

Create and register a normal sound event with:

public static final SoundEvent EXAMPLE_SOUND =
        MOD.sound("example_sound");

You can also provide an existing SoundEvent:

MOD.sound("example_sound", soundEvent);

Other Registry Helpers

Butterfly API also provides helpers for:

MOD.entity(...)
MOD.blockEntityType(...)
MOD.screenHandler(...)
MOD.statusEffect(...)
MOD.potion(...)
MOD.recipeSerializer(...)
MOD.recipeType(...)
MOD.particle(...)
MOD.tab(...)

Generic Registration

For registries without a dedicated shortcut, use:

MOD.register(registry, "path", value);

Butterfly API automatically creates the identifier using your mod namespace.

Registrar

The underlying registrar can be accessed directly:

MOD.registrar();

For normal usage, the shortcut methods on ModContext are usually simpler.

Enchantments and Paintings

Minecraft 1.21.11 handles enchantments and painting variants through data-driven dynamic registries.

Because of this:

MOD.enchantment(...)
MOD.painting(...)

do not perform normal static registry registration.

Their actual registry entries should be defined through Minecraft's data-driven systems.

Related Pages

Clone this wiki locally