Skip to content

Add BlockEntityType Event

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

Add BlockEntityType Event

The @AddBlockEntityType annotation is used to associate custom blocks with existing vanilla block entity types during mod initialization. This annotation eliminates the need for manual block entity registration by programmatically mapping blocks to specific block entity types.

Responsibilities / Purpose

  • Automates block entity association: Links blocks to block entity types without manual registration
  • Enables block entity functionality: Allows blocks to use vanilla block entity behaviors
  • Integrates with initialization: Works seamlessly with Temporal API's initialization system
  • Supports vanilla compatibility: Enables custom blocks to work with existing block entity systems

How it works

  1. Annotation processing: The framework scans fields annotated with @AddBlockEntityType
  2. Block extraction: Extracts the block from the annotated field
  3. Entity type resolution: Resolves the specified block entity type resource location
  4. Registration: Maps the block to the block entity type in BlockEntityTypeEventHandler

Annotation Structure

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface AddBlockEntityType {
    String value();
}

Parameters

  • value (required): Resource location string of the block entity type to associate with the block

Usage Examples

Custom Sign Blocks

@AddBlockEntityType("minecraft:sign")
public static final DeferredBlock<StandingSignBlock> EXAMPLE_SIGN = BLOCK_FACTORY.createStandingSignWithoutItem("example_sign", 1f, ExampleWoodTypes.EXAMPLE_WOOD_TYPE);

@AddBlockEntityType("minecraft:sign")
public static final DeferredBlock<WallSignBlock> EXAMPLE_WALL_SIGN = BLOCK_FACTORY.createWallSignWithoutItem("example_wall_sign", 1f, ExampleWoodTypes.EXAMPLE_WOOD_TYPE);

Custom Hanging Sign Blocks

@AddBlockEntityType("minecraft:hanging_sign")
public static final DeferredBlock<CeilingHangingSignBlock> EXAMPLE_HANGING_SIGN = BLOCK_FACTORY.createCeilingHangingSignWithoutItem("example_hanging_sign", 1f, ExampleWoodTypes.EXAMPLE_WOOD_TYPE);

@AddBlockEntityType("minecraft:hanging_sign")
public static final DeferredBlock<WallHangingSignBlock> EXAMPLE_HANGING_WALL_SIGN = BLOCK_FACTORY.createWallHangingSignWithoutItem("example_wall_hanging_sign", 1f, ExampleWoodTypes.EXAMPLE_WOOD_TYPE);

Custom Chest Variant

@AddBlockEntityType("minecraft:chest")
public static final DeferredBlock<ChestBlock> EXAMPLE_CHEST = BLOCK_FACTORY.createChest("example_chest", ExampleWoodTypes.EXAMPLE_WOOD_TYPE);

When to use

  • Sign blocks: Custom wood types for signs and hanging signs
  • Storage blocks: Custom chest variants with different materials
  • Utility blocks: Custom furnace, hopper, or dispenser variants
  • Redstone blocks: Custom redstone components that need block entity functionality
  • Decorative blocks: Custom blocks that need inventory or data storage
  • Vanilla compatibility: When you want custom blocks to work with vanilla systems

Extension Points

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

  • Automatic registration: No manual event registration required
  • Type safety: Uses reflection to ensure proper block types
  • Strategy pattern: Uses AddBlockEntityTypeStrategy for processing
  • Event handler integration: Works with BlockEntityTypeEventHandler
  • Multi-block support: Multiple blocks can use the same block entity type

The annotation maps to AddBlockEntityTypeStrategy that handles block entity registration logic, allowing for easy extension and customization of the block entity association system.

Important Notes

  • Vanilla only: Currently only supports vanilla block entity types
  • Block entity behavior: The block will inherit all behaviors of the specified block entity type
  • Data compatibility: Custom blocks will be compatible with existing block entity data formats
  • Rendering: Blocks will use the appropriate rendering for their block entity type
  • Inventory: Storage block entities will provide inventory functionality automatically

Clone this wiki locally