silk-compose
Adds server-side Compose support to the game. This allows you to create any gui you want, without any limitations - using a modern UI toolkit.
Dependency
modImplementation("net.silkmc:silk-compose:1.0.0")
The Compose dependency is bundled with silk-compose, you don't have to include it yourself.
Don't forget to apply the id("org.jetbrains.compose")
Gradle plugin and add the following repositories as well:
mavenCentral()
google()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") // for unstable compose-jb
// maven("https://androidx.dev/storage/compose-compiler/repository") // for unstable compose compiler
Usage
You can open a server-side compose gui and show it to a player using the player.displayComposable function:
player.displayComposable(8, 6) {
YourComposableFunction()
}
@Composable
fun YourComposableFunction() {
var clicks by mutableStateOf(0)
Button(
onClick = { clicks++ }
) {
Text("Clicked $clicks times")
}
}
and that's it, you now have access to the world of Compose in Minecraft.
You can now have a look at the UI package (below) to see custom composable functions provided by fabrikmc-compose.
Compose docs
There are docs at Android Developer Website and you can find desktop specific documentation at the compose-jb repository. Additionally, there is a community maintained playground. For each Compose module, you can also find very useful API docs, e.g. the ones for Material 3.