Search in sources :

Example 1 with AccessChunkRendererRegion

use of net.fabricmc.indigo.renderer.accessor.AccessChunkRendererRegion in project fabric by FabricMC.

the class MixinChunkRenderTask method chunkDataHook.

/**
 * The block view reference is voided when {@link ChunkRenderTask#getAndInvalidateWorldView()} is called during
 * chunk rebuild, but we need it and it is harder to make reliable, non-invasive changes there.
 * So we capture the block view before the reference is voided and send it to the renderer. <p>
 *
 * We also store a reference to the renderer in the view to avoid doing thread-local lookups for each block.
 */
@Inject(at = @At("HEAD"), method = "takeRegion")
private void chunkDataHook(CallbackInfoReturnable<ChunkRendererRegion> info) {
    final ChunkRendererRegion blockView = region;
    if (blockView != null) {
        final TerrainRenderContext renderer = TerrainRenderContext.POOL.get();
        renderer.setBlockView(blockView);
        ((AccessChunkRendererRegion) blockView).fabric_setRenderer(renderer);
    }
}
Also used : ChunkRendererRegion(net.minecraft.client.render.chunk.ChunkRendererRegion) AccessChunkRendererRegion(net.fabricmc.indigo.renderer.accessor.AccessChunkRendererRegion) TerrainRenderContext(net.fabricmc.indigo.renderer.render.TerrainRenderContext) AccessChunkRendererRegion(net.fabricmc.indigo.renderer.accessor.AccessChunkRendererRegion) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

AccessChunkRendererRegion (net.fabricmc.indigo.renderer.accessor.AccessChunkRendererRegion)1 TerrainRenderContext (net.fabricmc.indigo.renderer.render.TerrainRenderContext)1 ChunkRendererRegion (net.minecraft.client.render.chunk.ChunkRendererRegion)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1