Interface RenderAttachedBlockView
- All Superinterfaces:
net.minecraft.world.BlockRenderView
,net.minecraft.world.BlockView
,net.minecraft.world.HeightLimitView
FabricBakedModel
for dynamic model
customization. It ensures thread safety and exploits data cached in render
chunks for performance and data consistency.
There are differences from BlockView consumers must understand:
BlockEntity implementations that provide data for model customization should implement
RenderAttachmentBlockEntity
which will be queried on the main thread when a render
chunk is enqueued for rebuild. The model should retrieve the results via getBlockEntityRenderAttachment(BlockPos)
.
While BlockView.getBlockEntity(net.minecraft.util.math.BlockPos)
is not disabled, it
is not thread-safe for use on render threads. Models that violate this guidance are
responsible for any necessary synchronization or collision detection.
BlockView.getBlockState(net.minecraft.util.math.BlockPos)
and BlockView.getFluidState(net.minecraft.util.math.BlockPos)
will always reflect the state cached with the render chunk. Block and fluid states
can thus be different from main-thread world state due to lag between block update
application from network packets and render chunk rebuilds. Use of {link #getCachedRenderData()}
will ensure consistency of model state with the rest of the chunk being rendered.
Models should avoid using BlockView.getBlockEntity(BlockPos)
to ensure thread safety because this view may be accessed outside the main client thread.
Models that require Block Entity data should implement RenderAttachmentBlockEntity
and then use getBlockEntityRenderAttachment(BlockPos)
to retrieve it. When called from the
main thread, that method will simply retrieve the data directly.
This interface is only guaranteed to be present in the client environment.
-
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable Object
getBlockEntityRenderAttachment(net.minecraft.util.math.BlockPos pos)
For models associated with Block Entities that implementRenderAttachmentBlockEntity
this will be the most recent value provided by that implementation for the given block position.Methods inherited from interface net.minecraft.world.BlockRenderView
getBaseLightLevel, getBrightness, getColor, getLightingProvider, getLightLevel, isSkyVisible
Methods inherited from interface net.minecraft.world.BlockView
getBlockEntity, getBlockEntity, getBlockState, getDismountHeight, getDismountHeight, getFluidState, getLuminance, getMaxLightLevel, getStatesInBox, raycast, raycast, raycastBlock
Methods inherited from interface net.minecraft.world.HeightLimitView
countVerticalSections, getBottomSectionCoord, getBottomY, getHeight, getSectionIndex, getTopSectionCoord, getTopY, isOutOfHeightLimit, isOutOfHeightLimit, sectionCoordToIndex, sectionIndexToCoord
-
Method Details
-
getBlockEntityRenderAttachment
@Nullable default @Nullable Object getBlockEntityRenderAttachment(net.minecraft.util.math.BlockPos pos)For models associated with Block Entities that implementRenderAttachmentBlockEntity
this will be the most recent value provided by that implementation for the given block position.Null in all other cases, or if the result from the implementation was null.
- Parameters:
pos
- Position of the block for the block model.
-