request

fun request(mc: Minecraft, consumer: (NativeImage) -> Unit): Boolean

Take a screenshot of the main render target and hand the image to consumer. Render thread only.

consumer runs inline through 1.21.4; from 1.21.5 the readback sits behind a GPU fence and vanilla's RenderSystem.executePendingTasks delivers it a frame or two later — on the render thread either way. It owns the NativeImage: copy what's needed and close it. It must not throw — on the async path it runs inside a vanilla fenced task, so a throwable escapes into the game loop.

Return

false if this runtime has neither shape, or no main render target yet. true means the request was issued, not that consumer has run.

Throws

whatever takeScreenshot threw: IllegalStateException for a target with no colour texture, IllegalArgumentException for a readback it can't shape.