Skip to content

ComposeContainerScreen

abstract class ComposeContainerScreen<T : AbstractContainerMenu>(
    menu: T, 
    playerInventory: Inventory, 
    title: Component, 
    val asynchronous: Boolean = true
) : AbstractContainerScreen<T> , CoroutineScope

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

Use this when your screen is backed by a AbstractContainerMenu (for inventory slots, crafting grids, etc.). The Compose UI is rendered from renderBg so it appears behind vanilla slot highlights but above the background.

class MyContainerScreen(
    menu: MyMenu, inventory: Inventory, title: Component,
) : ComposeContainerScreen<MyMenu>(menu, inventory, title) {
    override fun init() {
        super.init()
        start { MyContainerContent(menu) }
    }
}

Parameters

  • T: The AbstractContainerMenu subtype.

  • menu: The container menu instance.

  • playerInventory: The opening player's inventory.

  • title: The screen title.

  • asynchronous: When true (default), recomposition runs off the main thread.

Constructors

ComposeContainerScreen

constructor(
    menu: T, 
    playerInventory: Inventory, 
    title: Component, 
    asynchronous: Boolean = true
)

Parameters

  • T: The AbstractContainerMenu subtype.

  • menu: The container menu instance.

  • playerInventory: The opening player's inventory.

  • title: The screen title.

  • asynchronous: When true (default), recomposition runs off the main thread.

Properties

asynchronous

Parameters

  • asynchronous: When true (default), recomposition runs off the main thread.

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

open override val isPauseScreen: Boolean
open override val menu: T?

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?>?

clearDraggingState

open fun clearDraggingState()

clearFocus

open fun clearFocus()

getChildAt

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

getMenu

open fun getMenu(): T?

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. Called from renderBg so that the Compose UI is drawn before vanilla item/slot overlays.

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

fun tick()

triggerImmediateNarration

open fun triggerImmediateNarration(onlyNarrateNew: Boolean)

updateNarratorStatus

open fun updateNarratorStatus(narratorEnabled: Boolean)