Interface RenderDataBlockEntity


public interface RenderDataBlockEntity
Extensions that allow BlockEntity subclasses to provide render data.

Block entity render data is arbitrary data that captures some useful state of the BlockEntity and is safe to use in a multithreaded environment. In these environments, accessing and using a BlockEntity directly via BlockView.getBlockEntity(BlockPos) may not be thread-safe since the BlockEntity may be modified on a different thread, and it may not be consistent since accessing the internal state of the BlockEntity could modify it in a non-atomic way (such as through lazy computation). Using render data avoids these issues.

Implementation Tips

The simplest form of render data is a value or object that is immutable. If only one such value must serve as render data, then it can be returned directly. An example of this would be returning an Integer that represents some internal state of a block entity. If more than one value must be used as render data, it can be packaged into an object that cannot be modified externally, such as a record. It is also possible to make render data a mutable object, but it must be ensured that changes to the internal state of this object are atomic and safe.

Note: This interface is automatically implemented on all BlockEntity instances via Mixin and interface injection.

  • Method Summary

    Modifier and Type
    Method
    Description
    default @Nullable Object
    Gets the render data provided by this block entity.