Skip to content

ComposeScreen

abstract class ComposeScreen(title: Component, val asynchronous: Boolean = true) : Screen, CoroutineScope

A Compose-driven Minecraft Screen base class with layer support, async recomposition, and full pointer/keyboard input dispatch.

Extend this class and call start inside your init() override:

class MyScreen : ComposeScreen(Component.literal("My Screen")) {
    override fun init() {
        super.init()
        start {
            Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
                Text(Component.literal("Hello!"))
            }
        }
    }
}

Parameters

  • title: The screen title passed to the vanilla Screen constructor.

  • asynchronous: When true (default), recomposition runs off the main thread and the result is joined at the start of the next frame for smooth, non-blocking updates. Set to false to force synchronous recomposition (simpler but may stutter).

Constructors

ComposeScreen

constructor(title: Component, asynchronous: Boolean = true)

Parameters

  • title: The screen title passed to the vanilla Screen constructor.

  • asynchronous: When true (default), recomposition runs off the main thread and the result is joined at the start of the next frame for smooth, non-blocking updates. Set to false to force synchronous recomposition (simpler but may stutter).

Properties

asynchronous

Parameters

  • asynchronous: When true (default), recomposition runs off the main thread and the result is joined at the start of the next frame for smooth, non-blocking updates. Set to false to force synchronous recomposition (simpler but may stutter).

backgroundMusic

@get:



Nullable



open val backgroundMusic: Music?

coroutineContext

currentFocusPath

@get:



Nullable



open val currentFocusPath: ComponentPath?

focused

@get:



Nullable



open var focused: GuiEventListener?

height

var height: Int

isDragging

isFocused

open var isFocused: Boolean

isPauseScreen

narrationMessage

open val narrationMessage: Component?

rectangle

open val rectangle: ScreenRectangle?

tabOrderGroup

open val tabOrderGroup: Int

title

open val title: Component?

width

var width: Int

Functions

added

open fun added()

afterKeyboardAction

open fun afterKeyboardAction()

afterMouseAction

open fun afterMouseAction()

afterMouseMove

open fun afterMouseMove()

charTyped

open override fun charTyped(codePoint: Char, modifiers: Int): Boolean

children

open fun children(): List<out GuiEventListener?>?

clearFocus

open fun clearFocus()

getChildAt

open fun getChildAt(mouseX: Double, mouseY: Double): Optional<GuiEventListener?>?

handleComponentClicked

open fun handleComponentClicked(@Nullable



 style: Style?): Boolean

handleDelayedNarration

init

fun init(
    minecraft: Minecraft?, 
    width: Int, 
    height: Int
)

isMouseOver

open fun isMouseOver(mouseX: Double, mouseY: Double): Boolean

keyPressed

open override fun keyPressed(
    keyCode: Int, 
    scanCode: Int, 
    modifiers: Int
): Boolean

keyReleased

open override fun keyReleased(
    keyCode: Int, 
    scanCode: Int, 
    modifiers: Int
): Boolean

mouseClicked

open override fun mouseClicked(
    mouseX: Double, 
    mouseY: Double, 
    button: Int
): Boolean

mouseDragged

open override fun mouseDragged(
    mouseX: Double, 
    mouseY: Double, 
    button: Int, 
    dragX: Double, 
    dragY: Double
): Boolean

mouseMoved

open override fun mouseMoved(mouseX: Double, mouseY: Double)

mouseReleased

open override fun mouseReleased(
    mouseX: Double, 
    mouseY: Double, 
    button: Int
): Boolean

mouseScrolled

open override fun mouseScrolled(
    mouseX: Double, 
    mouseY: Double, 
    scrollX: Double, 
    scrollY: Double
): Boolean

nextFocusPath

@Nullable



open fun nextFocusPath(event: FocusNavigationEvent?): ComponentPath?

onClose

open override fun onClose()

onFilesDrop

open fun onFilesDrop(packs: List<Path?>?)

removed

open fun removed()

render

open override fun render(
    guiGraphics: GuiGraphics, 
    mouseX: Int, 
    mouseY: Int, 
    partialTick: Float
)

renderBackground

open fun renderBackground(
    guiGraphics: GuiGraphics?, 
    mouseX: Int, 
    mouseY: Int, 
    partialTick: Float
)

renderNodes

open fun renderNodes(
    guiGraphics: GuiGraphics, 
    mouseX: Int, 
    mouseY: Int, 
    partialTick: Float
)

Measures and renders all active layers.

In async mode the previous recompose job is joined before rendering, then a new job is launched if there are pending frame waiters.

renderTransparentBackground

open fun renderTransparentBackground(guiGraphics: GuiGraphics?)

renderWithTooltip

fun renderWithTooltip(
    guiGraphics: GuiGraphics?, 
    mouseX: Int, 
    mouseY: Int, 
    partialTick: Float
)

resize

open fun resize(
    minecraft: Minecraft?, 
    width: Int, 
    height: Int
)

setTooltipForNextRenderPass

open fun setTooltipForNextRenderPass(tooltip: List<FormattedCharSequence?>?)
open fun setTooltipForNextRenderPass(tooltip: Component?)
open fun setTooltipForNextRenderPass(
    tooltip: List<FormattedCharSequence?>?, 
    positioner: ClientTooltipPositioner?, 
    override: Boolean
)
open fun setTooltipForNextRenderPass(
    tooltip: Tooltip?, 
    positioner: ClientTooltipPositioner?, 
    override: Boolean
)

shouldCloseOnEsc

tick

open fun tick()

triggerImmediateNarration

open fun triggerImmediateNarration(onlyNarrateNew: Boolean)

updateNarratorStatus

open fun updateNarratorStatus(narratorEnabled: Boolean)