Stateful, layout-driven UIs inside Minecraft Java dialogs (Paper 26.3). No client mods: every screen is drawn with glyphs from a resource pack Canvas generates.
public class SettingsScreen implements NodeLike {
public static void open(final Player player) {
new Canvas(new SettingsScreen()).open(player);
}
@Override
public Node getNode(final Scope scope) {
final State<Boolean> moving = scope.useState(false);
return Panel.builder()
.title("Visuals")
.add(SettingRow.builder().label("Moving background").control(Toggle.of(moving)).build())
.build();
}
}Canvas is published through JitPack. Use a release tag (or a commit hash) as the version:
repositories {
maven("https://jitpack.io")
}
dependencies {
compileOnly("com.github.Chubbyduck1.Canvas:canvas-paper:<tag>")
}As a plugin: download Canvas.jar from Releases into
plugins/, add depend: [Canvas] to your plugin.yml, keep the dependency compileOnly, and register your own
nodes in onEnable:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
CanvasRuntime.get().register(MyNode.class);
}
}Shaded: depend on it with implementation and shade it with Shadow. Relocate
Canvas and leave out what Paper already provides:
dependencies {
implementation("com.github.Chubbyduck1.Canvas:canvas-paper:<tag>")
}
tasks.shadowJar {
relocate("me.chubbyduck.canvas", "com.example.myplugin.libs.canvas")
dependencies {
exclude(dependency("net.kyori:.*"))
exclude(dependency("com.google.code.gson:.*"))
exclude(dependency("org.jetbrains:annotations"))
exclude(dependency("org.jspecify:jspecify"))
}
}Then start it yourself in onEnable (don't also install the Canvas plugin):
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
CanvasRuntime.bootstrap(this).register(Nodes.defaults()).register(MyNode.class).start();
}
}Canvas writes its resource pack to plugins/<plugin>/pack.zip and logs its SHA-1. Host it (or merge it into your
server pack) and send it to players.
plugins/Canvas/config.yml:
| Option | Default | Effect |
|---|---|---|
require-pack |
false |
true: plain dialogs until a resource pack has loaded (.requirePack(true) when shaded) |
metrics |
true |
Anonymous usage statistics on bStats |
Unknown glyphs are measured as 5 pixels, including the spacing pixel. This can be wrong, and if it is, it will offset the entire dialog. Simply register an override for it!
CanvasApi.registerFontWidth(Key.key("myplugin", "icons"), 0xE100,12);
CanvasApi.registerFontWidth(Key.key("minecraft", "default"), '\u6F22',9);
Component icon = Component.text("\uE100").font(Key.key("myplugin", "icons"));./gradlew build builds every module and canvas-paper/build/libs/Canvas-<version>.jar.
./gradlew runServer starts a test server with the example plugin (/ks).
It stages both plugin jars in canvas-kitchensink/build/run-plugins before launch, so rebuilding while the server
is running does not overwrite its loaded jars. Restart runServer to pick up a new build.
Canvas is not affiliated with or endorsed by Mojang Studios or Microsoft. Minecraft is a trademark of Mojang
Studios. The generated pack reuses the vanilla font by reference (no Mojang assets are shipped) and includes an
optional core/gui shader derived from vanilla's, which hides the dialog focus outline.
The project was partially generated with Claude Opus 5.5. My reasoning was as follows: Just wanted to make it work, can make it pretty later :)
