Interface Renderer


public interface Renderer
Interface for rendering plug-ins that provide enhanced capabilities for model lighting, buffering and rendering. Such plug-ins implement the enhanced model rendering interfaces specified by the Fabric API.

Renderers must ensure that terrain buffering supports FabricBlockStateModel.emitQuads(QuadEmitter, BlockAndTintGetter, BlockPos, BlockState, RandomSource, Predicate), if they introduce an alternate path for it. In vanilla, this happens in SectionCompiler, which is automatically patched to use altModelBlockRenderer(boolean, boolean, BlockColors).

All places in vanilla code that invoke BlockStateModel.collectParts(RandomSource, List) or ModelBlockRenderer.tesselateBlock(BlockQuadOutput, float, float, float, BlockAndTintGetter, BlockPos, BlockState, BlockStateModel, long) are, where appropriate, patched automatically to invoke FabricBlockStateModel.emitQuads(QuadEmitter, BlockAndTintGetter, BlockPos, BlockState, RandomSource, Predicate) or AltModelBlockRenderer.tesselateBlock(QuadEmitter, float, float, float, BlockAndTintGetter, BlockPos, BlockState, BlockStateModel, long), respectively, instead.

Renderers must implement FeatureRenderers to support ExtendedBlockModelSubmit and ExtendedItemSubmit. This is typically done by adding them to FeatureRenderDispatcher's map with a mixin.

  • Method Details

    • get

      static Renderer get()
      Access to the current Renderer for creating and retrieving mesh builders and materials.

      Warning: do not call this method before ModInitializer has been invoked. Doing so will likely crash.

    • register

      static void register(Renderer renderer)
      Rendering extension mods must implement Renderer and call this method during initialization.

      Only one Renderer plug-in can be active in any game instance. If a second mod attempts to register, this method will throw an UnsupportedOperationException.

    • quadEmitter

      QuadEmitter quadEmitter(Consumer<? super MutableQuadView> consumer)
      Obtain a new QuadEmitter instance that invokes the given consumer on QuadEmitter.emit(), after transforms are applied.
      Parameters:
      consumer - logic performed when the quad is emitted.
    • mutableMesh

      MutableMesh mutableMesh()
      Obtain a new MutableMesh instance to build optimized meshes and create baked models with enhanced features.

      Renderer does not retain a reference to returned instances, so they should be re-used when possible to avoid memory allocation overhead.

    • altModelBlockRenderer

      AltModelBlockRenderer altModelBlockRenderer(boolean ambientOcclusion, boolean cull, net.minecraft.client.color.block.BlockColors blockColors)
      Obtain a new AltModelBlockRenderer instance to tesselate blocks with modded quads. Prefer using this over the vanilla ModelBlockRenderer to correctly tesselate modded models.