Skip to content

Register Entity Renderer Event

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

Register Entity Renderer Event

The renderer registration annotations provide a declarative way to register entity and block entity renderers for Minecraft. These annotations automatically handle the registration of renderer classes with Minecraft's rendering system during the renderer registration phase, eliminating the need for manual event handler registration.

Responsibilities / Purpose

The renderer registration annotations are responsible for:

  • Automatically registering entity renderers for custom entity types
  • Automatically registering block entity renderers for custom block entity types
  • Managing the relationship between entity/block entity types and their corresponding renderers
  • Eliminating manual event handler registration for renderer setup
  • Ensuring proper instantiation of renderer classes with required context parameters

How it works

The Renderer Registration system operates through the following process:

  1. Field Scanning: The annotation processor scans fields annotated with renderer registration annotations
  2. Type Extraction: The strategy extracts the EntityType or BlockEntityType from the annotated field
  3. Renderer Class Resolution: The specified renderer class is obtained from the annotation value
  4. Constructor Preparation: The strategy locates the appropriate renderer constructor:
    • For entity renderers: constructor accepting EntityRendererProvider.Context
    • For block entity renderers: constructor accepting the renderer context
  5. Registration Queue: A registration consumer is added to the queue in EntityRendererRegisterRendererEventHandler
  6. Event Processing: During EntityRenderersEvent.RegisterRenderers, the renderers are instantiated and registered

The annotations are processed within the EntityRendererRegisterRendererEventHandlerAnnotationProcessorAdapter scope, ensuring execution at the correct time in the rendering initialization lifecycle.

How to use / Configure

Entity Renderer Registration

Apply the @RegisterEntityRenderer annotation to your entity type field, specifying the renderer class:

public final class ExampleEntityTypes {
    private static final EntityTypeFactory ENTITY_TYPE_FACTORY = InjectionPool.getFromInstance(EntityTypeFactory.class);

    @RegisterEntityRenderer(ExampleRenderer.class)
    public static final DeferredHolder<EntityType<?>, EntityType<ExampleEntity>> EXAMPLE_ENTITY = 
        ENTITY_TYPE_FACTORY.create("example_entity", ExampleEntity::new, MobCategory.MISC, 1f, 1f);
}

Entity Renderer Implementation

Create an entity renderer class:

public class ExampleRenderer extends MobRenderer<ExampleEntity, ExampleEntityModel<ExampleEntity>> {
    public ExampleRenderer(EntityRendererProvider.Context context) {
        super(context, new ExampleEntityModel<>(context.bakeLayer(ExampleEntityModel.LAYER_LOCATION)), 0.5F);
    }

    @Override
    public ResourceLocation getTextureLocation(ExampleEntity exampleEntity) {
        return ResourceUtils.parse("textures/entity/example_entity.png");
    }

    @Override
    public void render(ExampleEntity entity, float entityYaw, float partialTicks, 
                       PoseStack poseStack, MultiBufferSource buffer, int packedLight) {
        if (entity.isBaby()) {
            poseStack.scale(0.6F, 0.6F, 0.6F);
        } else {
            poseStack.scale(1F, 1F, 1F);
        }
        super.render(entity, entityYaw, partialTicks, poseStack, buffer, packedLight);
    }
}

Block Entity Renderer Registration

Apply the @RegisterBlockEntityRenderer annotation to your block entity type field:

public final class ExampleBlockEntityTypes {
    private static final BlockEntityTypeFactory BLOCK_ENTITY_TYPE_FACTORY = 
        InjectionPool.getFromInstance(BlockEntityTypeFactory.class);

    @RegisterBlockEntityRenderer(ExampleBlockEntityRenderer.class)
    public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<ExampleBlockEntity>> EXAMPLE_BLOCK_ENTITY = 
        BLOCK_ENTITY_TYPE_FACTORY.create("example_block_entity", ExampleBlockEntity::new);
}

Block Entity Renderer Implementation

Create a block entity renderer class:

public class ExampleBlockEntityRenderer implements BlockEntityRenderer<ExampleBlockEntity> {
    public ExampleBlockEntityRenderer(BlockEntityRendererProvider.Context context) {
        // Initialize renderer resources
    }

    @Override
    public void render(ExampleBlockEntity blockEntity, float partialTick, PoseStack poseStack, 
                       MultiBufferSource bufferSource, int packedLight, int packedOverlay) {
        // Custom rendering logic
    }
}

Annotation Parameters

  • @RegisterEntityRenderer.value (Class extends EntityRenderer>>): The entity renderer class to instantiate and register
  • @RegisterBlockEntityRenderer.value (Class extends BlockEntityRenderer>>): The block entity renderer class to instantiate and register

Requirements

The renderer classes must:

  • Implement or extend the appropriate renderer interface (EntityRenderer<?> or BlockEntityRenderer<?>)
  • Have a constructor that accepts the required context parameter:
    • Entity renderers: EntityRendererProvider.Context
    • Block entity renderers: BlockEntityRendererProvider.Context
  • Be accessible (public or package-private with appropriate access)

Extension / Customization Points

The Renderer Registration system can be extended by:

  1. Custom Entity Renderers: Create specialized entity renderers with custom rendering logic
  2. Complex Block Entity Renderers: Implement sophisticated block entity rendering with animations
  3. Renderer Variants: Register different renderers for different entity variants
  4. Custom Rendering Contexts: Use the rendering context for advanced rendering features

When to use

Use renderer registration annotations when:

  • Creating custom entities that need visual representation
  • Creating custom block entities that need custom rendering
  • You want to eliminate manual event handler registration for renderers
  • You need to ensure proper timing of renderer registration
  • You want to follow a declarative approach to renderer setup

Clone this wiki locally