Skip to content

Registration

Moth edited this page Aug 9, 2026 · 2 revisions

Registration

Butterfly API provides shortcuts for common Minecraft registration through your ModContext.

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

Items

Register an item with:

import net.minecraft.item.Item;

public static final Item SILK_SCRAP = MOD.item(
        "silk_scrap",
        settings -> new Item(settings.maxCount(64))
);

This registers the item as:

example_mod:silk_scrap

For additional item-specific helpers, see Items.

Blocks

Register a block with a matching block item using:

import net.minecraft.block.Block;
import net.minecraft.sound.BlockSoundGroup;

public static final Block POLISHED_SILK = MOD.block(
        "polished_silk",
        settings -> new Block(settings
                .strength(1.5F, 3.0F)
                .sounds(BlockSoundGroup.WOOL))
);

Blocks Without Items

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

public static final Block INVISIBLE_TRIGGER = MOD.blockOnly(
        "invisible_trigger",
        new Block(MOD.blockSettings("invisible_trigger")
                .noCollision()
                .nonOpaque())
);

Block Builder

For blocks requiring additional customization, use:

MOD.blockBuilder(...)

The block builder supports:

  • Custom block settings
  • Custom item settings
  • Custom block item factories
  • Tall block items
  • Blocks without items

It also returns both the registered block and item through BlockRegistration.

See Blocks and Multiblocks for the full block API.

Sounds

Register a sound event with:

import net.minecraft.sound.SoundEvent;

public static final SoundEvent SILK_CHIME =
        MOD.sound("silk_chime");

The corresponding sound should be defined in:

assets/<modid>/sounds.json

Example:

{
  "silk_chime": {
    "sounds": [
      "example_mod:silk_chime"
    ]
  }
}

Other Registration Shortcuts

Butterfly API also provides shortcuts for:

MOD.entity("fluttering_mob", entityType);

MOD.blockEntityType(
        "display_case",
        blockEntityType
);

MOD.screenHandler(
        "display_case",
        screenHandlerType
);

MOD.statusEffect(
        "silk_touchdown",
        statusEffect
);

MOD.potion(
        "silk_touchdown",
        potion
);

MOD.recipeSerializer(
        "looming",
        recipeSerializer
);

MOD.recipeType(
        "looming",
        recipeType
);

MOD.particle(
        "sparkle",
        particleType
);

Enchantments

Enchantments are data-driven in Minecraft 1.21.11.

Define enchantment registry entries under:

data/<modid>/enchantment/

Painting Variants

Painting variants are also data-driven.

Define them under:

data/<modid>/painting_variant/

Client Registration

Renderers, screens, model layers, render layers, and particle factories should be registered from client code.

See Client Registration.

Related Pages

Clone this wiki locally