SilkMC / silk-compose

Bringing Kotlin Compose UI to Minecraft
https://silkmc.net/silk-compose/docs/
GNU Affero General Public License v3.0
67 stars 5 forks source link
compose compose-jb gui jetpack-compose minecraft silkmc

silk-compose

Silk Compose is a module for SilkMC which makes it possible to use Compose Multiplatform inside Minecraft, both on the server- and the client-side (the latter only planned).

Demo

https://user-images.githubusercontent.com/52456572/175792435-1a7f0e30-76cc-4739-87dc-0ec8ed222d4a.mp4

Dependency

Development Environment

Silk Compose is available on Maven Central.

modImplementation("net.silkmc:silk-compose:$version")

As a normal user

Download silk-compose from Modrinth to provide it at runtime and add it as a mod.

Usage

The docs are located at silkmc.net/silk-compose/docs.

To display a basic UI for a player, do the following:

player.displayComposable(8, 6) {
    YourComposableFunction()
}

@Composable
fun YourComposableFunction() {
    var clicks by mutableStateOf(0)
    Button(
        onClick = { clicks++ }
    ) {
        Text("Clicked $clicks times")
    }
}