Interface RenderContext
Only the renderer should implement or extend this interface.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns aQuadEmitter
instance that is used to output quads.boolean
Returns whether this context currently has at least one transform.boolean
isFaceCulled
(@Nullable Direction face) Returnstrue
if the given face will be culled away.Returns the current transformation mode.Deprecated.void
Removes the transformation added by the last call topushTransform(QuadTransform)
.void
pushTransform
(RenderContext.QuadTransform transform) Causes all models/quads/meshes sent to this consumer to be transformed by the providedRenderContext.QuadTransform
that edits each quad before buffering.
-
Method Details
-
getEmitter
QuadEmitter getEmitter()Returns aQuadEmitter
instance that is used to output quads. It is necessary to callQuadEmitter.emit()
to output a quad.The renderer may optimize certain operations such as
Mesh.outputTo(QuadEmitter)
when used with this emitter. Thus, using those operations is preferred to using the emitter directly. It should be used sparingly for model components that demand it - text, icons, dynamic indicators, or other elements that vary too much for static baking to be feasible.Calling this method invalidates any
QuadEmitter
returned earlier. Will be thread-local/re-used - do not retain references. -
hasTransform
boolean hasTransform()Returns whether this context currently has at least one transform. -
pushTransform
Causes all models/quads/meshes sent to this consumer to be transformed by the providedRenderContext.QuadTransform
that edits each quad before buffering. Quads in the mesh will be passed to theRenderContext.QuadTransform
for modification before offsets, face culling or lighting are applied. Meant for animation and mesh customization.You MUST call
popTransform()
after model is done outputting quads.More than one transformer can be added to the context. Transformers are applied in reverse order. (Last pushed is applied first.)
Meshes are never mutated by the transformer - only buffered quads. This ensures thread-safe use of meshes/models across multiple chunk builders.
Using the quad emitter of this context from the inside of a quad transform is not supported.
-
popTransform
void popTransform()Removes the transformation added by the last call topushTransform(QuadTransform)
. MUST be called before exiting fromFabricBakedModel
.emit... methods. -
isFaceCulled
Returnstrue
if the given face will be culled away.This function can be used to skip complex transformations of quads that will be culled anyway. The cull face of a quad is determined by
QuadView.cullFace()
. Note that if there is a transform, no computation should be skipped, because the cull face might be changed by the transform, or the transform might wish to receive culled faces too.This function can only be used on a block render context (i.e. in
FabricBakedModel.emitBlockQuads(net.minecraft.world.BlockRenderView, net.minecraft.block.BlockState, net.minecraft.util.math.BlockPos, java.util.function.Supplier<net.minecraft.util.math.random.Random>, net.fabricmc.fabric.api.renderer.v1.render.RenderContext)
). Calling it on another context (e.g. inFabricBakedModel.emitItemQuads(net.minecraft.item.ItemStack, java.util.function.Supplier<net.minecraft.util.math.random.Random>, net.fabricmc.fabric.api.renderer.v1.render.RenderContext)
) will throw an exception. -
itemTransformationMode
ModelTransformationMode itemTransformationMode()Returns the current transformation mode.This function can only be used on an item render context (i.e. in
FabricBakedModel.emitItemQuads(net.minecraft.item.ItemStack, java.util.function.Supplier<net.minecraft.util.math.random.Random>, net.fabricmc.fabric.api.renderer.v1.render.RenderContext)
). Calling it on another context (e.g. inFabricBakedModel.emitBlockQuads(net.minecraft.world.BlockRenderView, net.minecraft.block.BlockState, net.minecraft.util.math.BlockPos, java.util.function.Supplier<net.minecraft.util.math.random.Random>, net.fabricmc.fabric.api.renderer.v1.render.RenderContext)
) will throw an exception. -
meshConsumer
Deprecated.UseMesh.outputTo(QuadEmitter)
instead.
-
Mesh.outputTo(QuadEmitter)
instead.