Search in sources :

Example 1 with TerrainRenderContext

use of net.fabricmc.indigo.renderer.render.TerrainRenderContext 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)

Example 2 with TerrainRenderContext

use of net.fabricmc.indigo.renderer.render.TerrainRenderContext in project fabric by FabricMC.

the class MixinChunkRenderer method hookRebuildChunkHead.

/**
 * Save task to renderer, this is the easiest place to capture it.
 */
@Inject(at = @At("HEAD"), method = "rebuildChunk")
private void hookRebuildChunkHead(float float_1, float float_2, float float_3, ChunkRenderTask chunkRenderTask_1, CallbackInfo info) {
    if (chunkRenderTask_1 != null) {
        TerrainRenderContext renderer = TerrainRenderContext.POOL.get();
        renderer.setChunkTask(chunkRenderTask_1);
    }
}
Also used : TerrainRenderContext(net.fabricmc.indigo.renderer.render.TerrainRenderContext) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

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