Skip to content

API reference Obsidian.API.Client

EntityRendererProperties class

How the Obsidian client draws a mod's entity type: a model layer and a texture from the mod's assets, the keyframed animations it plays, layers drawn over it, and code drawing anything else. Register it with IClientRegistry.RegisterEntityRenderer.

public sealed class EntityRendererProperties

In Obsidian.API.Client.

Remarks

Parts named head turn to where the entity looks, and, without a EntityRendererProperties.WalkAnimation, parts whose names end in leg swing as it walks (left and right, and front and back, in opposite phases), like vanilla's mobs; other parts stay as modelled unless an animation moves them.

The items the server says the entity holds and wears are drawn on parts named like vanilla's: held items in the hands of right_arm and left_arm, and armour pieces on the parts vanilla's humanoid armour covers (head, body, right_arm, left_arm, right_leg and left_leg), following them. A model without such a part doesn't show what would go on it.

EntityRendererProperties.TextureProvider and the layers' providers choose how the entity looks from its synced metadata, once each time it changes, and EntityRendererProperties.Renderer runs each frame. They all run on the client's game thread inside a call into the mod. A provider that throws is logged and its defaults are used until the metadata changes again; a renderer that throws is logged, what it drew that frame is dropped, and it isn't called for the entity until its metadata changes.

Layers and the renderer aren't drawn while the entity is invisible.

Constructors

public EntityRendererProperties();

Properties

AttackAnimation

public string AttackAnimation { get; init; }

An animation played once each time the entity swings its arm, which servers show as mobs attack; null for none.

IdleAnimation

public string IdleAnimation { get; init; }

An animation the entity always plays, from its spawn, for example examplemod:golem/idle for assets/examplemod/animations/entity/golem/idle.json; null for none. A looping one repeats, and one that doesn't loop holds its last pose.

Layers

public IReadOnlyList<EntityRenderLayer> Layers { get; init; }

Layers drawn over the model, in order, like vanilla's render layers: glowing eyes, a saddle, an overlay.

Model

public required string Model { get; init; }

The model layer, for example examplemod:golem for assets/examplemod/models/entity/golem.json: the texture's size and a tree of parts with their pivots, rotations and cube faces, in the client's model layer format (see Obsidian's docs on plugin content).

Models

public IReadOnlyList<string> Models { get; init; }

More model layers EntityRendererProperties.Renderer may draw, named like EntityRendererProperties.Model, for the client to read with the assets.

Renderer

public IEntityRenderer Renderer { get; init; }

Code that draws more of the entity each frame, after its model and layers, for what they can't describe.

Scale

public float Scale { get; init; }

How much bigger than its model the entity is drawn.

ShadowRadius

public float ShadowRadius { get; init; }

The radius of the entity's shadow, in blocks, like vanilla renderers' shadow radius; 0 for none.

Texture

public required string Texture { get; init; }

The texture, for example examplemod:entity/golem for assets/examplemod/textures/entity/golem.png. Entity textures are read from textures/entity/.

TextureProvider

public Func<IReadOnlyDictionary<byte, object>, string> TextureProvider { get; init; }

Chooses the texture from the entity's synced metadata, for variants: a texture named like EntityRendererProperties.Texture, or null for EntityRendererProperties.Texture. Null for none.

Remarks

The metadata is like IClientEntity.Metadata: by protocol index, with values as decoded, missing what the server hasn't sent. It's the entity's own table, read-only, so keep the function pure and don't change values in it. It runs at most once per metadata change.

WalkAnimation

public string WalkAnimation { get; init; }

An animation played as the entity walks, advancing with the distance it walks and weighted by its speed like vanilla's walking animations, instead of swinging its legs; null for none.

On this page