Skip to content
Get started

Architecture

View as Markdown

Minekube Games rests on one idea: your code runs inside the server process, against the server’s own API, and changing it is a file write. Types, recordings, the devtools and networks all follow from that. This page shows the parts and how a save becomes running code. The pages after it say why each part is built the way it is.

Part Runs in Does
Runtime core The platform’s JVM Watches a folder of bundles (*.js), gives each its own GraalJS context, swaps a bundle when its content changes and uninstalls it when the file goes. Owns every listener and task a bundle registers, keeps JS on one thread, and times every call into JS. It knows no platform.
Platform runtime A Paper plugin, a Velocity plugin, a Fabric mod The platform’s events, scheduler and main thread, on top of the core. On Paper that is listen for any event class and schedule on the server scheduler.
Type generator Each runtime, when its server starts Reads the public classes of the platform’s jars, with nullability and declared exceptions from the bytecode, and writes TypeScript declarations and Effect Schemas.
SDKs Your project @minekube/paper for Paper, @minekube/velocity for Velocity, @minekube/client for the client, one package per platform with its own API. A game is an Effect UI component; the SDK mounts it, records it and connects it to the platform’s events.
CLI Your machine mk server runs the one dev server, mk dev builds your project with Vite on every save and installs it.
Devtools Your machine The Effect UI devtools show every recording as a session; your coding agent reads the same data over MCP.

The same core runs in three places today: Paper for games, Velocity for proxy bundles, and the Minecraft client for test players.

  1. You save. mk dev bundles the project and writes the bundle into the server’s games folder in one atomic step.
  2. The Minekube plugin looks at the folder on its bundle thread a few times a second (every five ticks on Paper). A bundle whose content hash is the running revision is left alone, so rewriting the same file restarts nothing.
  3. It evaluates the new bundle in a fresh context. If that fails, the running revision stays and the server says <id>: bundle rejected, keeping the previous revision.
  4. Only then does the old revision stop. Its scope closes, which removes its listeners, tasks and fibers, and its recording ends.
  5. The new revision starts in the same task on the server thread, so no event reaches the game between the two: Reloaded <id> (<revision>).

Players stay connected throughout: the server, the proxy and their connections never restart. Live swap and lifetime covers what that means for state and failures.

GraalJS contexts are single-threaded, so JS runs only on the platform’s main thread. Paper’s async events, such as AsyncChatEvent, wait up to a second for the server thread and run there, which keeps them cancellable. The same holds for a JS function that Java receives as an interface, like a Runnable or a Brigadier Command: called on the server thread, it runs at once; from another thread, a call without a result is queued, and a call with a result runs on the server thread and gives up after a second. The server thread itself never waits, so there is no deadlock.

Each revision writes its message log to plugins/Minekube/recordings/<game>/<start>-<revision>.ndjson, encoded with the component’s Schemas; the newest 50 per game are kept. mk server streams each recording into the devtools as a session, your coding agent reads them over MCP, and a recording copied into your project becomes a test: bun test replays it through today’s rules. Client bundles are recorded the same way, so a test can read the server’s and the player’s side of one session next to each other. See Testing and Devtools and message logs.

On a GraalVM JDK, the Truffle JIT compiles game code; on other JDKs GraalJS only interprets it, so run your servers on GraalVM. The runtime reports any call that holds the main thread for more than 10 ms, with what explains it: the first call of its kind in a revision, its usual time, garbage collection pauses inside it, and how old the revision is. Performance lists what we measured.

The same game code runs inside the server today: same tick, no network. Running it elsewhere, in a Worker or a Durable Object, is planned as a second Layer of the same PaperServer service, asynchronous instead of synchronous, so the difference sits in one Layer and not in the game.

Was this helpful?