Skip to content

Client Rendering Registration

itsmeow edited this page Jan 4, 2022 · 1 revision

About

IMDLib provides an interface to cleanly register entity renders, based on lambda builders. This removed a lot of the class boilerplate from vanilla, as renders usually only require a small amount of unique information, but a lot of code.

The IMDLib render registration system also ties into the variant system to provide a simple experience.

Usage

The RenderFactory is retrieved and stored into a field:

public static final RenderFactory R = IMDLibClient.getRenderRegistry(MOD_ID);

It is then used during client initialization or FMLClientSetupEvent on Forge.

If your mod uses any heads, must call HeadBlockEntity.registerTypeRender() during this time.

Add Render

This is the main builder interface. It accepts an entity type, a shadow size, then the builder arguments as a lambda.

The following examples are shown for 1.16, there are changes for 1.17+ that I will note later.

Minimal example:

R.addRender(ExampleModEntities.EXAMPLE.getEntityType(), 1F, r -> r.tSingle("tex").mSingle(new ExampleEntityModel<>()));

Methods

This is a documentation of the methods on the render builder.

Texture Mappings (Required)

Single
Condition
Single (Raw)
Condition (Raw)
Variant
Variant + Baby
Mapped
Mapped (Raw)
Variant + Condition

Model Mappings (Required)

Single
Mapped
Condition

Pre Render Callback

This accepts a method called during the LivingRenderer method scale (previously known in MCP/Forge as preRenderCallback).

This is incompatible with any of the scaling methods, as they simply wrap this method.

Scaling

Handle Rotations

Apply Rotations

Render Layers

Used to add render layers to the renderer.

Static Methods

Add Render (Static)

This is wrapper for the default rendering registry, except it takes EntityTypeContainers instead of EntityTypes, and has a cleaner generic type interface.

RenderFactory.addRender(ExampleModEntities.EXAMPLE.get(), RenderExampleEntity::new);

Sprite

This returns a throwable sprite renderer, to be used by things like eggs.

RenderFactory.addRender(ExampleModEntities.EXAMPLE.get(), RenderFactory.sprite());

Nothing

This returns an empty renderer, that renders nothing.

RenderFactory.addRender(ExampleModEntities.EXAMPLE.get(), RenderFactory.nothing());