Skip to content

API reference Obsidian.API.Client

BlockEntityRendererProperties class

How a mod's block entity type is drawn each frame, on top of its block's model, like vanilla's block entity renderers: parts that move without meshing the world again, such as a machine's spinning gear. Register it with IClientRegistry.RegisterBlockEntityRenderer.

public sealed class BlockEntityRendererProperties

In Obsidian.API.Client.

Remarks

BlockEntityRendererProperties.Provider describes the parts from the block entity's synced data, once per update, and the client animates them each frame; BlockEntityRendererProperties.Renderer is code that draws them itself each frame. Give either, or both.

Block entities are drawn within 64 blocks of the camera and in view, like vanilla's, with the light at their block. Parts that change only when the data does (cable arms, facades) belong in the block's model instead (see IClientRegistry.RegisterBlockEntityModel), which costs nothing per frame.

Constructors

public BlockEntityRendererProperties();

Properties

Models

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

The models the parts may name, in the block model format, like examplemod:part/gear for assets/examplemod/models/part/gear.json (block or item models with elements). The client reads them with the block models; a part naming another model is an error.

Provider

public Func<IReadOnlyDictionary<string, object>, IBlock, IReadOnlyList<BlockEntityRenderPart>> Provider { get; init; }

The parts a block entity draws, from its latest synced update data (plain NBT values: nested compounds are dictionaries, lists are lists) and its block state; null or none to draw nothing. A part is shown by returning it and hidden by leaving it out.

Remarks

It runs at most once per update and block state, on the client's game thread inside a call into the mod: keep it pure and short, and don't mutate nested values. The client turns each part for the frame's time (see BlockEntityRenderPart.Speed). If it throws, the error is logged and the block entity draws nothing until its next update.

Renderer

public IBlockEntityRenderer Renderer { get; init; }

Code that draws a block entity each frame, for what BlockEntityRendererProperties.Provider's parts can't do.

On this page