Changes

Update to 1.17, will change once PR for event of BERs is added
Line 1: Line 1: −
A <code>TileEntityRenderer</code> or <code>TER</code> is used to render blocks in a way that cannot be represented with a static baked model (JSON, OBJ, B3D, etc.). A tile entity renderer requires the block to have a TileEntity.
+
A <code>BlockEntityRenderer</code> or <code>BER</code> is used to render blocks in a way that cannot be represented with a static baked model (JSON, OBJ, B3D, etc.). A block entity renderer requires the block to have a <code>BlockEntity</code>.
   −
== Creating a TER ==
+
== Creating a BER ==
To create a TER, create a class that inherits from <code>TileEntityRenderer</code>. It takes a generic argument specifying the block's TileEntity class. The generic argument is used in the TER's <code>render</code> method.
+
To create a BER, create a class that inherits from <code>BlockEntityRenderer</code>. It takes a generic argument specifying the block's <code>BlockEntity</code> class. The generic argument is used in the BER's <code>render</code> method.
   −
Only one TER exists for a given tile entity. Therefore, values that are specific to a single instance in the world should be stored in the tile entity being passed to the renderer rather than in the TER itself. For example, an integer that increments every frame, if stored in the TER, will increment every frame for every tile entity of this type in the world.
+
Only one BER exists for a given <code>BlockEntityType</code>. Therefore, values that are specific to a single instance in the world should be stored in the block entity being passed to the renderer rather than in the BER itself. For example, an integer that increments every frame, if stored in the BER, will increment every frame for every block entity of this type in the world.
    
=== <code> render </code> ===
 
=== <code> render </code> ===
   −
This method is called every frame in order to render the tile entity.
+
This method is called every frame in order to render the block entity.
    
=== Parameters ===
 
=== Parameters ===
* <code>tileentityIn</code>: This is the instance of the tile entity being rendered.
+
* <code>blockEntity</code>: This is the instance of the block entity being rendered.
 
* <code>partialTicks</code>: The amount of time, in fractions of a tick, that has passed since the last full tick.
 
* <code>partialTicks</code>: The amount of time, in fractions of a tick, that has passed since the last full tick.
* <code>matrixStackIn</code>: A stack holding four-dimensional matrix entries offset to the current position of the tile entity.
+
* <code>poseStack</code>: A stack holding four-dimensional matrix entries offset to the current position of the block entity.
* <code>bufferIn</code>: A rendering buffer able to access a vertex builder.
+
* <code>bufferSource</code>: A rendering buffer able to access a vertex consumer.
* <code>combinedLightIn</code>: An integer of the current light value on the tile entity.
+
* <code>combinedLight</code>: An integer of the current light value on the block entity.
* <code>combinedOverlayIn</code>: An integer set to the current overlay of the tile entity, usually <code>OverlayTexture#NO_OVERLAY</code> or 655,360.
+
* <code>combinedOverlay</code>: An integer set to the current overlay of the block entity, usually <code>OverlayTexture#NO_OVERLAY</code> or 655,360.
   −
== Registering a TER ==
+
== Registering a BER ==
In order to register a TER, call <code>ClientRegistry#bindTileEntityRenderer</code> passing the tile entity class to be renderer with this TER and the instance of the TER to use to render all TEs of this class.
+
In order to register a BER, call <code>BlockEntityRenderers#register</code> passing the <code>BlockEntityType</code> to be rendered with this BER and a <code>BlockEntityRendererProvider</code>, or BERP, that's used to construct the BER. BERPs can be a method reference that takes in a <code>BlockEntityRendererProvider$Context</code> and returns a BER.
 +
 
 +
{{Tip/Important|<code>BlockEntityRenderers#register</code> should be registered within the synchronous work queue (<code>#enqueueWork</code>) of the <code>FMLClientSetupEvent</code> since the method is not thread-safe.}}