Archive incari-client (client, 26.3, clean)

This commit is contained in:
2026-11-28 00:54:38 -06:00
parent 7a6174687f
commit 12838e838c
2383 changed files with 280266 additions and 0 deletions
@@ -0,0 +1,43 @@
# ADR 0001: The repo is patch-only, built on the Spigot/Paper model
- Status: accepted
- Date: 2026-09-25
## Context
Incari modifies Minecraft's client, and Mojang's code and assets can't be redistributed. Playable
Eaglercraft repositories were taken down in 2023, and the EaglercraftX workspace now returns
HTTP 451 on GitHub. Spigot's BuildTools has survived since 2014 by shipping only patches plus a tool
that downloads and decompiles the game on the user's machine.
## Decision
- The repo tracks only Incari's own code, patch files, and a manifest of whole-class changes.
- `./incari setup` downloads the pinned client jar from Mojang, decompiles it with Vineflower into
the git-ignored `work/`, and applies the patches. A fresh clone reaches a patched tree with that
one command.
- Game edits are commits in `work/client`. `./incari rebuild` turns them into patch files. Patch
files are never edited by hand.
- Patches carry as little Mojang text as possible: one context line, no hunk-header function names,
and no file deletions. Deleting or replacing a whole class goes through `patches/classes.txt`,
which names the class and contains none of its code.
- The version, the client jar's SHA-1 and the Vineflower version are pinned exactly, so every
machine decompiles the same bytes and the patches apply everywhere.
- CI never publishes a build (no artifacts, releases or pages), and a guard script enforces it.
## Alternatives rejected
- **Commit the decompiled source on a vendor branch** (the original plan's first sketch): simplest to
rebase, but it puts Mojang's code in the repo.
- **A binary patch against the jar** (Paper's Paperclip): works for JVM bytecode, but Incari's output
is a TeaVM compile. The source tree has to exist locally anyway.
- **Full diff context** (`-U3`, the git default): more robust to drift, but triples the Mojang lines
in the repo. `git am --3way` with full blob ids recovers most of that robustness.
## Consequences
- Updating to a new drop means re-pinning `incari.properties`, then `./incari setup`, fixing
conflicts in `work/client`, and `./incari rebuild`. Automating this is planned.
- Anyone building Incari needs network access to Mojang's download hosts.
- Patch files still contain a few Mojang lines as diff context. Keeping patches thin (one- or
two-line hooks into Incari modules) keeps that small; CI holds patches to a size budget.
@@ -0,0 +1,22 @@
# ADR 0002: GPL-3.0-or-later with a Minecraft additional permission, and DCO sign-off
- Status: accepted
- Date: 2026-09-25
## Decision
- Incari's own code is licensed **GPL-3.0-or-later** (`LICENSE`) with an **additional permission
under GPL section 7** (`LICENSE-EXCEPTION.txt`). It lets anyone convey Incari combined with
Minecraft: Java Edition without having to provide Minecraft's source.
- Contributors certify the **Developer Certificate of Origin** (`DCO.txt`) with a `Signed-off-by`
line on every commit. Signing off licenses the contribution under the project license, exception
included, so no contributor's code can later be used against the builds. CI checks sign-offs on
every pull request.
- DCO rather than a CLA: it's lighter for contributors, and the exception is part of the license
every contribution is made under, so a separate grant isn't needed.
## Consequences
- The published source must keep `LICENSE`, `LICENSE-EXCEPTION.txt` and `DCO.txt` at the root.
- Third-party code copied into Incari must be GPL-3.0-compatible, and must allow the exception.
Code under a license that forbids adding permissions can't be merged into Incari modules.
@@ -0,0 +1,56 @@
# ADR 0003: Enforced module boundaries and one set of quality gates
- Status: accepted
- Date: 2026-09-26
## Context
Incari is two halves: Mojang's decompiled game, which is touched as little as possible, and
Incari's own code, which people and agents write in parallel streams (graphics, platform,
network, features). Without mechanical checks, the architecture erodes one convenient import at a
time. It's also easy to paste decompiled code into an Incari module, which is a quality problem
and a legal one.
## Decision
- **Modules and their allowed dependencies are one file**, `gradle/module-boundaries.txt`.
`./gradlew checkModuleBoundaries` (part of `check`) fails on an undeclared project dependency
and on a module the file doesn't list. ArchUnit tests in each module enforce the package-level
rules a Gradle dependency can't express: `platform-api` uses only the JDK and JSpecify, the
platforms see no game types, and Incari's game-side code never touches LWJGL or TeaVM directly.
- **One set of gates for all Incari code**, run by `./gradlew check`, `npm run check`, CI and the
pre-commit hook:
- Java: Palantir Java Format via Spotless; `-Xlint:all -Werror`; Error Prone; NullAway in
JSpecify mode, where unannotated means non-null (`AnnotatedPackages=incari`).
- TypeScript: `strict` plus stricter compiler options, typescript-eslint's strict type-checked
rules with zero warnings allowed, `any` an error, a reason required on every disable comment,
Prettier.
- GLSL: glslang validates every Incari shader.
- The verbatim-copy check (`./incari copycheck`) fails on 60-token runs identical to the
decompiled game.
- The patch budget (`patches/budget.properties`) makes growth in vendor edits a deliberate,
reviewed change.
- **Vendor code is exempt from all of it.** It's never formatted, linted or fixed for warnings.
`:client` compiles it with lint off, and `strictCompile` rechecks Incari's sources in that
module with the full gates.
- **The build runs on JDK 25** (`gradle/gradle-daemon-jvm.properties` and the toolchain), the
same as CI and TeaVM's limit, so formatter and compiler results don't depend on the machine.
- **Human review** is required through `CODEOWNERS` for patches, graphics, networking, licensing
and the guards themselves.
## Alternatives rejected
- **Convention plugins in `build-logic`**: cleaner at scale, but a second build to maintain for
about thirty lines of shared configuration. Revisit when features add many modules.
- **Checkstyle or Spotless-only rules for architecture**: they can't see the dependency graph.
- **A `-Werror`-free `:client`**: would let warnings pile up in Incari's adapter code, the one
place Incari and vendor code meet.
- **An allowlist for copycheck findings**: every finding is fixed by rewriting, never excused.
## Consequences
- Adding a module means a line in `module-boundaries.txt` and an ArchUnit test; changing a line
needs an ADR.
- `./gradlew check` needs `./incari setup` first, because `:client` compiles the patched tree.
- Upgrading Palantir, Error Prone or TeaVM past what JDK 25 supports means moving the whole
build's JDK, not one tool.
@@ -0,0 +1,45 @@
# ADR 0004: The game is built from the patched source tree, starting with decompile fixes
- Status: accepted
- Date: 2026-09-26
## Context
The TeaVM survey compiled Mojang's jar, not source. Everything after it needs the game compiled
from `work/client`, because that's where Incari's patches live: the desktop runtime and the
TeaVM build both start from it. Vineflower 1.12.0's output of 26.3 doesn't compile as-is:
javac reports 233 errors in 119 files. About 90 are annotation jars Mojang compiled against but
doesn't ship; the rest are generics, casts and variable scopes the decompiler lost. Vineflower's
`--explicit-generics` makes it worse (1,000 errors).
## Decision
- **`:client` compiles `work/client`** as its main source set, against Mojang's own library jars
(the list `incari fetch` writes to `work/cache/versions/<version>/classpath.txt`, after checking
each jar's SHA-1), plus JetBrains annotations and JSR-305 as compile-only dependencies.
- **Decompile errors are fixed by patches in the `decompile` subsystem**, applied first. They
restore what the original source must have been (a cast, a type witness, a renamed duplicate
local, a missing enum case) and change no behavior; where behavior was in doubt, the bytecode
decided. They are **not** wrapped in `// Incari start`/`// Incari end`: those markers identify
Incari's changes to the game, and decompile fixes aren't changes to the game.
- **Vendor warnings stay.** The tree is compiled with lint off, and a warning in Mojang's own code
(26.3 has one) is never patched away.
- **The decompiler options stay at Vineflower's defaults** (plus formatting). Any change to them
regenerates every file and invalidates every patch.
## Alternatives rejected
- **Compile against Mojang's jar and patch only bytecode**: patches would be bytecode transforms
instead of readable source diffs, and the desktop debugger would show decompiled, not patched,
source.
- **Replace every broken class through `classes.txt`**: an Incari-authored copy of a Mojang class
is exactly the verbatim copying the repo forbids.
- **Tune Vineflower until the output compiles**: tried with `--explicit-generics`, which made it
worse; each new drop would need retuning anyway.
## Consequences
- Each Minecraft drop starts with fixing the new decompile errors in `patches/decompile/`. The
Future update automation would treat "the tree compiles" as its first gate.
- The compiled client matches the jar class for class (11,383 classes for 26.3), which the desktop
desktop runtime relies on.
@@ -0,0 +1,72 @@
# ADR 0005: The platform layer: whole-class replacements over Platform interfaces
- Status: accepted
- Date: 2026-09-26
## Context
26.3 talks to the machine directly: SDL3 for windowing and input, OpenAL for sound, Netty's NIO
and epoll transports for servers, the JVM's thread pools. The browser has none of these. This ADR puts
a platform layer under the game so the same code can run on the desktop (for development) and in
the browser, and proves it on the desktop first: vanilla must stay fully playable.
The SDL and OpenAL calls sit in about twenty classes (`com.mojang.blaze3d.platform`,
`com.mojang.blaze3d.audio`, `Blaze3D`) whose job is exactly this glue, plus a handful of calls in
game classes (`RenderSystem`, `Minecraft`, `MouseHandler`, `InputConstants`, `InputQuirks`).
## Decision
- **`platform-api` defines the platform** as plain Java interfaces with no game or library types:
`Platform` (lifecycle, clock, event polling) with `PlatformWindow`/`PlatformDisplays`,
`PlatformInput`, `PlatformShell` (clipboard, links, message boxes), `PlatformAudio`,
`PlatformNetwork` (a byte stream), `PlatformStorage` and `PlatformThreads`. One platform is
installed per process (`Platforms`).
- **Input uses SDL3's conventions as data**: scancodes are USB HID usage ids, keycodes follow SDL's
rule, modifier bits are `SDL_Keymod` values, key actions press/release/repeat. That's what the
game's key handling already reads, so the desktop passes events through untouched and the
browser maps `KeyboardEvent.code` onto the same ids.
- **Glue classes are replaced whole** (`patches/classes.txt`) by Incari sources in
`client/src/main/java` that keep the game-facing API and delegate to the platform. A replacement
is written fresh (copycheck holds it to that) and carries the full quality gates; a patch that
deleted the same SDL code would republish it as `-` lines. Classes that are mostly game logic
(`VideoMode`, `InputConstants`, `RenderSystem`...) get small hook patches instead.
- **Policy moves with the OS calls.** Desktop windowing rules (borderless-window fullscreen on
Windows, exclusive-mode fallback, mouse confinement in exclusive fullscreen) live in
`platform-desktop`; the game's own rules (sizes, GUI scale, the fullscreen request) stay in the
replacement `Window`.
- **Graphics keeps Mojang's backend API.** `PreferredGraphicsApi.getBackendsToTry` asks
`GraphicsBackends`, which the entry point fills: Mojang's OpenGL and Vulkan backends on the
desktop, WebGL2 in the browser. The backend creates the native surface through the
platform (`NativeSurfaceFactory`).
- **Networking keeps Netty's pipeline.** Client connections use `PlatformSocketChannel`, a Netty
channel over `PlatformNetwork`, so framing, compression and packets run unchanged over a socket
on the desktop and a WebSocket in the browser. "Open to LAN" still listens with Netty NIO.
- **Threads**: the platform sizes the background pool; 0 means run inline, which the browser uses
until Web Workers (ADR 0015, 0023).
- **The desktop runtime is verified by a scripted session** (`./gradlew :app-desktop:smokeTest`,
and `smokeHost` + `smokeJoin` for two clients), driven by real SDL events.
## Deviations from vanilla
- macOS: the "Close Window" menu item isn't hidden (the desktop runtime doesn't drive the
Objective-C menu); Command+W asks the game to close, which saves as usual.
- Audio: a device that opens but lacks a required OpenAL extension is skipped in favour of the
next device rather than failing sound; sources are capped at the device's mono-source count.
- The smoke test turns off authentication on its own LAN world so an offline second client can
join; vanilla always authenticates LAN guests.
## Alternatives rejected
- **Patching every SDL call site**: about 200 edits, each republishing Mojang lines in patch files,
and conflicts on every drop that touches these classes.
- **A platform API in game types** (taking `Window`, `VideoMode`): would tie `platform-desktop` and
`platform-web` to the vendor tree and break the module boundary.
- **Replacing Netty's pipeline with Incari's own protocol stack**: far more code, and the Via
integration (ADR 0017) expects Netty.
## Consequences
- A new drop that changes a replaced class isn't a patch conflict; `./incari setup` still copies
the replacement. Each drop needs a check that the replacements' API still matches (the compile
catches most of it) and a smoke-test run.
- `platform-web` implements the same interfaces (ADRs 0006–0015).
@@ -0,0 +1,54 @@
# ADR 0006: How the browser build links: removals by rule, a class library for the rest
- Status: accepted
- Date: 2026-09-26
## Context
TeaVM compiles a closed world: everything reachable must exist at link time. As-is, 26.3 reaches
thousands of APIs a page can't have (LWJGL, JNA, OSHI, profilers, Realms, Vulkan, raw sockets) and JDK
classes TeaVM lacks. The TeaVM survey (`docs/port-backlog.md`) filed each as *stub*, *shim*, *rewrite* or *delete*
(`tools/survey/rules.txt`). The build must link and run the game loop with rendering off, without editing
libraries or scattering patches.
## Decision
- **The survey's rules decide removals.** `RemovalTransformer` rewrites every reference to a
*missing* symbol filed under *delete* or *rewrite*. Existing symbols are never touched; a missing
*stub* or *shim* stays a link error. `removed.txt` lists every removal and its rule.
- **Deleted features are stripped; rewrites throw.** A call into a deleted feature does nothing and
its value is null or zero. A call into code still to be rewritten throws
`UnsupportedOperationException`, so unported paths fail loudly. Class literals of removed classes
become classes nothing is an instance of.
- **`web-classlib` provides stubs and shims**, written fresh from JDK contracts:
- `substitutes.<pkg>.T<Name>` replaces `<pkg>.<Name>` (ours win over TeaVM's);
- `additions` adds missing methods to TeaVM's classes;
- SLF4J binds straight to a console logger;
- LWJGL's memory classes over Java arrays (later linear memory, ADR 0008);
- LWJGL's `STBImage` as a PNG decoder written for the build, pixel-checked against the JDK's;
- the shader include cache's struct as plain memory.
- **`java.time` from ThreeTen Backport**, which TeaVM already maps.
- **Concurrency follows TeaVM:** threads are coroutines; locks, queues, executors and futures block
through monitors and never spin. The worker pool ran inline (until ADR 0015).
- **Monitors that guard no suspension are dropped** (`MonitorElision`). Any monitor makes a method a
coroutine, and that spreads through virtual calls: one `synchronized toString` made every
`toString` a coroutine. In the page, code that can't suspend already runs exclusively, so monitors
come off methods that don't wait or block; `lock()` there becomes a non-waiting acquire that fails
loudly if held. The accepted risk: a method that blocks only through a virtual call loses a monitor
it needed. `async.txt` lists hot methods still compiled as coroutines.
- **`ServiceLoader` finds nothing:** service lookups are only for extras the build leaves out.
- **TeaVM bugs are fixed in `tools/teavm-patches`**, each meant for upstream.
- **Generic superclasses kept only for type capture** (`TypeCaptures`): `TypeToken` subclasses read
their type argument at run time.
- **Resources come from the client jar at run time** (since ADR 0011, mounted in place).
- **Entry-point hooks** for native library loading, the Vulkan check and the render step (off until
ADR 0007). The loop yields to the page once per pass (`Platform.endFrame`).
## Consequences
- The build links without editing any library; every removal traces to a rule, and changing what
the browser keeps is a reviewed change to `rules.txt`.
- A stripped feature can hide a null a later caller trips over. Deleted categories (profilers,
telemetry, Realms, online-mode crypto) are chosen so that doesn't reach game logic; a crash traced
to a stripped reference means a rule is in the wrong category.
- `web-classlib` is JDK surface we maintain, tested against the real JDK where possible.
@@ -0,0 +1,40 @@
# ADR 0007: The WebGL2 backend, under Mojang's frontend, with shaders translated at build time
- Status: accepted; the unsupported pipelines and the depth range are superseded by
[ADR 0012](0012-webgl2-backend-complete-and-screenshot-diffs.md)
- Date: 2026-09-27
## Context
26.3 draws through `com.mojang.renderpearl`: a validating frontend (`FrontendGpuDevice`) over a
backend (`GpuDeviceBackend`: OpenGL or Vulkan). Pipelines compile at run time with shaderc and
SPIRV-Cross, native libraries a page doesn't have; compiling them to WebAssembly would add megabytes
for work with the same answer every time. WebGL2 also differs in shaders (GLSL ES 3.00) and device
features (no mapping, base vertex, multi-draw, per-target blend).
## Decision
- **The backend sits under Mojang's frontend:** `render-webgl2` implements `GpuDeviceBackend`, and
`WebGl2Backend` wraps it in `FrontendGpuDevice`, so the game's validation stays in front. The
device reports what WebGL2 lacks, so the game takes its plain paths.
- **Shaders are translated at build time:** `tools/shaders` loads the game's pipeline registry on the
build JVM and compiles every distinct stage to GLSL ES 3.00 with shaderc and SPIRV-Cross, set up as
the game does. Varyings are renamed by location; blocks and samplers keep the game's names. The
result and its reflection go in `shaders.json` beside the page (never in the TeaVM output, never
committed).
- **glslang checks every program**; `?shaders=eager` links them all in the browser at start-up.
- **One hook** (`PipelineCompilingBackend`) lets the backend compile its own pipelines from the
manifest, so the frontend never creates shaderc. A resource pack that changes a vanilla shader gets
the vanilla translation, with a warning.
- **Programs link on first use** (each link costs milliseconds on a Chromebook).
- **The game's copy of a buffer is the truth;** writes are uploaded through linear memory.
- **Gaps filled in the device:** attributes re-pointed for a base vertex, one shared vertex array,
the first target's blend for all, texture views as mip ranges, no timestamps.
- At first, 33 of 216 pipelines (texel buffers, indexed fragment outputs) drew nothing; ADR 0012 fixed them.
## Consequences
- Most of the render API runs unchanged, and the frontend validates every call before the backend.
- Resource packs can't change shaders in the browser.
- `tools/shaders` runs game code at build time and fails loudly if a version reaches beyond the
minimal platform it installs.
@@ -0,0 +1,46 @@
# ADR 0008: Off-heap memory in the module's linear memory, and Netty in heap mode
- Status: accepted
- Date: 2026-09-27
## Context
The game keeps vertex data, images and uniforms off the Java heap through LWJGL's `MemoryUtil`,
`MemoryStack` and allocators. The first stand-ins (ADR 0006) used Java arrays, so every write went through a lookup
and every upload was copied (a `byte[]` under WebAssembly GC is invisible to JavaScript).
Netty's buffers didn't start in the page at all: `MethodHandles.lookup()` failed on TeaVM's empty
`java.lang.invoke`, the leak detector used reflection, and TeaVM's generated atomic updaters were
treated as missing. Networking needs them.
The original plan was `ArrayBuffer` + `DataView`, but every vertex element would then be a call into
JavaScript, where TeaVM's `Address` intrinsics compile to single load/store instructions on the same
bytes.
## Decision
- **The game's memory users run unchanged;** `web-classlib`'s stand-ins (`TMemoryUtil`,
`TMemoryStack`, `TBufferUtils`, `TSTBImage`) sit underneath, over `Heap`. No vendor patch.
- **Memory is the module's linear memory:** each allocation is a TeaVM direct buffer, an address is
its real offset, reads and writes are single instructions (`LinearMemory`), and views are slices.
WebGL uploads read them in place, with no copy.
- **Freeing is immediate** (linear memory only grows). `calloc` and `BufferUtils` clear explicitly.
- **TeaVM's internal buffer interfaces** are redeclared identically in `web-classlib` so `Heap` can name them.
- **The same code runs on a JVM for tests:** `Heap.linear()` picks the backend at compile time; the
JVM backend checks bounds and fills `malloc`'d memory with junk.
- **Byte parity is tested:** `MemoryParityTest` runs the game's memory users on LWJGL and on the
stand-ins and requires every byte to match; a browser probe compares digests.
- **Netty runs in heap mode:** unpooled, no `Unsafe`, leak detection off (`LibraryDefaults`). A
method-handle lookup that finds nothing makes Netty fall back; leak detector reflection is declared;
generated atomic updaters count as present.
- **JOML starts:** `joml.format=false` (TeaVM rejects its `DecimalFormat`), and `org.joml.Runtime` is
substituted (`Class.forName("java.lang.Float")` fails in TeaVM).
## Consequences
- A vertex element costs one store; a mesh upload costs no copy.
- Linear memory isn't bounds-checked: a stray write corrupts instead of throwing. The JVM backend
and the parity test catch misuse.
- Linear memory never shrinks; its high-water mark is the page's.
- Netty's adaptive allocator stays unusable; the default is unpooled.
- LWJGL's `PointerBuffer` isn't stood in for: nothing the browser runs uses it.
@@ -0,0 +1,63 @@
# ADR 0009: A WebSocket transport under the game's Connection, one packet per message
- Status: accepted
- Date: 2026-09-27
## Context
A page can't open TCP sockets; every browser client uses WebSocket. Eagler servers speak WebSocket
with one packet per binary message, no length prefix, after an Eagler handshake. The game's
connections already run on `PlatformSocketChannel` (ADR 0005). Missing: a WebSocket on each platform,
a way to name a WebSocket server, and message framing. Via and the Eagler handshake must fit later.
## Decision
- **The platform opens WebSockets:** `PlatformNetwork.openWebSocket(url, listener)` returns the same
`NetConnection` as TCP, with message semantics. Desktop: the JDK's `java.net.http.WebSocket`.
Browser: the page's `WebSocket`, whose callbacks only queue events, delivered on the game's thread
at each poll (a JavaScript callback can't start a coroutine).
- **A new module, `:net`**, owns the transport (`NetConnectionChannel`, `WebSocketUrl`,
`WebSocketAddress`, `MessageFraming`). Netty and `platform-api` only, no game types.
- **Players type a URL:** `ws://` or `wss://`. `ServerAddress` is replaced whole to hold either a TCP
host and port or a `WebSocketUrl`. Two hooks: the resolver passes WebSocket addresses through (no
DNS or SRV; the block list still applies), and `Connection.connect` hands them to
`WebSocketConnections`, which builds the game's own pipeline with message framing. Connect screen,
server ping and reconnects work unchanged.
- **One packet per message:** `MessageFraming` replaces "splitter" and "prepender" under the same
names, so compression and encryption slot in as over TCP. Oversized or empty messages fail.
- **Later stages slot in by name:** the Eagler handshake before "splitter"; Via between compression
and the codec, as ViaFabricPlus does.
- **A development bridge** (`tools/wsbridge`) stands in for an Eagler proxy in front of a vanilla
server. Never shipped.
- **The browser build keeps Netty's pipeline**, minus the NIO transport. Event loops are local ones
on coroutine threads; `web-classlib` adds IP-literal socket addresses, two NIO exceptions, and binds
Netty's logger to SLF4J (Log4j's lookup made every exception constructor a coroutine).
- **The Eagler handshake belongs in the client**, not a server plugin
([`docs/eaglerxserver.md`](../eaglerxserver.md)).
## Alternatives rejected
- **TCP's byte stream inside messages:** no Eagler server speaks it.
- **Hooking `ConnectScreen`:** would miss the server list ping, and `Connection.connect` loses a URL.
- **`java.net.URI`:** not a browser's rules. `WebSocketUrl` accepts exactly what a page's `WebSocket` does.
- **A separate channel class:** the address already decides which call opens the connection.
## Verified
- **Desktop** (`smokeServer`): ping, join, chat, the Nether and back, a transfer, disconnect and
reconnect, over `ws://` through the bridge and over TCP.
- **Browser** (`server-join.steps`): join, chat, the Nether and back, a transfer to a `ws://`
address, a kick and rejoin. Getting there took about ten TeaVM and build fixes, most with a probe
in `app-web/probes/`: coroutine type inference, class initialization order, interrupted `wait()`,
`ArrayDeque`'s iterator, `getSuppressed`, Netty handlers' captured generic types, and `Module`.
## Consequences
- Online-mode encryption can't pass a proxy that doesn't decrypt (each message would be encrypted
alone). Eagler servers run offline mode, so this matches the target.
- The legacy server ping (only when a modern one fails) can't reach a WebSocket server.
- A transfer packet may name a `ws://` URL as its host, so servers can move browser players.
- The bandwidth chart counts packets without TCP's length prefix.
- Network events reach the game once per frame, which bounds reading in a throttled hidden tab
(ADR 0006's quarter-second fallback keeps the connection alive). Since ADR 0075 a message also
wakes the game's thread between frames, and the connection's thread reads it at once.
@@ -0,0 +1,45 @@
# ADR 0010: Browser input: focus, a text input element, an asynchronous clipboard, dropped files
- Status: accepted
- Date: 2026-09-27
## Context
The game reads input as SDL3 reports it (ADR 0005). A page gets DOM events instead, and the browser
keeps control SDL gives a desktop program: it owns shortcuts like Ctrl+W, allows Pointer Lock and
fullscreen only after a gesture, releases the lock on Escape, reads the clipboard only in a paste
event or a promise, and gives dropped files as contents, not paths. And a DOM listener can't call
into the game (a coroutine can't start from a JavaScript callback).
## Decision
- **Every DOM event is queued and drained at the game's poll** (`DomEventQueue`, plain Java). Async
APIs report back through the same queue. The only call from a listener into Java is the pure
`DomEventQueue.consumesKey`.
- **Keys are the game's while it has focus** (canvas, its textarea, or the body). All defaults are
cancelled except developer tools, Ctrl+V (for the paste event) and dead keys (for composition). A
host page's own controls keep their keys.
- **Browser-reserved shortcuts:** Ctrl+W/T/N, Ctrl+1–9 and Ctrl+Q can't be cancelled outside
fullscreen. In fullscreen, Keyboard Lock takes them (and Escape pauses; holding it exits). Outside
fullscreen, a leave-page prompt guards the tab while the mouse is locked.
- **Text through an invisible textarea** while a field wants typing, placed over the field so input
method candidates appear there. Ordinary typing still comes from key events; only compositions
and keyless text (virtual keyboards, voice) come from the textarea.
- **Key names from the Keyboard Map API**, re-read on refocus; learned from typing where it's
missing (Firefox, Safari).
- **Clipboard never waited on:** Ctrl+V's paste event arrives in the same frame as the key. Writes
use the async Clipboard API (or a copy command over plain http) without waiting.
- **Pointer Lock asks for raw movement** (`unadjustedMovement`), falling back to a plain lock. Leaving
with Escape gives the game the Escape it missed, so it pauses.
- **Fullscreen is the canvas's**, always borderless; leaving it from the browser updates the game's option.
- **A hidden tab counts as lost focus:** held keys release, pause-on-focus-loss applies.
- **Dropped files are copied into `/incari/dropped/<id>/`** and their paths handed to the game's drop
handler, so pack screens take them as on the desktop.
## Consequences
- Nothing depends on game types; the game-facing side is unchanged from ADR 0005.
- Headless Chromium can't show raw movement, Keyboard Lock, input method windows or the leave-page
prompt: they're on the manual checklist.
- Without `unadjustedMovement` (Firefox, Safari, some Chromium), mouse movement keeps system
acceleration, unlike SDL's relative mode.
@@ -0,0 +1,65 @@
# ADR 0011: Storage: the file system in memory, written behind to OPFS by a worker
- Status: accepted
- Date: 2026-09-28
## Context
The browser build ran on TeaVM's in-memory file system: a reload lost everything, and the
client jar was unpacked on every load (22,844 resources, 86 MB of heap, ~1 s).
The game's file access is synchronous everywhere; the browser's durable storage (OPFS, IndexedDB)
isn't, and OPFS's synchronous handles exist only in workers. Making file calls wait would turn most
of the program into coroutines (ADR 0006), and the page's thread may not block on a worker.
## Decision
- **The file system is a tree in memory** (`TreeFileSystem`), installed first thing in `WebMain`.
Every file call stays synchronous. Where TeaVM differed from the JDK, it follows the JDK
(`"rw"` keeps bytes, seeks past the end leave zeros, renames may replace, `/tmp` exists).
- **Written behind once a frame:** a `Journal` records shape changes and written byte ranges. At
`endFrame` one batch goes out: folders, then writes (new files whole, existing ones only the
changed bytes), then deletes. A file rewritten many times is sent once; a temp file renamed into
place is never sent under its temp name. No game patches: save points are ordinary writes.
- **A storage worker keeps the durable copy** (`storage-worker.js`, run from a Blob URL). OPFS with
sync access handles, writing only changed bytes off the page's thread; `createWritable` where sync
handles are missing; IndexedDB without OPFS (plain-http pages, older browsers); nothing, with a
console note, if neither exists. It loads `/incari` at start-up and hands it to the page.
- **One tab writes:** a Web Lock; a second tab keeps its changes to itself and tells the player
(`PlatformNotice`, a toast), as it does when there's no storage. The page asks for persistent storage.
- **A change the store couldn't keep is sent again whole** (2026-11): the worker stores the rest of
the batch and names the failed paths; five seconds later the page marks them changed, so a lost
range never leaves a file damaged. A failed save is told to the player once until saving works again.
- **Leaving saves singleplayer** (2026-11): the page's own hidden, `beforeunload` and `pagehide`
listeners post a save to the world's worker, and in a world the page asks before closing.
- **The client jar is cached whole and mounted** read-only at `/incari/classpath` (`ZipArchive`),
each entry inflated when opened: one read instead of 22,844, and a 40 MB buffer outside the heap
instead of 86 MB in it.
- **Not kept:** dropped files, the mounted jar, anything outside `/incari`.
- **Files reach the player through the shell:** `PlatformShell.openPath` downloads a file (F2's
screenshot link) or opens the file picker for a folder (the pack screens' "Open Pack Folder" becomes import).
- **Screenshots encode in the page** (`PngEncoder` behind LWJGL's `STBImageWrite`).
- **Fixed on the way:** `MessageDigest` added (Guava's `sha1()` names server icons); TeaVM's
`ZipFile` failed at some entries' end (638 textures of a pack); single-byte reads returned signed
bytes, so 0x80 read as end-of-file and the server list was lost.
## Alternatives rejected
- **Suspending file calls:** most of the game becomes coroutines, and each small write a round trip.
- **The page blocking on a worker** (`Atomics.wait`): the page's thread may not block.
- **Writing from the page with `createWritable`:** copies the whole file on every close.
- **Persisting the unpacked jar:** 22,844 reads every start.
- **Flushing only on `pagehide`:** no Java can run there, and async writes started there may not finish.
## Consequences
- **A reload can lose** the current frame's writes and a batch not yet applied (milliseconds). An
interrupted OPFS batch can be partly applied; IndexedDB batches are whole. A failed change is
sent again, whole.
- **Everything stored is in memory** (worlds too), until region files stay in place (ADR 0041).
- **File times:** OPFS keeps its own; a time the game sets is kept only in IndexedDB. Read-only flags aren't kept.
- **Without persistent storage**, the browser may evict data when the disk is nearly full.
- The game's profiling-report zip file system is still unsupported.
- **Verified** by `storage.steps`, `community-pack.steps`, `screenshot.steps`, the probes
`StorageProbe`, `FileReadProbe`, `ZipFileProbe`, and unit tests of the tree, journal, zip reader and
worker. Persistence across a browser restart, second tabs and downloads are on the manual checklist.
@@ -0,0 +1,72 @@
# ADR 0012: Every pipeline in WebGL2, and screenshot diffs against the desktop
- Status: accepted
- Date: 2026-09-28
## Context
After ADR 0007, 33 of 216 pipelines couldn't run: the clouds read a texel buffer (WebGL2 has none),
and the improved-transparency passes index an array of fragment outputs (GLSL ES 3.00 forbids it).
And nothing checked that the browser draws what the desktop draws.
## Decision
### Every pipeline runs
`tools/shaders` lists every pipeline the game can make (219 in 26.3, post-effect passes included)
and what each needs; all translate and link.
- **Texel buffers become 2D textures**, 2048 texels wide (element `i` at `(i & 2047, i >> 11)`). The
build rewrites `texelFetch` (`EsslRewrites.texelBuffers`); the device re-uploads the texture only
when the buffer changed (`TexelBufferTexture`).
- **Fragment output arrays become separate outputs**: the shader writes a private array, and a new
`main` copies each element out (`EsslRewrites.fragmentOutputArrays`).
- **Depth runs 0 to 1 where the browser has EXT_clip_control**, so the game's reversed-Z works as on
the desktop; the build translates a second variant of stages that read the depth define. Without
the extension, the game's own −1-to-1 path draws the same images with less far-plane precision.
- **32-bit float targets fall back to 16-bit** where the browser can't blend 32-bit floats.
- **Wireframe** uses WEBGL_polygon_mode where present, else is skipped with one warning.
- **Texture uploads read linear memory in place.**
Atlases, mipmaps, anisotropy, framebuffers, post effects and uniform buffers needed no change.
### Screenshot diffs (`./gradlew :app-web:screenshotDiff`)
- **Two games, one script.** Each gets its own vanilla server with a fresh world from one seed. The
desktop game (Mojang's OpenGL backend, the reference) is driven over a loopback line protocol
(`SceneAgent`); the browser build over DevTools. Both run `scenes.txt`: RCON commands build each
scene and place the camera.
- **Deterministic.** Worlds are frozen and stepped tick by tick from game time 40, so weather,
clouds and animations line up. Built scenes float above y 150. Same options (1280×720, GUI scale 2,
FOV 70, render distance 8, HUD hidden). A shot waits for three alike frames 1.5 s apart.
- **Compared by SSIM** (RGB mean, 11-pixel Gaussian window, `ImageDiff`), plus the share of pixels
over 32/255 apart and a heat map.
- **Threshold SSIM ≥ 0.90** for every shot. Correct renders on two drivers score ≥ 0.996; broken ones
(unlit terrain, a missing pass, a crash) scored 0.13–0.85.
- **The page must stay clean:** any WebGL error, incomplete framebuffer, shader failure or skipped
pipeline fails the run.
- **Nothing rendered is committed:** shots are pictures of Mojang's assets.
## Results
2026-09-28, RX 9060 XT: desktop on Mesa radeonsi, browser on ANGLE's OpenGL over the same driver.
14 shots (terrain, translucency with and without improved transparency, entities, particles, sky,
GUI, distant terrain, post effects, weather, Nether, End): **SSIM 0.9967–1.0000**, ≤ 0.17% of pixels
changed.
## Consequences
- **Every vanilla pipeline draws in the browser** with no WebGL errors. The gaps cost little: a
texture upload when clouds rebuild, a few moves per fragment in improved-transparency passes.
- **The diff found bugs nothing else had:** the End crashed twice (an empty immutable map divided by
zero; the dragon's phases lacked reflection metadata); two item pipelines never reached the
manifest; uniform ranges were too small for Mesa's layout under ANGLE.
- **The GPU matters.** Headless Chromium defaults to SwiftShader; the harness uses the real GPU via
ANGLE (`--gpu gl`). SwiftShader (`-Pscreenshots.gpu=swiftshader`, all CI has) renders correctly
but scores lower and isn't the gate.
- **Needs a display and GPU**; a full run takes about ten minutes.
- **For later:** the manifest grew 29.6 → 43.5 kB gzip (the 0-to-1 variants ~10.6 kB could load
separately). To measure on a Chromebook: cloud re-uploads, the improved-transparency targets, and
whether its GPU has EXT_clip_control.
- Read-backs (screenshots) still block on `readPixels`; async is for when something calls them per frame.
- Resource packs still can't change shaders in the browser (ADR 0007).
@@ -0,0 +1,68 @@
# ADR 0013: Sound over Web Audio, with the browser's decoder and the desktop's panning
- Status: accepted
- Date: 2026-09-28
## Context
The game's sound engine already sits on `PlatformAudio` (ADR 0005), with OpenAL on the desktop. The
browser had a silent stand-in. The game expects OpenAL's model: a listener, mono sources placed in
the world with a distance model, gain, pitch, looping, one-shot buffers and queued streams, 255
sources.
The game decodes Ogg Vorbis itself (JOrbis). On the page that would run on the only thread and cost
frames for every new sound and every second of music. Browsers decode Ogg natively, but
`decodeAudioData` decodes whole files only (70 MB of floats for a 3-minute track). And a page can't
play sound until the player clicks or presses a key.
## Decision
- **Web Audio implements `PlatformAudio`**: one `AudioContext`; each source is a small graph with a
gain per ear. **Panning comes from `Spatializer`**, plain Java that runs OpenAL Soft's own model,
not Web Audio's `PannerNode`, so each ear hears what it would on the desktop.
- **The desktop's model, measured:** `:platform-desktop:openAlReference` records OpenAL Soft's mix to
a WAV at known positions. For stereo without HRTF, each ear gets `0.5 ± 0.5·right + 0.0957·front`
of the attenuated gain (ahead 0.596 per ear, behind 0.404). `SpatializerTest` holds the browser
within 0.003.
- **The browser decodes, off the page's thread.** `PlatformAudio.decoder()` (optional) is
`decodeAudioData`. `PlatformSoundLoading` hooks the game's sound buffer library; three loader
threads decode and cache as the game would. The desktop has no decoder and keeps the game's path;
a file the browser can't decode falls back to it too.
- **Streams play compressed:** music and records go to a media element feeding the same graph
(pitch as `playbackRate`), so a track costs its file, never its decoded samples. The game's
buffer-queue path stays for anything else.
- **OpenAL semantics over one-shot nodes:** a `PlaybackClock` per source handles pause, resume,
position and looping. 255 sources, as OpenAL Soft.
- **Gains change only when needed**, smoothed over 5 ms while playing. Re-panning every frame allocates nothing.
- **Directional Audio (HRTF)** uses the browser's HRTF panner, which differs from OpenAL Soft's data set.
- **Autoplay unlock:** a small "Click or press a key to turn on sound" prompt until the first
gesture. Until then one-shot sounds are dropped (so title clicks don't pile up) and streams wait.
JavaScript callbacks only set flags; only the decoder's promise calls Java.
- **Sounds are fetched when first played:** the page writes the sound list and an empty placeholder
per sound; on first play `RemoteSounds` fetches the real file. Resource pack sounds are read normally.
- `javax.sound.sampled.AudioFormat` (description only) is in `web-classlib`.
## Deviations from the desktop
- No output limiter: loud stacks clip instead of being limited.
- No output device choice.
- Sound starts after the first click or key press, as on every web page.
- Decoded sounds take about twice the desktop's memory (32-bit floats at output rate).
- A sound's first play waits for its download.
## Alternatives rejected
- **`PannerNode`:** equal-power panning ignores front and back and makes listener-relative sounds
(UI, music) 1.5 dB louder than the desktop.
- **JOrbis in the page:** on the only thread; frames drop on every new sound.
- **WebCodecs with an Ogg demuxer:** a demuxer to maintain and patchy Vorbis support; the media
element does it natively.
- **A worker for decoding:** `decodeAudioData` is already off-thread.
- **Downloading every sound at start:** 360 MB, mostly never played.
## Consequences
- Positional sound, UI, music and records work in the browser. `audio.steps` checks the unlock and
streaming; `audio-positional.steps` matches the desktop's panning and fade within 1%.
- What needs ears (HRTF, jukeboxes, long sessions) is on the manual checklist.
- Where Safari refuses an Ogg file, the game's decoder takes over for that sound.
@@ -0,0 +1,44 @@
# ADR 0014: The loader page, the build manifest, the service worker and the asset pack
- Status: accepted; the JavaScript fallback and the manifest's `wasm`/`js` entries are superseded by
ADR 0036 (Fast and Compatible builds, manifest format 2)
- Date: 2026-09-28
## Context
The page was a stub: it fetched the whole module (29 MB gzip) every visit, showed nothing useful
while doing so, and gave no reason when a browser couldn't run it.
What a player's browser downloads falls into three groups (ADR 0001): the **build** (the module and
what's prepared at build time; contains Mojang code, so it's self-hosted, never published by the
project), **Mojang's files** (client jar, asset index, sounds), and **the page**.
## Decision
- **The page is a loader** (`index.html`, `boot.ts`): a loading screen with a progress bar and the
current step. It checks the browser (`features.ts`), reads the manifest, picks a build, registers
the service worker, downloads with byte counts, and starts the game, which reports its own steps
through `window.incariLoader`. Failures stop with a sentence the player can act on.
- **TypeScript compiled by stripping types** (Node's `stripTypeScriptTypes`, `:app-web:pageScripts`):
erasable syntax only, no bundler.
- **`build.json`** lists the game version, release flag, targets, the asset pack, and every file's
size and SHA-256. Files are requested as `name?v=<hash>`.
- **Streaming compile with progress:** the module compiles while it downloads.
- **A service worker** (`sw.ts`, `cache-policy.ts`) caches versioned build files and sounds: a
returning player downloads only what changed. The page and its starting files come from the network
with a cached fallback, so play works offline. The client jar passes through (the storage worker
keeps it). `?sw=off` unregisters it.
- **The asset pack** (`incari.pack`): build-time data for the game (shaders, later sprites and Via's
mappings), mounted read-only at `/incari-pack` like the jar. Never published.
- **Release builds:** `-Pteavm.release` (TeaVM ADVANCED, obfuscated, no debug data). Strict null
checks stay on: the game catches `NullPointerException`, and without them a null dereference traps.
- **The dev server serves the page by name**, so editing it needs no recompile.
## Consequences
- A returning player downloads only changes. On the desktop a dev build starts in ~0.7 s from a local
server; Chromebook loads wait for the device.
- Browsers without module workers run uncached, with a warning.
- The JavaScript fallback built and ran (60 fps standing, 36–44 fps in fresh terrain), but was later
dropped for the Fast and Compatible builds (ADR 0036).
- `serve`, `browserCheck`, `screenshotDiff` and `checkDownloadSize` build the page and pack too.
@@ -0,0 +1,45 @@
# ADR 0015: The background pool runs between frames, and the render thread's waits are counted
- Status: accepted
- Date: 2026-09-28
## Context
The web platform reported no background threads, so the game's worker pool ran every task inline,
usually on the render thread mid-frame. Terrain meshing resubmits itself until the backlog is empty,
so one `schedule` meshed everything before the frame went on: turning in fresh terrain gave 38 fps
with frames up to 950 ms.
This is also the audit of blocking calls: a wait on the render thread holds the frame for as long
as it lasts, and deadlocks if what it waits for can only run on the render thread.
## Decision
- **The platform may run the game's pool:** `PlatformThreads.backgroundExecutor(name)` (null on the
desktop, which keeps `ForkJoinPool`). The existing `Util.makeExecutor` hook takes it.
- **In the page the pool runs between frames** (`IdleTimeExecutor`): tasks queue; one coroutine runs
them in slots that start after the frame is drawn and end 2 ms before the next is due (at least
4 ms). A started task runs to its end. A thread waiting on a queued task waits for the next slot,
which comes even in a hidden tab (within a quarter second), so nothing deadlocks.
- **Render-thread waits are counted:** the frame monitor (`window.__incariFrames`) times each frame;
if the animation-frame callback returns before the frame ends, the render thread waited. Every
`Object.wait` is routed through `Waits`, which adds render-thread waits to the frame's total and
prints the stack of any wait ≥ 50 ms.
- **The build lists every blocking call** (`blocking.txt`), classified in
[`docs/threading.md`](../threading.md).
- **The gate:** `soak.steps`, 30 minutes on a server, fresh terrain every minute, turning full
circle; fails on any frame with ≥ 50 ms of render-thread waiting.
## Results
- **Gate passed** (2026-09-29, release build): 108,244 frames at 60 fps; longest wait total 32 ms,
no frame over 50 ms. Fixed on the way: slots that started during a short wait made it wait for a
whole task, and the frame limiter's skipped frames were counted as waits.
- Arriving in fresh terrain holds 59 fps (worst frame 50 ms); turning there 59 fps (worst 33 ms).
## Consequences
- Background work gets only the time frames leave: with full frames, the pool gets 4 ms and terrain
appears more slowly rather than frames dropping. Workers (ADR 0023) add throughput.
- Resource reloads run on the pool too, so the loading screen animates.
- The frame monitor and wait tracing stay on in every build (a timestamp per frame and per wait).
@@ -0,0 +1,61 @@
# ADR 0016: The Eagler handshake in the client, and Eagler skins
- Status: accepted
- Date: 2026-09-29
## Context
Every browser-reachable Minecraft server today is an Eagler server: EaglerXServer in front of
ordinary backends, nearly all 1.8. Its first binary message opens Eagler's own login exchange (a
vanilla handshake is closed silently); after it, the proxy logs the player in and carries vanilla
packets one per message (ADR 0009's framing). Protocol V5 accepts any Minecraft protocol number, so
the handshake belongs in the client ([`docs/eaglerxserver.md`](../eaglerxserver.md)).
Eagler servers also answer the server list with a text MOTD query and move skins in their own
messages. Gate: join a stock EaglerXServer 1.8 network with skins both ways. EaglerXServer is All
Rights Reserved: written from the wire protocol only.
## Decision
- **Every `ws://`/`wss://` server speaks Eagler.** `EaglerHandshake` sits at the pipeline's head,
below framing, and runs V5 when the channel opens. It swallows the game's handshake and Login Start
(the proxy already logged in), then answers with a Login Success in the connection's protocol
layout (and swallows Login Acknowledged from 1.20.2, holding backend packets until then). A refusal
becomes a Login Disconnect, shown as the kick reason.
- **The protocol named is the server's:** with Via above, it's the version Via translates to.
- **Eagler's own messages** (`0xEE`, bundled `0xEE 0xFF`) go to an `EaglerSession`.
- **Server list MOTD:** WebSockets gain text messages. A hook in `ServerStatusPinger.pingServer`
sends `Accept: motd` (`EaglerPings`) and fills the entry: MOTD, counts, names, and the 64×64 icon.
An Incari extension field `data.protocol` is read when present; otherwise the server is taken as 1.8.
- **Skins:** the player's own is sent at login (`skin_v2`, `cape_v1`; chosen on Edit Profile since
ADR 0029). Others' are asked for by UUID the first time they're drawn (`EaglerSkins`, a hook in
`PlayerInfo`), registered as `incari:eagler/...` textures, released on disconnect. Invalidations and
forced skins are honoured.
- **Formats** (`EaglerTextures`): skins 64×64 at 3 bytes a pixel (alpha as one bit), capes a 22×17
region plus 11 pixels. Checked byte for byte against EaglerXServer's converters with a local
program (nothing of its jar committed).
- **Presets:** Eagler's skins 0 and 1 show as Steve and Alex; the rest (Eagler's art, not shipped) as
one of the game's default skins. Preset capes (Mojang's) aren't drawn; custom capes are.
- **`tools/wsbridge` speaks Eagler** in front of a vanilla server: MOTD, V5 handshake, login over
TCP, compression, then bridging.
- **Later:** passwords, voice, cookies, redirects, capabilities.
## Alternatives rejected
- **An EaglerXServer add-on:** needs each server's operator.
- **Eagler only for marked addresses:** no WebSocket Minecraft server isn't Eagler.
- **Answering the login before the game asks:** the game's login listener isn't ready yet.
- **Drawing Eagler's preset skins:** not Incari's art to ship.
## Verified
- **Desktop** against EaglerXServer 1.1.1 on BungeeCord, in front of vanilla 1.8.9: `smokeServer`
pings, joins through Via, chats, moves, stays 20 s, reconnects. `smokeSkinA` + `smokeSkinB`: each
sees the other's exact skin, model and cape. Against the bridge: 26.3, 1.20.4, 1.12.2, 1.8.9 pass.
- **Browser:** `server-join.steps` and `version-join.steps` pass.
## Consequences
- Eagler servers show their MOTD, counts and icon; the version reads "Eagler 1.8.x" or what they name.
- `wss://` works as far as the platform's WebSocket does.
- The bridge now closes with a proper close frame (an abrupt drop showed as error 1006).
@@ -0,0 +1,57 @@
# ADR 0017: Via in the client, and choosing a server's version
- Status: accepted
- Date: 2026-09-29
## Context
The game speaks only 26.3's protocol. Players want mostly 1.8 servers (nearly every Eagler server),
then 1.12, then modern ones. ViaVersion and its companions translate packet by packet as a Netty
stage, as ViaFabricPlus does in-client. Goal: Via under TeaVM, version detection with a manual
override, and 1.8, 1.12, 1.20 and 26.3 servers joining and playing.
## Decision
- **A new module, `:via`**: Netty and Via, no game types. ViaVersion and ViaBackwards 5.12.0,
unmodified, from `repo.viaversion.com`.
- **ViaVersion covers every older server** (1.8–26.2): "a newer client on an older server" is its
job. **ViaBackwards** only for servers newer than the game, loaded on first need. **No ViaRewind**
(for old *clients* on new servers). Pre-1.8 would need ViaLegacy; left until needed.
- **The platform** (`IncariVia`): a version provider per connection. Settings live in memory (no
update checks, 1.8 idle movement packets, no rate limits); no YAML. Via starts on the first join
that needs it, on the connector thread, never blocking the network thread.
- **The pipeline** (`ViaPipeline`): `via-decoder` after "splitter", `via-encoder` after
"prepender", so compression lands correctly; the Eagler stage stays below and speaks the server's
version. `via-relay` defers packets Via releases synchronously inside the game's own write (for
pre-1.20.2 servers), which otherwise met a pipeline with no outbound protocol.
- **Choosing the version:** a "Version" button on each server's edit screen ("Auto" or a release),
saved in `servers.dat`. (How "Auto" resolves was replaced by ADR 0018: join as the game's version
and read the refusal.)
- **The server list** counts servers Via can reach as compatible.
- **In the browser:** Via compiles in like any library; its mappings (0.3 MB compressed) ride in
the asset pack. Build help: Via's bundled `TypeToken` joins `TypeCaptures`, `PipelineUtil` is
substituted, SnakeYAML is stripped, `Collections.unmodifiableSortedSet` added (probes for each).
- **Licensing is open:** Via is GPLv3 without Incari's Minecraft exception (ADR 0002). The repo
holds no Via code, and building locally distributes nothing; the project distributes no build
with Via until it's settled.
## Alternatives rejected
- **ViaLoader:** pulls in ViaLegacy, ViaBedrock and ViaAprilFools; the part needed is a hundred lines.
- **Via's YAML configs:** a parser and file writes for settings no player edits.
- **Detecting an Eagler server's version from the handshake:** V5 accepts anything; only the backend knows.
- **One Via stage for both directions:** the game's handlers aren't neighbours, and compression is
placed by the framing names.
## Verified
- **Desktop** (`smokeServer`, behind the bridge): 1.8.9, 1.12.2, 1.20.4 join through Via, chat, move,
stay 20 s, reconnect; 26.3 without Via. 1.8.9 over plain TCP too. Via starts in ~150 ms.
- **Browser** (`version-join.steps`): the same three versions and stock EaglerXServer with a 1.8.9
backend: join, chat, 20 s, kick, rejoin. Via starts in ~30 ms.
## Consequences
- A wrongly detected version gets the server's own "outdated client" message; the Version button fixes it.
- The 1.8 behaviour layer (ADR 0020) builds on the known version (`ServerConnections.lastJoinedProtocol`).
- Every packet to an older server costs Via's translation on the network thread.
@@ -0,0 +1,48 @@
# ADR 0018: "Auto" finds a server's version by joining
- Status: accepted (amended by ADR 0071: Via is off by default)
- Date: 2026-09-29
## Context
ADR 0017's "Auto" took any Eagler server that doesn't name its version as 1.8. Nothing an Eagler
server says before login names it (the MOTD has none; the handshake accepts anything), so every
non-1.8 Eagler server was joined as 1.8 and refused. BungeeCord over TCP has the same problem.
What servers do say, reliably, is why they refuse, in words: "Outdated server! I'm still on 1.8.8",
"Incompatible client! Please use 1.20.4", BungeeCord's "Kicked whilst connecting to lobby: …".
## Decision
- **"Auto" joins as**, in order: the player's choice; the version that last reached the world at
this address (`incari/learned-versions.txt`); the version the server reports; else the game's own.
- **Refusals are read** (`VersionRetry`, one hook in `DisconnectedScreen.init`): release numbers in
the text and its translation arguments map to protocols through Via. The newest version below the
refused one is tried next (older only if nothing older is named), never one already tried. Only
within a minute of connecting, only for "Auto", at most four joins.
- **A silent drop is a hint:** EaglerXServer on BungeeCord closes without a word when the proxy
can't carry the protocol. A close during the Eagler login (`droppedDuringLogin`) makes "Auto" try
1.8 next, then 1.12.2; a newer backend refuses 1.8 by name, which the next retry reads. Not
when the dropped version already reached the world at this address: a rejoin right after a kick
is often dropped while the old session lingers, and a multi-version server would accept the 1.8
guess and teach it for good (Carrotcraft). Only a refusal in words corrects a learned version.
- **Only a join that reaches the world is remembered.** A stale one is refused and corrected,
except on a server that accepts every version: a wrong one sticks there, so the drop rule above
guards it. `server-versions.txt`, which builds up to 0.1.2 could fill that way, is deleted once.
## Alternatives rejected
- **Keeping 1.8 as the Eagler default:** wrong for every non-1.8 server.
- **Probing versions in parallel:** each probe is a full login, visible to the server, and looks like an attack.
- **Trying every release newest-first:** up to fifty logins, where a refusal names the version in one.
## Consequences
- **Verified** against EaglerXServer 1.1.1 on BungeeCord: with a 1.8.9 backend, 26.3 is dropped,
"Auto" tries 1.8, joins, and remembers it. With a 1.20.4 backend, 26.3 dropped, 1.8 refused naming
1.20.4, then 1.20.4 tried.
- That last join fails outside the client: EaglerXServer 1.1.1 on BungeeCord carries protocols only
up to 1.18.2 here. Modern Eagler networks need Velocity.
- The first join to such a 1.8 server costs one dropped login (~10 s); later joins use the learned version.
- A kick message that mentions a version and a refusal word triggers a retry; the minute window
and four-join cap stop loops.
@@ -0,0 +1,67 @@
# ADR 0019: Eagler's extras: passwords, cookies, redirects, voice chat and shared worlds
- Status: accepted
- Date: 2026-09-29
## Context
Joining an Eagler server (ADR 0016) left out EaglerXServer's extras: handshake passwords, login
cookies, redirects, WebRTC voice chat, and worlds shared through a relay. Gate: voice chat and
auth-plugin servers work.
Two kinds of auth: **most Eagler servers log players in on the backend** with plugins like AuthMe
(`/login` in chat), which needs only chat and commands. **EaglerXServer's handshake auth** asks for a
password before the player reaches any server; it's in the protocol but uncommon. Neither is a
Mojang account.
EaglerXServer and Eagler's clients are All Rights Reserved: everything here is written from the wire
protocol. Local test doubles (an auth plugin, the relay jar) live under `run/` and are never committed.
## Decision
- **Handshake passwords** (`EaglerPassword`, `EaglerAuth`, `PasswordScreen`): the server names a
method and salt; the client answers `EAGLER_SHA256`, `AUTHME_SHA256`
(`hex(sha256(hex(sha256(password)) + salt))`), or plain text only after the player agrees. A
refusal for a missing password shows the password screen, which joins again (`JoinFailures`).
Passwords stay in memory for the session, by server URL; never on disk.
- **Cookies** (`EaglerCookies`): a server's cookie (≤ 255 bytes, ≤ a week) is sent with the next
login to the same URL. The server chooses whether it's saved (`incari/eagler-cookies.txt`).
- **Redirects:** a redirect to a `ws://`/`wss://` address joins it with "Auto"; others are refused.
- **Voice chat** (`EaglerVoice`, `Platform.rtc()`; browser only): the server only signals (who has
voice on, pairing, offers, answers, ICE). Each peer gets an audio transceiver up front and the mic
track is swapped in once granted, so the permission prompt never forces renegotiation. Voices play
through the game's audio context with a gain and stereo pan set each tick (proximity: linear fade
and direction; global: fixed). Push to talk on B. Voice starts off; choosing a channel shares the
microphone. Controls are in the pause menu's voice panel (ADR 0045); the HUD lists who's talking.
- **Joining shared worlds** (`incari.net.relay`, `RelayScreen`): "Shared..." on the multiplayer screen
takes a relay URL and code. `RelayJoin` negotiates a WebRTC data channel through the relay, which
becomes the game's connection with Eagler's LAN framing (`LanFraming`) and login (`LanLogin`), under
Via at 1.8, since Eaglercraft hosts are 1.8. Hosting came later (ADR 0062).
- **Capabilities** asked at login: cookies and redirects always; voice where WebRTC exists.
## Alternatives rejected
- **Storing passwords or hashes on disk:** cookies are the servers' own "remember me", and a stored
hash is as good as the password.
- **An audio element per voice with `PannerNode`:** voices share the game's context and listener,
with one gain each for mutes and fades.
- **WebRTC on the desktop:** it's the development runtime; voice and shared worlds are checked in the browser.
## Verified
- **Handshake auth** (`smokeAuth`) against EaglerXServer 1.1.1 with a local test plugin: both hashed
methods accepted, the cookie saved, and the next join logged in by cookie alone. Hashes match
independent vectors in `EaglerHandshakeTest`. Plain text is unit-tested only.
- **Voice** (`voice-talker.steps` + `voice-listener.steps`, two headless Chromiums with fake mics):
paired, connected, and the listener hears the talker. Signalling also on the desktop (`smokeVoiceA`
+ `smokeVoiceB`). Fixed on the way: the answering side now adopts the offer's transceiver.
- **Shared worlds** (`relay-join.steps`) against EaglerSPRelay and a stand-in host page: the channel
opens, the host gets the Eagler login, the client reaches the world.
## Consequences
- **In-game `/login` plugins (the common case) aren't checked yet.** They need only chat and
commands, but a check with AuthMe on the local 1.8.9 server should run before the gate counts.
- Redirects are unit-tested only; no redirecting server was at hand.
- The desktop has no voice or shared worlds; its screens say so.
- The talking indicator holds 0.6 s after the last loud moment.
@@ -0,0 +1,52 @@
# ADR 0020: The legacy behaviour layer: playing 1.8 servers as 1.8 did
- Status: accepted
- Date: 2026-09-29
## Context
Via translates packets but can't change how the client moves, aims and collides. A 1.8 server
simulates the player by 1.8's rules: sneaking under a slab, a thicker ladder or a taller lily pad
gets corrected (rubber-banding) or flagged by anticheat. And 1.8 PvP means no attack cooldown, sword
blocking, and a swing before each attack.
ViaFabricPlus is the reference, but it's GPL-3.0 without Incari's Minecraft exception, so nothing of
it is used: the behaviour is written fresh from what 1.8 does. Gate: side-by-side recordings with a
real 1.8.9 client.
## Decision
- **Everything keys off the server's version** (`LegacyRules`, from
`ServerConnections.lastJoinedProtocol`, updated once a tick). Plain static fields, cheap on hot paths.
- **Combat on 1.8** (`LegacyCombat`):
- no attack cooldown (strength always 1, no indicator);
- **sword blocking:** swords become usable like shields with the `BLOCK` animation; Via turns the
use into 1.8's block and the server halves damage. 26.3 already draws the 1.8 pose;
- the swing sent before attacking or digging;
- a 0.1 pick margin around entities.
- **Movement and poses** (`LegacyPlayer`, `LegacyMovement`): sneaking keeps a 1.8-high box with eyes
at 1.54 (1.65 high for 1.9–1.13), for every player so hitboxes match; no swimming or crawling before
1.13; on 1.8 each axis of motion under 0.005 a tick stops.
- **Block shapes on 1.8** (`LegacyShapes`, one pair of hooks in `BlockStateBase`): ladders 2/16
thick; lily pads full 1/64 squares; glass panes and bars as 1.8's arms; anvils full height, 12/16
wide; farmland a full block. Unchanged shapes aren't touched.
- **Fishing rods and bows** need nothing: the server and Via handle them.
## Alternatives rejected
- **Porting ViaFabricPlus:** its licence, and its fixes are mixins against other mappings.
- **Hooks per block class:** more hooks for the same result.
- **A `blocks_attacks` component on swords:** it's the server's, and would show in tooltips and be
sent back in creative.
## Consequences
- **Verified against a real 1.8.9 server** (`smokeLegacy`): rules follow protocol 47; pick margin
0.1; full strength after a swing; 1.54 sneak eyes; a server-placed ladder collides at 2/16; and
blocking halves an arrow as 1.8 does ((1 + d) / 2: 3.0 open, 2.0 blocking). Singleplayer and current
servers are unchanged.
- **The gate isn't met as written:** no recordings beside a real 1.8.9 client yet. Feel (knockback,
hit registration, strafing) still needs that session with a PvP player.
- Not changed yet: creative reach, red hurt armour, hurt tilt, the offhand. Each is a small hook.
- Rules are per version group: 1.9–1.13 get the sneak height (and to 1.12 no swim pose), but not
1.9's own changes.
@@ -0,0 +1,70 @@
# ADR 0021: The profiler, the benchmark and the performance gate
- Status: accepted
- Date: 2026-09-29
## Context
The goal is 60 fps at render distance 8 on a 4 GB Chromebook. Every change must show what it
did, on the same scenes, and regressions must be caught before merge. That needs an
in-game overlay, a fixed benchmark world with scripted scenes, a runner for real Chromebooks, and a
CI report per pull request that fails on regressions.
## Decision
### Measuring a frame
- **The game's own profiler zones are the timers.** One hook (`Minecraft.run`) wraps the game's
`ProfilerFiller` with Incari's `FrameProfiler` while collecting; it times the two outer zone levels
and allocates nothing. Nothing collecting: the frame is untouched.
- **Split:** *tick*, *extract* (`update`, `extract`), *render* (handing the frame to the backend:
every WebGL call), and *GPU*.
- **GPU time** from EXT_disjoint_timer_query_webgl2 (`GpuTimer`), a frame or two late; unknown (not
zero) without the extension. The backend also counts draws, terrain draws and sections
(`GpuFrameStats`). The desktop's Mojang backends report these as unknown.
- **`PlatformProfiling`:** memory (JVM heap on the desktop; JavaScript heap and linear memory in the
browser), each frame, and start-up marks. The page keeps the last 16384 frames in
`window.__incariFrames`.
- **1% low** is the frame rate over the slowest 1% of frames (their mean), so stutters show.
### The overlay
F9 (rebindable) or `?overlay`: FPS and 1% low, the frame split, draws, mesh queue, memory, GC, and a
frame-time graph. Text rebuilt 4x a second.
### The benchmark (`./gradlew :app-web:benchmark`)
- **Fixed world:** the screenshot harness's server, fixed seed, time and spawning stopped, every
chunk pre-generated so scenes measure client loading.
- **Scripted scenes** (`benchmark.txt`): the player spectates an armor stand the server moves.
`flythrough` (55 s east at 11 blocks/s over unseen terrain), `combat` (golems vs raiders, 40 s).
- **Loads:** cold start (cleared origin), warm start, join.
- **Figures** (`FrameStats`, `GcStats`): FPS, 1% low, p99 frame, tick/extract/render/GPU, draws,
sections, mesh queue, memory, GC pauses from a DevTools trace. Chromium runs with precise memory info.
- **Gate** (`PerfBaseline`, `baseline.properties`): per machine, per figure, a direction and an
allowed worsening (percentage *and* absolute). Past it fails. `-Pbenchmark.updateBaseline` records.
- **Report:** Markdown and JSON, plus history in `~/.incari/benchmark-history.jsonl` and trend charts.
### Real Chromebooks
The runner drives any Chrome over DevTools (`--connect`), serving the page from this machine
(`--page-host`). A Chromebook in developer mode exposes remote debugging through SSH
([`docs/benchmark.md`](../benchmark.md)). No Playwright: it uses the same protocol and can't drive a
stock Chromebook either, and `tools/webbuild` already has a DevTools client.
### Every pull request
Hosted runners can't compile the browser build (20 GB heap) and their software GPU gives meaningless
times, so CI's `perf` job runs on a self-hosted runner labelled `incari-perf` once
`INCARI_PERF_RUNNER` is set. It compiles, measures, and writes the report to the job summary; a
regression fails. Nothing is uploaded. Never for fork pull requests.
## Consequences
- Two three-line hooks (`Minecraft.run`, `Gui`); the rest is `incari.client.profiler` and
`incari.platform.api.profile`.
- Figures are per machine. Until a Chromebook is recorded, the gate protects the desktop's figures:
it catches regressions in work done, not the floor device's margins.
- On SwiftShader GPU time is unknown, but draw counts still gate.
- Players pay nothing until they press F9.
- The CI job waits for someone to register the runner.
@@ -0,0 +1,59 @@
# ADR 0022: Terrain in a few multi-draws a frame
- Status: accepted
- Date: 2026-09-29
## Context
Every WebGL call crosses from WebAssembly into JavaScript and is validated; on a Chromebook that
overhead, not the GPU, limits drawing. Terrain is most draws: each section's layer cost about eight
WebGL calls (uniforms, re-pointing attributes because WebGL2 has no base vertex, the index buffer,
the draw).
The 26.x renderer already keeps sections in shared heaps (`UberGpuBuffer`), culls with the occlusion
graph, groups by layer and heap, and on capable devices submits each group as one indirect draw with
per-instance section data. WebGL2 lacks indirect draws, base vertex and base instance, but has
`WEBGL_multi_draw` (many ranges in one call, told apart by `gl_DrawID`).
## Decision
- **Claim indirect multi-draws and base instance where `WEBGL_multi_draw` exists**, so the game takes
its indirect terrain path. `?multidraw=off` turns it off.
- **Run indirect draws from the game's copy of the command buffer** (every buffer has one, ADR 0007).
- **Base vertex goes into the indices:** the backend keeps a 32-bit quad index pattern
(`QuadIndices`) where quad `v / 4` already counts from vertex `v`, so a section draws from an
offset with no base vertex. A heap is one `multiDrawElementsWEBGL`; sections at a vertex not a
multiple of four take one extra call per remainder. At most four calls per heap's layer.
- **Base instance becomes `gl_DrawID`:** terrain vertex shaders are rewritten to read per-section
data (16 bytes) from row `gl_DrawID` of a uniform block (`DrawIdRewrite`), filled per batch from a
ring (`DrawRows`).
- **Translucent indices are rebased and kept** (`RebasedIndices`): each sorted section's indices are
copied with the base vertex added, and kept until the game re-sorts it (tracked per 4 KiB page).
Copying them every frame had cost more than it saved.
## Results
Desktop, render distance 8, three alternating runs each:
| | Fly-through off | on | Combat off | on |
| --- | ---: | ---: | ---: | ---: |
| Terrain draw calls | 553 | 9 | 513 | 9 |
| All draw calls | 629 | 85 | 591 | 87 |
| Render submit (ms) | 1.2 | 1.1 | 1.6 | 1.1 |
Terrain calls fell ~60x, past the tenfold target. The desktop holds 60 fps either way; render submit
falls a third in combat. On a Chromebook, where calls cost more, that's what matters.
Found on the way: a TeaVM heap bug (whole-page allocation after an exactly full heap) fixed in
`tools/teavm-patches`; and new typed-array views per multi-draw caused 290–370 ms GCs until views
were kept.
## Consequences
- The quad index buffer costs 24 bytes per quad of the fullest heap (a fifth of the vertices).
- Per-section uniform rebinding and attribute re-pointing are gone.
- Re-sorted translucent sections are copied again when they change (a handful a frame in water).
- Without `WEBGL_multi_draw`, terrain draws as before.
- This relies on how the game draws terrain (indirect only for terrain, one instance each, the quad
pattern). Pipelines that break it skip their draws and say so; a changed pattern falls back to a
draw per section.
@@ -0,0 +1,76 @@
# ADR 0023: Terrain meshed in Web Workers by Incari's own mesher
- Status: accepted
- Date: 2026-09-30
## Context
Meshing terrain (`SectionCompiler.compile`: models, culling, light, fluids, visibility, translucent
sorting) is the game's heaviest recurring job. In the page it runs between frames (ADR 0015), so
terrain gets only the time frames leave; the fly-through's 1% low was 31 fps because of it.
The plan: a small WebAssembly mesher in a worker pool, flat snapshots in a
`SharedArrayBuffer` (or transferred buffers), a compact vertex format, and sorting in the worker.
Gate: no meshing on the main thread, no chunk-load stutter. The catch: a worker can't touch game
objects, and the picture must not change.
## Decision
### An exact mesher of Incari's own
- **`:mesher`** has no dependencies. A `Snapshot` (block ids, light, tints, per-position shapes for a
section and two blocks around it) plus `MeshTables` (every state and model) go into `SectionMesher`,
which writes exactly what the game's compiler writes: culling and skip rules, smooth or flat
lighting with the game's quirks, tints, emission, fluids, visibility, sorted translucency. Written
fresh, not copied.
- **Tables are read from the game, never assumed** (`MeshTableExport`): flags, light, shapes, skip
rules, fluid heights, plant offsets and every baked quad. How a model picks parts is discovered by
running it with a recording random source. States that don't fit are marked unsupported (none in
26.3). The mesher's copies of the game's hash, random and table trig are checked against the game's.
- **Checked byte for byte:** `-Dincari.mesher=verify` meshes every section both ways; `smokeMesher`
covers ten overworld places, the Nether, the End and the debug world, with smooth lighting and
cutout leaves on and off: 17,763 sections, none different.
### In the page
- **Compiled alone:** `mesher.wasm` (~120 KB, 123 classes), run in one worker per core but one, up to four.
- **Messages are bytes:** tables once (~11 MB), a ~25 KB snapshot per compile, centers per re-sort.
Copied through a `SharedArrayBuffer` slot when cross-origin isolated, else a transferred
`ArrayBuffer`. The answer goes straight into the section's buffer pack.
- **The game's dispatcher is unchanged:** hooks in compile and re-sort call `Meshing`. A mesh the
render thread needs at once (a block the player changed) is meshed in place by the same mesher.
- **Several meshes in flight:** a pool task waiting for a worker steps aside so another can run
(`IdleTimeExecutor.awaitOutside`). Buffer packs start at 64 KB, not 8.8 MB.
- **Snapshots never hold up a frame:** filling one takes 5–10 ms, so it calls
`PlatformThreads.pauseIfLate()` per layer and resumes in the next slot.
- **Slots end before the next frame:** the slot deadline only learns from frame steps near one
interval (skipped frames had pulled it toward 33 ms).
- **Compact vertices:** 16 bytes instead of 28 (position and light in four shorts, colour, UVs in two
shorts exact for power-of-two atlases). `TerrainVertexFormat` and `CompactTerrainRewrite` decode
them in the shaders. The desktop keeps the game's format.
- **Options:** `?mesher=inline` (on the page's thread), `?mesher=vanilla` (the game's compiler),
`?mesher=verify`.
## Results
Fly-through, desktop, vs `?mesher=vanilla`:
| | Workers | Game's compiler |
| --- | ---: | ---: |
| 1% low | 38–41 fps | 31.9 fps |
| p99 frame | 21.6–24.5 ms | 28.3 ms |
| Mesh queue, mean | 6.2 | 9.8 |
| Linear memory peak | 565 MB | 657 MB |
| Slowest frames' pool work between frames | ~1 ms | 25.2 ms |
What's left in the slowest frames is the game's tick (chunk packets, light), as in combat, which
loads no terrain.
## Consequences
- Meshing leaves the main thread; only copying the snapshot and the finished mesh stays.
- The mesher follows the game: changes in a new version show up in `smokeMesher`, and the arithmetic
check fails loudly.
- Building the tables takes ~2 s in the page per world or reload: joins take about a second longer
(until ADR 0032 kept them).
- The desktop meshes with the game's compiler unless asked (`-Dincari.mesher=incari`).
@@ -0,0 +1,68 @@
# ADR 0024: Entities, particles and text
- Status: accepted
- Date: 2026-09-30
## Context
A crowded lobby is where browser clients fall apart. The plan: entity occlusion culling,
instanced entity models, batched text, GUI and signs, and pooled, capped particles, gated on a
crowded-lobby benchmark.
The new `lobby` scenario: 80 armored mannequins with names, 24 hologram armor stands, 12 text
displays, 30 dropped items, signs, a sidebar, a boss bar and three particle fountains, from an
orbiting camera. Before this work its profile was mostly particles (~7 of 16 busy seconds), then text
(1.4 s), entity models (1.3 s) and entity ticks.
The 26.x renderer already batches draws (one staged buffer, one range per render type; the GUI merges
elements). What's left is CPU work per vertex, glyph and particle, and entities drawn nobody can see.
## Decision
- **Entity occlusion culling** (`EntityOcclusion`): skip an entity in the frustum if none of the
sections its box touches was reached by the terrain occlusion graph. Never culled: players,
glowing entities, visible names, text displays, leashed entities, the camera's entity. A few array
lookups, no allocation. `?entityculling=off`.
- **Instanced entity models** (`ModelBatches`, page only, `?instancing=off`):
- A model's cubes are baked once into a vertex buffer (`ModelMesh`).
- Per instance the CPU runs `setupAnim` and walks the part tree with the game's own transforms:
one matrix per part (hidden parts collapse to zero).
- One instanced draw per render type and model; rows in a 1024-row uniform block.
- A copy of the entity pipeline whose vertex shader the backend rewrites to apply the part
transform (`EntityInstanceRewrite`).
- Only solid-phase models with the entity shader; translucent, outlined, crumbling or remapped
(armor trims) models go the game's way. `ModelMeshTest` checks the arithmetic.
- **Text, GUI and signs:** the game's batching stays. `VertexMath` overrides `BufferBuilder`'s pose
transforms with the same arithmetic minus the per-vertex vector allocation: bit-identical.
- **Particles:**
- **Caps per tier** (`ParticleBudget`): 2048 / 8192 / 16384 (Potato / Standard / High), with the
game's admission curve scaled (all admitted until three quarters full). `?particles=`.
- **No per-particle allocation:** the camera rotation is reused, turned corners are kept while the
rotation holds, and light is read once per block per frame (`ParticleScratch`, `ParticleQuads`,
`ParticleLight`). Bit-identical.
## Results
Desktop:
| | Before | After |
| --- | ---: | ---: |
| Lobby 1% low | 40.2 fps | 38.4–44.6 fps |
| Lobby p99 frame | 22.9 ms | 21.9 ms |
| Lobby extract / render submit | 2.0 / 3.4 ms | 1.9 / 2.4 ms |
| Combat extract + render submit | 2.1 ms | 1.4 ms |
| Lobby particle CPU (41 s profile) | 5.07 s | 4.18 s |
The desktop holds 60 fps either way; the floor device is where this should show.
- Instancing takes armor (and mobs, armor stands in play). The mannequins' bodies stay the game's:
skins are translucent with a texture each (taken later by ADR 0027's opaque skins).
- Culling saves nothing in the lobby (everything is in sight); it's for ordinary play.
## Consequences
- An entity hidden behind terrain costs nothing to extract, animate or draw.
- New or changed models need nothing: meshes are baked from the game's parts on first draw.
- If a game version changes the entity shader's `Position` or `Normal` inputs, the instanced copy
fails to compile and those models fall back to the game's way: slower, never missing.
- Particle tiers change what's seen only past three quarters of a group's cap.
@@ -0,0 +1,74 @@
# ADR 0025: The memory diet
- Status: accepted
- Date: 2026-10-01
## Context
A 4 GB Chromebook gives a tab far less than the 1–2 GB the client uses on a desktop, and running
out kills the tab. Done when the benchmark's heap is under budget with no GC pause over 16 ms.
There was no heap budget yet, and the benchmark only reported peaks (which include uncollected
garbage). Measured first on the desktop: **1016 MB live JavaScript heap at the title screen**, ~1.1 GB
in a world, and 565 MB of linear memory. The desktop JVM holds 250 MB at the same title screen.
## Decision
### Measuring
- **Live figures:** after the title screen and each scenario, the benchmark forces a GC and reads the
JavaScript heap (`heapLiveMB`) and linear memory in use (`nativeLiveMB`, counted by `Heap`).
- **What holds memory:** `-Pbenchmark.heapProfile`, `-Pbenchmark.heapSnapshot`, and
`-Pbenchmark.desktopJfr`, which plays the scenarios on the desktop under Flight Recorder to see
allocation sites (the browser's tools can't see inside WebAssembly).
- **Budgets** (`budgets.properties`): absolute limits; over budget fails regardless of baseline.
Memory budgets apply to every machine.
- **Measure the release build**, which players get (a dev build also holds 92 MB of TeaVM's deobfuscator).
### Where memory went
| Change | What |
| --- | --- |
| Data fixer built only when needed (`incari.client.datafix`) | The game builds every schema since 2013 at start-up, plus a discarded development check. The page passes current data through a stand-in and builds the real fixer only for old data. Most of the title-screen heap, and 2.1 s of start-up |
| Terrain heaps sized by tier (`TerrainHeaps`) | The game reserves 128 MB vertex + 32 MB index heaps per layer and 98 MB of staging: 540 MB of GPU memory, mirrored in linear memory. Now 32/8 MB at Standard (16/4 at Potato), staging 16 MB; a full heap gets another, costing one more multi-draw |
| Draw-only buffers keep no copy (`WebGl2Buffer`) | Large, never-mapped vertex buffers write straight to WebGL. A read-back still works, with a warning |
| Block states share equal data (`BlockStateSharing`) | Occlusion face arrays and sturdy-face tables are interned (a few hundred kinds among 35,000 states). `BlockStateSharingTest` checks every state |
| Decoded sounds budgeted (`DecodedSoundBudget`) | 16 / 32 / 96 MB by tier; the oldest leave the cache and decode again when replayed |
| Atlases capped by tier (`AtlasBudget`) | 2048 / 4096 / GPU limit. An atlas that doesn't fit halves its sprites' resolution (alpha-weighted) until it does. Vanilla fits every tier |
| `DeviceTier` | One setting for all the budgets above and the particle cap. The page takes Standard (or `?tier=`); the desktop High |
Found on the way: TeaVM's unmodifiable collections scanned every element, making model loading
quadratic (fixed in `TCollections`).
### Allocations in hot paths
GC counts showed where (the lobby collected 8x a second) and desktop JFR showed what:
- **World text laid out every frame** → `TextLayouts` caches up to 2048 layouts keyed by content,
style and position (not obfuscated text). `TextLayoutsTest`.
- **Five vectors per item quad** → `VertexMath` writes with two reused vectors, bit-identical (`VertexMathTest`).
- **`ChunkSectionLayer.values()` copied per section per frame** → one shared array.
The lobby's render thread allocated 37 GB over 40 s before, 23 GB after. What's left would mean
restructuring the game's renderer, and causes no long pauses.
## Results
Desktop, release build, 2026-10-01, live figures after a forced GC:
| | Before | After |
| --- | ---: | ---: |
| JavaScript heap, title screen | 1016 MB | 255–265 MB |
| JavaScript heap, in a world | ~1.1 GB | 337–356 MB |
| Linear memory, peak | 565 MB | 74 MB |
| Longest GC pause | 5.2–7.3 ms | 1.8–5.5 ms |
Every scenario still runs at ~60 fps and within budget. Screenshot diffs 14/14.
## Consequences
- Memory budgets are enforced: over 320 MB live at the title, 420 MB in a world, 128 MB of linear
memory, or a 16 ms GC pause fails `:app-web:benchmark`.
- An old world or options file pays to build the data fixer when first read.
- A draw-only buffer read back logs a warning: a new caller to look at.
- The Chromebook's heap should match; its pauses and times wait for the device.
@@ -0,0 +1,70 @@
# ADR 0026: Start-up
- Status: accepted
- Date: 2026-10-01
## Context
The plan: pre-build what can be pre-built, cache processed state, stream the compile, defer what the
title screen doesn't need. Done when a warm start hits a time budget (set here, since none had been set
without the Chromebook).
Measured first (desktop, development build): cold start 10.5 s, warm 8.7 s. The warm start's profile
(`-Pbenchmark.profile` now records one):
| What | Time |
| --- | ---: |
| Data fixer (removed by ADR 0025) | 2.1 s + GC |
| Loading screen fade after everything loaded | 2.0 s |
| Block state definitions and models | 1.5 s |
| Bootstrap: block state shape caches | 1.1 s |
| Atlases: decode, stitch, mip | 0.6 s |
| Model discovery lookups (TeaVM scanned maps) | 0.27 s |
| Copying the module through the loader's byte counter | 0.25 s |
| Interface type checks over long tag-range lists | 0.24 s |
The benchmark now splits a warm start: to the first frame, to the end of the first reload, and the fade.
## Decision
- **Models load after the title screen** (`DeferredModels`): the first resource reload skips the
model manager and entity/block-entity dispatchers; a second reload runs them once the title is up.
Joining while they load shows "Loading Minecraft" until done. A later reload runs everything
together, as the game does. Page only (`-Pincari.browserStartup` tries it on the desktop).
- **Vanilla sprites decoded at build time** (`tools/sprites`, `SpriteCache`): 3142 sprites with their
mip levels, ~1.06 MB in the asset pack, kept in OPFS. The page uses them instead of decoding PNGs;
pack and animated sprites go the game's way. `SpritesTest` compares every byte.
- **Block state answers once per shape** (`BlockStateSharing`): support answers depend only on the
shape, which most of the 35,000 states share. A build-time registry snapshot would have to rebuild
`VoxelShape` identities, for less gain.
- **No copy through the loader:** a module the service worker already has goes straight to the
browser's compiler instead of through a byte-counting stream.
- **Faster fade** (`LoadingFade`): half a second, not two.
- **TeaVM fixes:** unmodifiable collections ask the wrapped collection (`TCollections`); interface
type checks binary-search their tag ranges (`WasmGCSupertypeFunctionGenerator`).
Not done: **pre-built baked models**. Models no longer delay the title, and serializing the model
graphs would need a format kept in step with every game version, to save time a join mostly spends
on the network.
## Results
Desktop, 2026-10-01 (before: development build; after: release build, now what's measured):
| | Before | After |
| --- | ---: | ---: |
| Warm start to title | 8.7 s | 2.1 s (first frame 1.1 s, reload done 1.6 s) |
| Cold start to title | 10.5 s | 2.9 s |
| Join the benchmark server | 11.4 s | 5.1 s |
Desktop budgets (3.0 s warm, 4.5 s cold) hold; the Chromebook's (10 s, 20 s) are estimates.
The pre-built sprites first drew blocks blank: TeaVM's absolute `ByteBuffer.put` copied nothing when
the source had no `remaining()`. Fixed in `TByteBuffer`; screenshot diffs 14/14 again.
## Consequences
- The first join after start-up may wait for models. `?models=now` and `?sprites=off` turn the two
changes off to compare.
- `sprites.bin` is rebuilt with the game; a stale or missing copy costs time, not correctness.
- The Chromebook's time budgets wait for the device.
@@ -0,0 +1,73 @@
# ADR 0027: Performance follow-ups: the compile, the backend's calls, and the game's own costs
- Status: accepted
- Date: 2026-10-01
## Context
After ADRs 0021–0026 the desktop holds 60 fps everywhere, but a 4 GB Chromebook has about a fifth of its
single-thread speed and a GPU 30–60x slower. A review of profiles and code found costs nothing
had covered yet: in the compile, the WebGL2 backend's calls, and the game's own logic. Every change is
exact and has an off switch.
## Decision
| Area | Change | Off switch |
| --- | --- | --- |
| Compile | JOML's `HAS_Math_fma` is a constant `false` (as on the desktop), so `Math.fma` folds and inlines. It was the lobby's top self time (5.6%) | — |
| Compile | Fewer coroutines: untimed queue `offer`/`poll` no longer count as blocking; two always-complete `join()`s became `resultNow()`; a `forEach` became a loop | — |
| Backend | Uniform writes are uploaded once per buffer range before the next draw (`PendingUploads`) | `?uniforms=each` |
| Backend | Quad draws read the backend's quad indices from `vertexOffset / 4`, so attributes stay bound | `?rebase=off` |
| Backend | Re-sorted translucent indices are copied in place, not appended | — |
| Backend | Uploads use kept views of linear memory, not a new typed array each (`Staging`, `WebWorkerPool`) | — |
| Game | Translucent quads sorted by radix sort, same permutation as the game's stable sort (`QuadSort`) | `?sort=game` |
| Game | Snapshots read light a section at a time (`SnapshotLight`) | `-Dincari.mesher.lightByBlock` |
| Game | Biome tints reuse the row's previous samples, bit-exact (`TintBlend`, page only) | `?tint=game` |
| Instancing | Plain items drawn instanced (`ModelBatches.takeItem`) | `?items=game` |
| Instancing | Skins with all-or-nothing alpha and an opaque tint draw in the solid phase, so instancing takes them (`OpaqueSkins`, page only) | `?skins=game` |
Why some of these matter:
- **The upload views:** TeaVM wraps each JavaScript object that reaches Java in a `WeakMap`. Thousands
of per-upload views piled up as ephemerons, and some GC pauses spent 33–36 ms marking them. Now
≤ 0.2 ms.
- **Opaque skins:** a texture with no partial alpha never blends, so drawing it before translucent
models gives the same picture (only exactly equal depths could differ).
- **Coroutines:** the hot-method list didn't shrink. TeaVM's flow analysis merges everything through
shared library code, so a blocking thread body makes every `Runnable.run` a coroutine. `async.txt`
now opens with a per-package coroutine count. The real fix needs TeaVM changes (later: the Fast
build, ADR 0036).
**Tools:** `-Pbenchmark.cpuThrottle=<n>` (a CPU stand-in for a Chromebook) and
`-Pbenchmark.gcTrace` (collector events per scenario).
## Not done
- **Skipping ambient-particle biome lookups outside the Nether:** exact and cut the tick 30–40%,
but the page allocating less triggered V8's memory reducer: heap-shrinking pauses of 11–26 ms.
Left out (ADR 0031 later did it differently).
- **The integrated server in a worker:** its own piece of work (later ADR 0039).
## Results
Development desktop, release build, 2026-10-01 (it holds 60 fps either way):
| | Before | After |
| --- | ---: | ---: |
| Lobby render submit (ms) | 9.9 | 8.4 |
| Lobby p99 frame (ms) | 22.9 | 21.7 |
| Fly-through longest GC pause (ms) | 5.5 | 3.5–8.8 |
| Fly-through live heap (MB) | 350 | 356 |
Items and skins instanced, lobby: render submit 8.4 → 6.5 ms, draws 132 → 97.
`async.txt`: 63% of reachable methods compile as coroutines. Correctness: screenshot diffs 14/14,
`smokeMesher` (18,060 sections) clean, `QuadSortTest`, `TintBlendTest`.
## Consequences
- Six more vendor patches.
- The coroutine count is worth guarding.
- `TintBlend` trusts that biome changes invalidate the game's tint caches (true in 26.3).
- A JavaScript object handed to Java on a hot path costs a weak-map entry: keep views, as
`Staging`, `DrawRows` and `WebWorkerPool` do.
@@ -0,0 +1,37 @@
# ADR 0028: The web folder (`./incari build`)
- Status: accepted
- Date: 2026-10-01
## Context
The goal: `incari build` writes a web folder and an offline HTML file, on Windows, macOS and
Linux. Until now a build ran only through the localhost dev server.
Every build contains Mojang's code, so the project never publishes one (ADR 0001, 0014). Once the
source is public, people will build anyway. They need a supported way to host their own build, and
a plain statement, wherever builds are seen, that they mustn't be shared.
## Decision
- **`./incari build [--out <dir>] [--only fast|compatible] [--no-sounds]`** (`WebBuild`) fetches
sounds if missing, compiles the release builds, and runs `:app-web:webFolder`. Default output
`dist/web/` (ignored). An output git would track is refused.
- **`WebFolder`** copies only what the page fetches (build files, page, manifest, pack, the jar's
resources, sounds) and writes its own `build.json` over exactly those.
- **It only replaces what it wrote** (`.incari-web-folder` marker); a folder with other files is refused.
- **The notice travels with the build:** `README.txt` starts "DO NOT SHARE, UPLOAD OR PUBLISH THIS
FOLDER" and explains why; `./incari build` prints it; [`docs/self-hosting.md`](../self-hosting.md)
is the project's statement.
- **Server set-up is documented, not required:** relative URLs; `.htaccess` for Apache, nginx and
Caddy snippets in `README.txt`. Without isolation headers, workers copy instead of sharing; over
plain HTTP, no service worker and IndexedDB storage.
(The original `--js` option went with the JavaScript fallback, ADR 0036.)
## Consequences
- A release build replaces the development one in `app-web/build/`.
- The offline HTML file came later (ADR 0057).
- Via's licensing question (ADR 0002) is unchanged: hosting your own build is easier; publishing
one stays forbidden.
@@ -0,0 +1,34 @@
# ADR 0029: Edit Profile
- Status: accepted
- Date: 2026-10-01
## Context
Eagler clients open an "Edit Profile" screen at load: a username, a skin from a dropdown beside a
preview, Add Skin and Clear List, and a Capes link. Eagler players know it, and nearly every Eagler
server is offline-mode, so that name is the player's identity. Incari took the name only from the
launch (`?name=`, `--username`), and skins from a bare "Eagler Skin..." screen.
## Decision
- **The name is answered at `Minecraft.getUser`** (one hook, `PlayerName`), so the login, Eagler
handshake, singleplayer, relay and voice all use it, with the matching offline UUID. Only offline
launches; a real account keeps its name.
- **3–16 letters, digits or underscores**, as Eagler requires; Done stays off until valid. Kept in
`incari/profile.properties`.
- **The screen opens at start-up** after the game's first-run screens, unless the entry point names
the player (`?name=`, `?server=`, tests, `-Pincari.username`). The web suggests `Player` + three
digits. Reopened from a title-screen link or the skin customisation screen. Locked in a world.
- **Skin list:** the game's nine default skins in both models, then the player's added PNGs
(`incari/skin/library/`; slim or wide read from the image). Add Skin uses the file picker, Clear
List removes added ones, the cape has its own screen. "Eagler Skin..." is gone.
- **Your own skin shows everywhere**, singleplayer and vanilla servers included.
- **The preview is vanilla's `PlayerSkinWidget`** (draggable); in the browser it shows "..." until
models load after the title (ADR 0026).
## Consequences
- Three new hooks plus one retargeted.
- A different name is a different offline UUID, so singleplayer inventories are per name.
- Not done: Eagler's profile Import/Export, and a cape on the preview.
@@ -0,0 +1,86 @@
# ADR 0030: Ideas from the Java optimization mods: draw lists, facing culling, sprite animation
- Status: accepted
- Date: 2026-10-02
## Context
The floor device has about a fifth of the desktop's CPU and a GPU 30–60x slower. We surveyed the
Java optimization mods (Sodium, Lithium, ImmediatelyFast, FerriteCore, ModernFix, EntityCulling,
MoreCulling, Exordium, Enhanced Block Entities) for ideas not yet taken. Their licenses
rule out their code, so everything here is written fresh from what each mod does.
Flight Recorder on the desktop showed the render thread spending 65% of the fly-through (21% of
combat) rebuilding the terrain draw list every frame, a third of that in hash lookups. And the
blocks atlas animates ~41 sprites a tick into 5 mip levels: ~67 draws a frame, where the whole
fly-through frame was 80.
## Decision
Six changes, each with a page option that restores the game's way. The first four draw exactly the
game's picture; the HUD texture and meshed chests differ slightly, which was accepted.
| Change | Idea from | Off switch | Exact? |
| --- | --- | --- | --- |
| Terrain draw list kept between frames | Sodium | `?drawlists=game` | Yes |
| Back-facing quad runs left out | Sodium | `?faces=all` | Yes |
| Only visible animated sprites redrawn | Sodium | `?animations=all` | Yes |
| No threading checks on one thread | Lithium | — | Yes |
| HUD kept in a texture between refreshes | Exordium | `?hud=live` | Rounds one 8-bit step; lags ≤ one refresh |
| Closed chests meshed into terrain | Enhanced Block Entities | `?chests=game` | Shading within one step; mipmapped; no break cracks |
- **Draw lists** (`SectionDraws`, `TerrainDrawLists`): each section mesh keeps its draws per layer,
re-read only when `UberGpuBuffer` moves its allocation. The frame's list is written straight into
two reused buffers, same groups and order as the game's, with no object per section. The desktop
uses it too.
- **Facing culling** (`incari.mesher.Facings`): the mesher groups solid and cutout quads by the
axis-aligned direction they face (others unassigned). The draw list skips runs the camera can't
see the front of (with a 3-block margin) and merges neighbours. The pipelines cull back faces
anyway, so the picture is identical. `smokeMesher` checks the grouping (18,120 sections, none differ).
- **Animated sprites** (`AnimatedSprites`): meshes record which animated sprites they use; anything
else that draws one notes it. Every animation still ticks, but only sprites drawn this or last
frame get new frames. A sprite coming back into view is caught up before terrain draws. When
terrain's sprites are unknown, everything animates as in the game.
- **Threading checks:** `ThreadingDetector`'s lock and semaphore are skipped where
`PlatformThreads.oneThread()` (the page): one thread can't race itself.
- **HUD texture** (`HudCache`): with no screen open, the camera overlays and crosshair stay live;
everything above them is drawn into a texture every 50 ms (Standard) or 66 ms (Potato), never at
High, and blended over each frame. It only kicks in while frames come faster than refreshes
(otherwise it would only add a pass). Between refreshes, nothing above the split is extracted.
- **Chests** (`ChestBaking`): a chest closed now and last tick is posed by its own renderer and its
quads are written into the section's cutout layer; the game no longer draws it as a block
entity. Chest textures join the blocks atlas; directional entity lighting is baked into vertex
colour. Opening re-meshes the section without it; it's meshed back 11 ticks after closing. Page only.
`?drawcensus` logs each pipeline's draws every 600 frames; that's how the animations' share was found.
## Results
Development desktop, release build, 2026-10-02. Draws a frame:
| | Off | On |
| --- | ---: | ---: |
| Fly-through | 80 | 18.5 |
| Combat | 84 | 17.8 |
| Lobby (CPU ÷4) | 238 | 31 |
- Unthrottled: render submit 0.88–0.90 ms vs 0.94–2.21 off; GPU 0.60 vs 0.72 ms.
- CPU throttled 4x: fly-through tick 2.9 vs 3.1 ms, GPU 0.50 vs 0.57; combat GPU 0.51 vs 0.77; lobby
tick 13.9 vs 15.5. FPS within noise: WebGL calls are cheap on the desktop. The floor device,
where each call and the GPU cost more, should gain most.
- HUD texture in the lobby: extract 2.1 vs 2.2 ms, draws 27 vs 29. At 17 fps (throttled) it steps
aside as designed.
- Correctness: screenshot diffs 15/15 (HUD 0.9971, chest scene 0.9996), `smokeMesher` clean.
## Not done
- **Lithium's skip of ambient particles where no biome adds any:** knowing that needs the biome
lookup it would save (done differently in ADR 0031).
## Consequences
- Five more vendor patches.
- A path that moves a terrain allocation without `UberGpuBuffer` would leave a stale draw.
- Mesh tables are encoding version 2.
- `?drawlists=game` also turns off animation culling.
- A chest lid that opens without its block event (none in 26.3) would stay drawn shut until re-meshed.
@@ -0,0 +1,76 @@
# ADR 0031: What the floor stand-in's profiles found: items, ambient particles, glyphs, tints, indices
- Status: accepted
- Date: 2026-10-03
## Context
Until now every performance figure came from the desktop with its CPU throttled. With no Chromebook to
hand, an old laptop now stands in (`laptop-floor`: i5-8250U held to 2 cores at 2.8 GHz, UHD 620,
Chromium capped at 3 GB with zram; [`docs/benchmark.md`](../benchmark.md)). It's closer to the floor
device than anything before, but still faster.
Before this ADR it held 60 fps in the fly-through and combat (1% lows 11–26 fps) and 21 fps in the
lobby (tick 10, extract 9, render submit 26, GPU 18 ms). Profiles of a release build with Java names
found, in the lobby: items written vertex by vertex 15%, glyph vertices 13%, ambient particle
sampling 10%. In the fly-through: section snapshots 15% (half biome lookups for tints), rebasing
translucent indices 7.5%. The slowest frames were catch-up ticks spent on ambient particles.
## Decision
Eight exact changes (the game's picture, byte-identical where vertices), each but the index copy
with an off switch, plus three tools.
| Change | What | Off switch |
| --- | --- | --- |
| Generated items instanced | ADR 0027 missed flat items: every layer's quads carry a tint index. Now an item whose quads share one tint index is instanced with that layer's colour (`ModelBatches`) | `?items=game` |
| Ambient particles per biome a tick | Of the attribute's layers, only the biome's reads the position, so the value is kept per biome per tick (`AmbientParticles`). Biomes are still looked up per position | `?ambient=game` |
| A glyph quad in one call | `GlyphQuads` writes a glyph's four vertices straight into place for the two world-text formats, same FMA order, same bytes (`GlyphQuadsTest`) | `?glyphs=game` |
| Blank sign lines skipped | `SignLines`: a blank line draws nothing anyway | `?signs=game` |
| Tint biomes kept by position | An 8192-slot table, dropped when the client's biomes may change | `?tint=game` |
| Direct index copies | `RebasedIndices` uses straight linear-memory loads/stores, ranges checked once | — |
| Occlusion graph rebuild paced | `GraphUpdates` checks the clock every 64 nodes and yields at the slot's end, so a 37–41 ms rebuild no longer overruns a frame | `?graph=game` |
| Particle light kept | `ParticleLight` keeps answers until a block or its light changes, or a chunk loads | `?particlelight=frame` |
**Tools:**
- **`-Pteavm.names`:** a release build that keeps Java names, so profiles read as the game's methods
(about twice the download; profiling only).
- **`?gpucensus`:** each draw's GPU time by pipeline. A draw that switches render targets also
absorbs earlier work, so read shares with care.
- **Benchmark against a remote browser** now gets the page's console, closes its tab, and prints the
stack of any 50 ms render-thread wait.
## Results
`laptop-floor`, release build, 2026-10-03, three alternating runs each (medians):
| Lobby | Before | After |
| --- | ---: | ---: |
| Frame rate (fps) | 21.1 | 31.6 |
| 1% low (fps) | 7.5 | 9.8 |
| Tick / extract / render submit (ms) | 10.2 / 8.7 / 26.2 | 5.1 / 7.8 / 15.9 |
| GPU (ms) | 18.0 | 10.6 |
| Fly-through and combat | Before | After |
| --- | ---: | ---: |
| Fly-through tick (ms) | 2.8 | 1.7 |
| Fly-through slowest-1% tick (ms) | 43.4 | 16.6 |
| Fly-through 1% low (fps) | 13.7 | 15.9 |
| Combat slowest-1% tick (ms) | 19.8 | 14.0 |
| Combat 1% low (fps) | 24.0 | 26.8 |
Both hold 60 fps at the median either way. Memory and start-up don't move. Screenshot diffs pass
15/15 (SSIM ≥ 0.9938).
## Consequences
- Five more vendor patches; the glyph one is largest, since Incari code can't reach LWJGL's memory
functions.
- Items with per-quad tint changes within one layer (none in 26.3) would need the game's way.
- Ambient particles assume the biome is the only positional layer, as in 26.3.
- Particle light trusts that every light change marks render sections dirty, as meshing does.
- The occlusion graph's full update can take several frames, as the game already allows.
- What's left on the stand-in: the lobby is CPU-bound (~30 ms of tick, extract and submit across
entities, text, particles); the slowest fly-through and combat frames are scavenges and catch-up
ticks.
@@ -0,0 +1,61 @@
# ADR 0032: Catch-up ticks paced, mesher tables kept, light maps updated in place, particles instanced
- Status: accepted
- Date: 2026-10-03
## Context
Still without a Chromebook, these changes were chosen as wins on any device, measured on
`laptop-floor`:
- **Catch-up ticks:** the slowest 1% of frames were mostly missed ticks run back to back after a stall.
- **Joining:** building the mesher's tables took ~7 s of the 22 s join, every time, for the same tables.
- **Fly-through GCs:** young collections averaged 10 ms (the lobby's 0.7 ms). Desktop JFR showed what
lives long: 70 of 158 samples were the light engine copying its whole section map after each
round of updates; 28 the occlusion graph cloning two sets.
- **Particles:** writing their vertices was 3.3% of the lobby.
## Decision
| Change | What | Off switch |
| --- | --- | --- |
| Catch-up ticks paced (`TickPacing`) | Owed ticks spread over frames: each frame runs the average needed (at least one), one more while over two frames' worth is owed. Debt capped at the game's own 10. Page only | `?ticks=game` |
| Mesher tables kept (`MeshTableCache`) | Encoded tables saved to `/incari/cache/mesher-tables.bin` in OPFS, keyed by build id, lighting settings, packs and every blocks-atlas sprite. Only with built-in packs and release builds | `?meshtables=build` |
| Light maps updated in place (`LightCopies`) | Instead of copying ~8,700 sections' arrays after each round, update the visible map only at sections noted as changed. One-thread only. Light from remote servers is kept as it arrives, not copied | `?light=game`, `?light=verify` |
| Occlusion graph copies refilled | Two kept sets refilled instead of cloned for each full update | `?graph=game` |
| Particles instanced (`ParticleInstancing`, `ParticleInstanceRewrite`) | Each particle's 12 floats and 2 ints go to the GPU as one instance; the vertex shader builds the quad from `gl_VertexID`. Translucent order kept. Only when every pipeline a layer may use has an instanced copy | `?particlequads=game` |
A first tick-pacing version allowed 20 ticks of debt and drained faster as it grew: combat's 1% low
fell after its stalls. Capped at 10, it doesn't.
The benchmark now joins twice (`load.rejoinMillis`), as a player's every later join.
## Results
`laptop-floor`, release build, 2026-10-03:
- **Tables:** built in 6.7 s, read back in 0.23 s. Rejoin 13.0–13.8 s vs 18.8–19.6 s.
- **Tick pacing**, fly-through (6 runs each): 1% low 26.9 vs 18.3 fps; slowest-1% frame 20.9 vs
36.1 ms. Combat and lobby unchanged.
- **Light and graph copies:** young GCs 40 vs 44 and 347–369 vs 376–417 ms total; p99 frame 26.3 vs
28.5 ms. `?light=verify` over 1,000 swaps: no difference.
- **Particles:** lobby render submit 15.1 vs 15.9 ms; 33.1 vs 31.6 fps.
- Screenshot diffs 15/15 (particles 0.9989, drawn instanced). `TickPacingTest`,
`ParticleInstanceRewriteTest`.
## Not done
- **Chunk data off the GC heap:** JFR named the light copies, not chunk storage.
- **Decoding chunk packets off the main thread:** 2.4% of the page; too little to pay for a worker's copies.
- **Lithium's shape and collision caches:** collisions were 1–2%.
- **Found for later:** every packet handed to the game's thread costs a throw, ~10x dearer off the
main thread (`PacketHandoffProbe`). ADR 0033 takes it.
## Consequences
- More vendor patches (tick hook, light swap and accessors, graph copies, four particle hooks).
- The kept tables cost 11 MB of heap; the title stays in budget.
- The tables' key must name every input; a new one (a model-changing setting) must join it.
- After a stall the game runs up to 10 ticks behind the clock for a few frames.
- In-place light trusts every change notes its section, as in 26.3; `?light=verify` checks.
- Particle positions are the GPU's arithmetic; the screenshot diffs check them.
@@ -0,0 +1,72 @@
# ADR 0033: Throws off the page's main thread: the packet handoff, and Via's dropped packets
- Status: accepted
- Date: 2026-10-03
## Context
`PacketUtils.ensureRunningOnSameThread` was 2.5% of combat on `laptop-floor`, mostly entity movement
packets, whose handoff cost ~100x their decoding.
The game decodes each packet on the network thread and calls its handler there; nearly every client
handler queues the packet for the game's thread and throws a shared exception that
`Connection.channelRead0` catches. Cheap on the JVM. In the page (`PacketHandoffProbe`):
| ns per packet | Main thread | Any other thread |
| --- | ---: | ---: |
| Calls | 5–15 | 5–10 |
| Queueing | 20–30 | 20–30 |
| Throw and catch | 65–100 | 640–860 |
The network thread is another thread, so every packet paid the dear throw.
## Decision
**`PacketHandoff`** (two hooks in `Connection.channelRead0`): the first time a packet type's handler
throws to hand off (per listener type), the pair is noted. From then on the connection queues such
packets on the game's packet processor itself, without calling the handler on the network thread.
The game's thread handles them as before.
That's exactly the game's effect where the handler's first statement is an unconditional handoff.
`PacketHandoffTest` reads the game's listeners and confirms it for 136 of 138 handlers in 26.3; the
other two (custom payload, transfer) are never noted. Handlers that don't hand off never throw, so
are never noted. Client listeners only. Page only; `?handoff=game` restores the game's way.
### The other throws: a census
`-Pteavm.throwCensus` (development builds) counts every `throw` by site and thread
(`ThrowCensus`, `ThrowCensusProbe`). On a 26.3 server: ~13 a second, mostly loading (missing-file
checks, reflection) and the section dispatcher finding no free buffer (fixed in ADR 0034). Not worth patches.
**Through Via:** 135–205 a second, nearly all Via dropping packets the other version doesn't use. Each
dropped packet threw in Via, then 3–4 more times in Netty's `MessageToMessage` codecs that
`ViaPipeline` extended.
**Via's stage without Netty's codecs:** `ViaPipeline`'s decoder and encoder are now plain handlers
that do the codecs' job and catch Via's drop themselves. A dropped packet now throws twice, both in
Via. `ViaPipelineTest` checks every buffer is released.
## Results
`laptop-floor`, release build, vs `?handoff=game`:
- Normal runs: within noise, since combat and the fly-through already hold 60 fps.
- With the profiler on (page 97–98% busy, like a slower device): combat median 40.7–44.4 vs
37.6–39.1 fps, every run with the change above every run without.
Via census, same sessions before and after:
| Throws off the main thread | Before | After |
| --- | ---: | ---: |
| 1.8.9 server, 2 minutes | 16,080 | 6,161 |
| 1.12.2 server, 90 s | 18,484 | 5,172 |
On the stand-in that's a few tenths of a millisecond a second, below what can be measured; it
counts where the CPU is the limit.
## Consequences
- One vendor patch (`Connection.channelRead0`).
- A future handler that does something before handing off fails `PacketHandoffTest` until listed.
- Via's own two throws per dropped packet stay; avoiding them means replacing Via's classes.
- `-Pteavm.throwCensus` adds a call before every throw: development only.
@@ -0,0 +1,71 @@
# ADR 0034: Fixed translucent orders, the class library's lookups, collision sweeps, and Binaryen
- Status: accepted
- Date: 2026-10-04
## Context
`laptop-floor` holds the fly-through and combat at 60 fps and the lobby near 33 fps. What's left is
thin CPU time and slow frames. Profiles of the stand-in named:
| Share of page time | |
| --- | ---: |
| Combat: dropped items' ticks, a third in block collision sweeps | 10% |
| Lobby: particles removed from an `ArrayDeque` element by element | 2% |
| Combat: `Set.contains` on the class library's `Set.copyOf` (tag checks) | 1.2% |
| Fly-through: `drawBuffers` on every framebuffer bind | 3.1% |
| Fly-through: a `NullPointerException` thrown when no buffer pack is free | 0.7% |
| Fly-through: section snapshots (tint biome lookups 2.5%) | 11% |
## Decision
| Change | What | Off switch |
| --- | --- | --- |
| Fixed translucent order (Sodium's static sorting) | When every translucent quad in a section lies flat across one axis (still water), one order is correct from any camera, because back faces are culled. The mesher writes that order (`FixedOrder`) and the game's re-sort is skipped. Page only | `?resort=game` |
| Air skipped in collision sweeps (Lithium) | `AirBlock` shapes are empty in every context, so skip them before asking (`Collisions`) | `?collisions=game` |
| Snapshots read section copies directly | `SnapshotBuilder` reads each copied section's palette, not 8,000 checked lookups. Desktop too, so `smokeMesher` checks it | `?snapshotreads=game` |
| Tint biomes dropped locally | A chunk loading or unloading drops cached biomes only in it and its neighbours (`TintBlend.chunkChanged`) | — |
| Hashed immutable sets and maps | `TTemplateCollections` probes an index table instead of comparing every element (`ImmutableCollectionsProbe`) | — |
| `ArrayDeque` middle removal | Shifts with `System.arraycopy` | — |
| Draw buffers set once | A framebuffer's draw buffers are set on its first draw bind (`Framebuffers`) | — |
| No throw for a busy dispatcher | Requeue without the `NullPointerException` the game threw and caught | — |
## Binaryen (`-Pteavm.wasmOpt`, opt-in at the time)
Runs `wasm-opt --closed-world -O3 -ocimfs 100` (Binaryen 133, pinned and fetched to
`work/cache/binaryen/`) after TeaVM. Adds ~13 minutes and 10 GB to a release build.
- **`--closed-world`** broke the page at first: functions JavaScript calls reached Binaryen only as
function references, so it emptied `main`. `WasmGCJsoCommonGenerator` (teavm-patches) now exports them.
- **`-ocimfs 100`:** uncapped single-caller inlining made functions V8's optimizer ran out of memory on.
- Plain `-O3` without closed world measured nothing.
On `laptop-floor`: fly-through render submit 2.3 → 1.9 ms; the rest within noise; download about the
same. Kept opt-in until measured on the floor device (made the default in ADR 0043).
## Not done
- **Vertex pulling** (terrain without an index buffer): on the UHD 620 it cost up to two thirds more
GPU time where vertices dominate.
- **Reusing entity render states:** constructors were 0.2% of combat, and reuse would trust every
renderer to reset every field.
## Results
`laptop-floor`, release build, 2026-10-04. The three switchable changes, on vs off: combat tick 2.3
vs 2.7 ms; fly-through and lobby within noise (both already at their limits).
Profile shares before → after: `drawBuffers` 3.1% → 0; dispatcher stack traces 0.5% → 0; snapshots
11% → 8.3%; `Set.contains` 1.2% → 0.02%; `ArrayDeque` removal 2% → 0.
Found on the way: the lobby's mesh queue drains at ~1.5 sections a second when frames overrun,
because the background pool gets only 1 ms then (fixed in ADR 0035).
Correctness: screenshot diffs 15/15, `smokeMesher` (17,943 sections) clean, `SectionMesherTest`.
## Consequences
- Five more vendor patches.
- The fixed order trusts that terrain pipelines cull back faces.
- Skipping air trusts that air has no shape in any collision context, as in 26.3.
- Local tint drops trust that a biome lookup never reads past the neighbouring chunk.
@@ -0,0 +1,42 @@
# ADR 0035: A floor for the background pool's share of a late frame
- Status: accepted
- Date: 2026-10-05
## Context
Background work runs in slots between frames (ADR 0015), ending 2 ms before the next frame is due,
with at least 1 ms. When the game's frame already overruns (the lobby on `laptop-floor` runs at 33
fps on a 60 Hz display), every slot is that 1 ms: part of one section's snapshot. A section took
dozens of frames, and terrain after a teleport took minutes on a slow device.
## Decision
While the pool has work, a slot lasts until `max(frame start + interval − 2 ms, now + floor)`, the
floor 4 ms by default (`WebPlatform.setPoolFloor`; `?poolfloor=<ms>`). On-time frames are unchanged;
only already-late frames give the pool more, and only while it has work.
## Results
Desktop, CPU throttled 4x, lobby:
| Floor | FPS | Mesh queue | Sections drawn |
| --- | ---: | ---: | ---: |
| 1 ms (before) | 29.9 | 81 | 119 |
| 4 ms | 29.0 | 48 | 196 |
| 8 ms | 26.4 | 46 | 197 |
Two-thirds more terrain in the same time for 3% of the frame rate; 8 ms cost more and loaded no
more. The fly-through (time to spare each frame) didn't move. On `laptop-floor` the lobby's queue
halved (17.7 → 8.3) for 2% of its frame rate.
## Not done
- **Several sections in progress at once:** starting another task while one waits for a worker made
no difference; the page's share of each section (snapshot, upload) is the limit.
## Consequences
- A late frame is ~3 ms later while terrain loads (more if a long task starts in its slot).
- The lobby benchmark loads further in the same time, so its tick and render submit rise with the
terrain drawn.
@@ -0,0 +1,68 @@
# ADR 0036: Fast and Compatible builds (JSPI instead of coroutines)
- Status: accepted
- Date: 2026-10-05
## Context
TeaVM compiles every method that might suspend as a coroutine, and its analysis spreads that through
shared library code (ADR 0027). In the release module, coroutines are 83,152 of 303,310 functions but
**81% of all instructions**, ~38% of which is the transformation's own bookkeeping. The fly-through
spends 87% of its WebAssembly time in coroutines. `CoroutineCostProbe`: the same code takes 8.3–8.7 ns
an item as coroutines vs 5.5–5.9 ns plain.
**JSPI** (WebAssembly JavaScript Promise Integration) lets the engine keep a suspended stack itself,
so nothing needs compiling differently. Chrome/Edge 137+ and Firefox 153+ have it; Safari doesn't yet.
The JavaScript fallback (ADR 0014) served only Chrome before 119 (end-of-life devices), ran far
slower, and was a second compile to maintain.
## Decision
- **Two WebAssembly GC builds, named for players:**
- **Fast:** threads suspend through JSPI; nothing is a coroutine. Chrome/Edge 137+, Firefox 153+.
- **Compatible:** TeaVM's coroutines, for browsers with WebAssembly GC but no JSPI (Safari, older
Chrome and Firefox).
The names say what a player weighs (speed vs reach) and are used everywhere: the loading screen,
`?build=`, `-Pteavm.fast`, `build/teavm-fast/`, `./incari build --only`, the manifest.
- **The JavaScript fallback goes.** Browsers without WebAssembly GC are told to update.
- **TeaVM changes** (teavm-patches): with `incari.jspi` set, `AsyncMethodFinder` finds nothing async.
`Fiber.Jspi` runs each fiber through `WebAssembly.promising` and suspends on a
`WebAssembly.Suspending` import. `JspiTransformer` routes `Fiber.suspend`/`start` there.
- **The page:** `build.json` format 2 lists `fast` and `compatible`. Where both run, the loading
screen asks (Fast recommended) and remembers.
- **Ending fibers on `pagehide`:** V8 never frees a suspended stack, so every reload leaked the
whole game (50 MB a load in `ReloadLeakProbe`; the lobby held three old games, 1,140 vs 356 MB).
`jspi.ts` resumes each waiting fiber with an order to end, and it unwinds by trapping, with no
Java code run.
- **`./incari build`** compiles both; `--only` makes one.
## Results
`laptop-floor`, release builds:
| | Compatible | Fast |
| --- | ---: | ---: |
| Lobby median / 1% low | 32.5 / 7.6 fps | 60.4 / 32.0 fps |
| Lobby tick / extract / render submit | 7.8 / 7.9 / 14.8 ms | 1.6 / 3.8 / 9.6 ms |
| Combat 1% low | 27.0 fps | 38.9 fps |
| Cold start | 13.4 s | 10.2 s |
| Join | 19.5 s | 13.7 s |
Desktop: lobby render submit 4.05 → 2.38 ms, join 4.9 → 3.6 s, combat and lobby 1% low up 22–27%.
Module 64.1 → 36.5 MB (gzip 20.5 → 12.3 MB). GC pause spikes vary run to run in both builds.
`JspiProbe` (sleep, wait/notify, join, exceptions across waits, `currentThread`) passes in both;
`jspi.test.ts` runs the imports under Node's JSPI.
## Consequences
- Two release compiles per build.
- Code reached from a JavaScript callback still must not suspend (JSPI traps).
- In Fast, a woken thread resumes from a microtask, not inside the call that woke it. Nothing found
relies on the old order.
- Thread switches through TeaVM's event queue cost ~4 ms in both builds (the `setTimeout` clamp; see
ADR 0040).
- Compatible is unchanged, so running both separates Fast regressions from game ones.
- Drop Compatible once every browser that matters has JSPI (watch Safari).
@@ -0,0 +1,45 @@
# ADR 0037: The Unicode font and the languages from the asset index
- Status: accepted; the panorama is no longer fetched (menus show Incari's own photo, `MenuBackdrop`)
- Date: 2026-10-05
## Context
The game reads both the client jar and the assets directory a launcher fills from the asset index.
The page took only sounds from the index (ADR 0013), and it showed:
- **Only English:** the jar has `en_us.json`; the other 142 languages (and the language list,
`pack.mcmeta`) are in the index.
- **No Unicode font** (`font/unifont*.zip`, 1.8 MB): CJK, most non-Latin scripts and many symbols drew
as boxes.
- **A grey title panorama:** the jar holds blank stand-ins. (Since replaced by Incari's own photo.)
These are Mojang's files: fetched by `./incari assets` into the ignored cache and copied into the
builder's own folder (ADR 0028), like the sounds. Nothing is committed.
## Decision
- **The build copies them:** `WebFolder` copies `sounds.json`, `pack.mcmeta`, `minecraft/font/` and
`minecraft/lang/` with the sounds. `--no-sounds` still leaves the whole index out.
- **The language list is fetched at start**, with `sounds.json`, since the pack repository reads it
once before the first reload.
- **The rest is fetched before the listeners that read it reload** (`RemoteAssets.gate`, through the
existing reload hook, no new patch): the font and the selected language are fetched on the
background pool while the language and font managers' reloads wait; others start at once. Files
already written are skipped, so later reloads fetch only a newly picked language.
- **A failed fetch is logged** and the reload continues with what's there.
- **The service worker keeps them** between loads (content-addressed objects).
- The desktop reads its full assets directory as before.
## Consequences
- Every language can be picked, and text outside the bitmap font draws.
- A first visit downloads ~1.8 MB more for the font (0.6 MB more for a non-English language).
- The folder grows by the languages (85 MB on disk; only one is downloaded).
## Alternatives rejected
- **A file system that fetches on open:** the page's file system never suspends (ADR 0011).
- **Fetching when the language screen closes:** a new patch, a render-thread wait, and it misses a
language saved from an earlier visit.
- **Incari's own font:** only needed for a distributable build, which none is.
@@ -0,0 +1,62 @@
# ADR 0038: Singleplayer in the page
- Status: accepted
- Date: 2026-10-07
## Context
Singleplayer was planned for much later. The plan changed: all of vanilla works before the client
builds its own features, singleplayer included. The integrated server was always in the browser
build, but nothing had opened a world. The first try failed to save `level.dat` and then waited
forever for its first chunk.
This ADR is stage one: singleplayer working with the integrated server on the page's one thread.
ADR 0039 moves the server into a worker.
## Decision
### Getting the server to run
- **The game's wait loops end their frame:** world load and save-and-quit pump events from inside a
loop, so the page never reached the point between frames where the server and pool run.
`SDLEventHandler.pumpEvents` now ends the frame there. No-op on the desktop.
- **A blocking pool task gives up the pool** (`IdleTimeExecutor.beforeWait`, via `Waits`): world
generation joins work it queued on the same pool, which never ran with the one runner holding it.
Another runner takes over. `IdleTimeExecutorTest`.
### Class library fixes (found because singleplayer is the first heavy user)
| What | Bug | Fix |
| --- | --- | --- |
| `GZIPOutputStream.flush()` | Threw on zlib's "no progress" | web-classlib's own |
| `Deflater`, `DeflaterOutputStream` | Threw mid-stream; miscounted input | web-classlib's own over jzlib (`DeflateProbe`) |
| `InflaterInputStream.skip` | Overwrote input not yet inflated | An addition skipping into scratch |
| `ByteBuffer.allocateDirect` | Not zeroed: region headers garbage | teavm-patches |
| Polled `ReferenceQueue` references | Lost their class's methods (Optimize World trapped) | teavm-patches (`WeakQueueProbe`) |
| Netty's local channels | Reflection, two NIO exceptions, interface probing | Declared, added, fixed ids |
| `STBImageResize` | Missing | `ImageResize` in Java |
| Logged crashes | Lost their cause | The console logger walks the chain |
### What a page does instead of a folder or a port
- **Folder buttons download zips** where the platform can't show folders (`FolderDownloads`): Open
World Folder, Open Backups Folder. Pack folders keep the file picker.
- **Drop a world on the world list to import it** (`WorldImport`): a zip or folder with a
`level.dat` becomes a new world, never overwriting one. Entries pointing outside are refused.
- **Open to LAN fails cleanly:** `PlatformNetwork.canAcceptConnections` is false, and the game's own
"couldn't host" path shows. Sharing through a relay came later (ADR 0062).
## Verified
Headless Chrome: create, generate, play, pause, save and quit, reopen, quit again; every chunk in
every region file inflates with the browser's `DecompressionStream`. Backups, Edit World, World
Options and Optimize World work.
## Consequences
- **The server shares the page's thread:** 60 ms frames during world generation, and "Can't keep
up". ADR 0039 fixes this.
- **Worlds sit in memory** as well as OPFS (until ADR 0041).
- **"UUID of added entity already exists"** a few times a session: entities load twice, the game
keeps the first, and saves hold no duplicates. Cause open.
- **The loading screen's chunk map** costs half the page's time while a world loads.
@@ -0,0 +1,65 @@
# ADR 0039: Singleplayer's server in a Web Worker
- Status: accepted
- Date: 2026-10-07
## Context
ADR 0038's server on the page's thread works, but its ticks and world generation take time from the
client's frames (60 ms frames after joining a new world, the server seconds behind). On the
reference Chromebook that's the difference between playable and not. Web Workers share nothing with
the page: own WebAssembly instance, own heap, messages only.
## Decision
### The same program, in a worker
- **No second module:** the worker loads the game's own (cached) module and starts it with a role:
`WebMain.main(["--worker", "server"])` runs `GameWorkerMain`, never the client. A second compile
would double build time and download for nearly all-shared code.
- **`PlatformThreads.startGameWorker`** runs `game-worker.js`, which loads the module as `boot.ts`
does (with JSPI for Fast). Page and worker talk through a `PlatformChannel` of transferred byte
messages. The desktop keeps the vanilla integrated server; `?singleplayer=page` keeps ADR 0038's way.
- **The worker's platform is headless** (`WorkerPlatform`): threads, pool, files. Pool slots are 8 ms
turns of the event loop (`WorkerSlots`).
- **The worker reads the client jar** from OPFS where the page cached it.
### The world's files move with the server
- **Hand-over:** the page sends the world's files and forgets them (`PlatformStorage.handOver`); on
stop the worker sends them back (`takeOver`). Never in both heaps. (ADR 0041 later leaves region
files in place.)
- **The worker's writes go to storage through the page** every 250 ms (ADR 0041 later made this direct).
- **A new world's settings are written on the page** before hand-over, so the worker opens every
world the same way.
### The server
- **`WorkerServer`**: a `MinecraftServer` written for the worker, doing what `IntegratedServer` does
for one player. Pause and view distances arrive by message. The owner's data goes into
`level.dat`, so worlds move between browser and desktop unchanged.
- **The client connects as if remote:** the game's pipeline, one packet per message over the channel
(`ChannelLink`). No compression or encryption.
- **Hooks:** opening (`Minecraft.doWorldLoad`: write data, start the worker, show its progress,
connect), leaving (`Minecraft.disconnect`: save and stop with "Saving world"), pausing, and the
world icon (taken on the page, sent to the worker).
- **World Options** asks a `SingleplayerHost` (the integrated server, or the worker's reported
settings, changed by message). Open to LAN fails cleanly.
## Verified
`singleplayer.steps`, both builds: create, play, World Options and a command, save, ~1,100 chunks
inflate, reopen, download, import, delete. A worker-made world opens in page mode too.
Desktop frames in the 5 s after joining a new world, then after: server on the page 32, 41, 56, 55
fps; in a worker 36, 58, 59, 58 fps.
## Consequences
- **Two copies of the game run;** the worker's heap (registries, data packs, world) adds to the
page's. Measuring both together is next.
- **The worker starts in a few seconds per world** (later started early, ADR 0041).
- **Logs** carry the worker's own thread names in the page's console.
- **"UUID of added entity already exists"** still appears: a chunk's entities load twice. The game
keeps the first; saved files hold no duplicates. Why it happens here and not on the desktop is open.
- **The desktop is unchanged.**
@@ -0,0 +1,65 @@
# ADR 0040: Singleplayer's server, faster: wakeups, math, spawn settings, stronghold rings
- Status: accepted
- Date: 2026-10-07
## Context
With the server in a worker (ADR 0039), a new world took 29 s to create on the desktop and 62 s on
`laptop-floor`; the idle tick at spawn was 9.7 ms (22 on the laptop), and the laptop's fly-through
drew ~20 sections because terrain couldn't keep up.
We surveyed the server-side optimization mods (Lithium, C2ME, Noisium, ScalableLux, ModernFix, Chunky)
against profiles of the worker itself (`-Pbenchmark.profile` now records them). Nothing here is a mod's
code. The profiles found:
| Where | What |
| --- | --- |
| Creating a world | 18 of 25 s with the worker 99% idle while picking spawn |
| Everywhere | 8–18% of busy time calling out to JavaScript |
| Idle spawn area | 55% of each tick in `NaturalSpawner.createState`, spawning off |
| Opening a world | half the time searching biomes for 128 stronghold rings |
| Fly-through | noise 50%, surface 24%, features 10% (not addressed here) |
## Decision
- **Wakeups without the timer clamp** (`wakeups.ts`): picking spawn makes ~8,000 hand-offs between
the world-gen task and the IO thread. TeaVM schedules every wakeup with `setTimeout(0)`, which
browsers clamp to 4 ms once nested five deep: 16–22 s of idle waiting. In the worker, events due
now drain from a `MessageChannel` instead. The page keeps timers unless `?wakeups=channel`
(ADR 0043 found it unsafe there).
- **`Math.floor`, `ceil`, `sqrt` as wasm instructions** (`MathIntrinsics`): TeaVM imported them from
JavaScript, and noise floors every coordinate. All three are exact in IEEE 754 (`MathProbe`). Calls
out fell from 18% to 1% of the worker's time.
- **Spawn settings once per biome** (`SpawnCosts`) [`?spawncosts=game`, `?spawncosts=verify`]: the
mob cap asked for spawn settings at every counted mob every tick; they depend only on the biome
unless a timeline changes them. Verified over 580,000 lookups: no difference.
- **Stronghold rings searched when needed** (`StrongholdRings`) [`?rings=game`]: the game started all
128 biome searches as the overworld loaded, ahead of the spawn area on a one-thread worker. Now
positions and random sources are worked out up front in the game's order, and each search runs the
first time a chunk within reach needs it; the rest run in the background after a minute.
`StrongholdRingsTest` checks identical positions for two seeds.
## Results
Singleplayer benchmark, Fast release:
| | Desktop before | after | `laptop-floor` before | after |
| --- | ---: | ---: | ---: | ---: |
| Create world | 29.4 s | 7.5 s | 61.6 s | 32.5 s |
| Save and Quit | 5.7 s | 2.1 s | 10.7 s | 5.6 s |
| Reopen | 7.9 s | 5.6 s | 32.1 s | 22.0 s |
| Idle tick at spawn | 9.7 ms | 5.1 ms | 22.4 ms | 14.4 ms |
| Fly-through tick | 4.4 ms | 2.5 ms | 14.5 ms | 4.6 ms |
| Sections drawn, fly-through | | | 21 | 89 |
On the laptop the page now draws 3–4x more terrain, so its frame figures aren't comparable: on two
cores, handling arriving chunks is now the page's cost, beside world generation. Baselines re-recorded.
## Consequences
- The page keeps TeaVM's timers; `wakeups.js` is one more script the loader serves.
- World generation (noise, surface) is now the worker's cost. Compiling density functions at build
time was the next idea; more generating workers would cost 260–420 MB each.
- Worker profiles are part of `-Pbenchmark.profile`.
- The desktop is unchanged.
@@ -0,0 +1,92 @@
# ADR 0041: Singleplayer's files in place, a direct line to storage, and cheaper world generation
- Status: accepted
- Date: 2026-10-08
## Context
Profiles after ADR 0040 (desktop, Fast build with names):
| Where | Time went to |
| --- | --- |
| Fly-through, server worker (56% busy) | surface 27.5%, noise 22%, features 11%, saving 12% |
| Fly-through, page | passing the worker's file changes to storage: 10%, 4x the chunk packets themselves |
| Creating a world, worker | surface 28%, noise 21%, features 8%, worker start 13% |
| Idle at spawn | mob movement and collisions 43% of the tick; stronghold searches 33% |
Region files rewrite their 8 KiB header with every chunk saved, and a file kept only one changed
range between flushes, so each 250 ms flush copied most of every touched region file about seven
times, three on the page's thread. Both page and worker also held whole worlds in memory, which
grows with exploring: on a 4 GB Chromebook that heap runs out.
In 26.3 the material system writes ~16,000 blocks a chunk through `ProtoChunk.setBlockState`.
Density functions are already sampled over volumes, so compiling them would gain little.
## Decision
Nothing here is a mod's code. Bracketed options turn a change off.
- **World files left in place** [`?inplace=off`]: region files (`.mca`, `.mcc`) are never loaded
whole when OPFS is the store and this tab holds it (`InPlaceFiles`). The page lists them by size
and reads one only when it opens it. The server worker opens them with synchronous access handles
(`OpfsFiles`), writing straight to the file. Hand-over sends sizes after a storage `sync`; hand-back
releases handles and `stat`s the files. With IndexedDB or no sync handles, files travel with their
bytes as in ADR 0039.
- **A direct line to storage:** the worker sends file changes straight to the storage worker through
a port the page hands it (`BrowserStore.connect`), in the page's queue. A file keeps up to 8
changed ranges (writes <512 bytes apart merge), so a region write sends its header and its chunk.
- **Packets a tick at a time** [`?packets=each`]: the page–worker link carries the game's stream,
length-prefixed, one message per flush (`ChannelLink`). The server flushes once a tick.
- **Worker started early:** the world list and create screen start the worker, which bootstraps and
builds the data fixer before a world is chosen (`WorldWorker.warmUp`).
- **Stronghold searches wait for quiet** while other background work is queued (`backgroundQueued`).
- **Surface writes** [`?surface=game`]: `SurfaceWrites` writes the material system's column as
`ProtoChunk` would, but looks up heightmaps and build height once per chunk and skips the
one-thread-safe palette check. Other chunk kinds go the game's way.
- **Biome cells** [`?biomecells=game|verify`]: when all eight biome cells around a 4×4×4 group agree,
`BiomeCells` answers without the blur's hashing.
- **Build heights cached** [`?heights=game`]: `Heights` keeps each level's and chunk's bottom and
height (they never change).
- **Criterion codecs built once** [`?criteria=game`]: DataFixerUpper names codecs eagerly; one per
trigger saves 90–140 ms of worker start.
Looked at and left: collision sweeps (already direct; `Heights` fixed their cost), merging dropped
items (0.2%), the aquifer's search (~1%), the light engine (3%, spread thin), compiling density
functions (26.3 already samples volumes), TeaVM's byte copies (~0.6 ms/MiB; volume was the cost).
## Verified
- `TerrainEquivalenceTest` runs the real overworld terrain step on 4×4 chunks, 4 areas, 3 seeds,
with and without the changes: every block and heightmap identical (a deliberately broken writer
fails it).
- `SurfaceWritesTest`, `BiomeCellsTest`, `DataFileTest`, `JournalTest`, `InPlaceTest`,
`ChannelLinkTest`, and the storage worker's tests.
- Whole worlds (`worldgenServer` + `tools/worldgen/compare.py`) can't be compared exactly: two runs
with the changes off already differ in 108–147 of 1,764 chunks (feature order between chunks).
- `singleplayer.steps` passes in a worker and on the page.
## Results
Singleplayer benchmark against ADR 0040:
| | Desktop before | after | `laptop-floor` before | after |
| --- | ---: | ---: | ---: | ---: |
| Create world | 7.5 s | 5.9 s | 32.5 s | 27.1 s |
| Save and Quit | 2.1 s | 1.0 s | 5.6 s | 3.7–4.2 s |
| Reopen | 5.6 s | 5.3 s | 22.0 s | 20.8–21.7 s |
| Page heap peak | 725 MB | 599 MB | 760 MB | 506–532 MB |
| Longest GC pause, spawn / fly-through | 74 / 49 ms | 0.8 / 15 ms | | |
| 1% low, spawn / fly-through | 42 / 36 | 53 / 48 | 17 / 10 | 27–30 / 14–23 |
- World generation changes alone (`laptop-floor`): create 30.7 → 27.1 s, and the server keeps up
with the camera longer (44 → 72–80 sections drawn in the fly-through).
- `?inplace=off` grows the worker heap 18–40 MB; `?packets=each` shows no measurable difference (kept
for fewer wake-ups).
## Consequences
- Memory no longer grows with a world's size while it isn't open on the page.
- A world handed to the worker in place can't be renamed by it (the store has no rename for a file
another program holds). The page renames, reading region files first.
- Opening a region file on the page suspends while it's read.
- The desktop is unchanged.
@@ -0,0 +1,71 @@
# ADR 0042: Density functions' branches sampled where used, terrain helpers, and goals' flags as masks
- Status: accepted
- Date: 2026-10-08
## Context
On `laptop-floor` the singleplayer server worker is 99% busy in the fly-through, drawing 55 terrain
sections against the desktop's 860. Worker time: noise 28%, surface 20%, features 11%, biomes,
carvers and light ~10%, saving 5%. Idle at spawn, mobs are 28% (movement sweeps and goal selection).
Two things stood out in 26.3. A range choice sampled over a volume samples **both** branches over the
whole volume before picking per point (and `lerp` both sides): the overworld's caves sampled the whole
cave stack even in the sky. And the terrain step reads only the seed, nearby biomes and structure
pieces, so it could run off the server's thread.
## Decision
Nothing here is a mod's code. Bracketed options turn a change off.
- **Branches sampled only where used** (`DensityBranches`) [`?densitychoices=game`]: sample a choice's
input first, then each branch only over the rows some point takes (likewise `lerp`'s sides).
Values are exact: rows start at multiples of 48 blocks so interpolated cells line up, and caches
are sampled no more than before. Only on cell-corner volumes (on single-block volumes it was slower).
- **Terrain step in helper workers** (`RemoteTerrain`) [`?terrainworkers=N`, **off by default**]: other
copies of the game in child workers build chunks' terrain from a `TerrainJob` (biomes and nearby
structure pieces); the server keeps two jobs per helper out and builds the rest. Off because it
showed no gain (the desktop keeps up anyway; `laptop-floor`'s two cores are already full) and a
helper costs 150–270 MB.
- **Goal flags as masks** (`GoalFlags`) [`?goalflags=game`]: each goal's control flags and the
selector's disabled flags as bitmasks, answered as the game's loops would.
Looked at and left: `min`/`max` laziness (4% slower), per-column row ranges (no fewer rows), the
palette's last-index search (no gain), skipping same-block writes (0.3%), chunk-aware block sweeps
(≤ 2%), cheaper save compression (done in ADR 0043).
### A Chrome renderer crash, found and fixed
With a helper, Chrome's renderer died in every run's second session. The renderer process hit
Chrome's 16 GB sandbox limit in V8's compilation zone: TurboFan was compiling
`teavm@initReflection`, one 559 KB function TeaVM generates. Once enough instances of the module had
started (page, server, helper, over two sessions), V8 tiered it up and ran out of memory.
`ReflectionMetadataGenerator` (teavm-patches) now splits it into ~4000-instruction functions, and
`WasmGCModuleGenerator` splits the 5 MB start function the same way. With both, every run finished
at a 3.8–4.0 GB peak. Players' builds without helpers could have hit it too after opening enough worlds.
## Verified
- `TerrainEquivalenceTest` with lazy branches on and off: every block and heightmap identical.
- `RemoteTerrainTest`: 16 chunks built by a helper equal those built in place.
- `GoalFlagsTest`: masks answer as the game's loops for every flag combination.
- JVM terrain step: noise fill 5% faster, the whole step ~1.5%.
## Results
Singleplayer benchmark, Fast release, helpers off, changes off vs on:
| | Desktop off | on | `laptop-floor` off | on |
| --- | ---: | ---: | ---: | ---: |
| Create world | 5.9 s | 5.9 s | 27.2–27.4 s | 26.6–27.0 s |
| Server tick at spawn | 4.2 ms | 4.2–4.6 ms | 15.3–17.3 ms | 13.7–13.8 ms |
| Fly-through sections drawn | ~866 | ~866 | 78–90 | 88–108 |
On `laptop-floor` the idle tick fell from 15–17 to 14 ms (likely the goal flags); the rest is within
noise. The desktop keeps up either way.
## Consequences
- Terrain helpers stay available behind `?terrainworkers=N`; nothing starts one by default.
- A game worker unwinds its fibers before it closes, as the page does on `pagehide`.
- The desktop is unchanged (`worldgenServer` turns the lazy branches on with ADR 0041's changes).
@@ -0,0 +1,93 @@
# ADR 0043: Less garbage in world generation, the client jar compacted, faster saves, and wasm-opt and channel wakeups measured again
- Status: accepted
- Date: 2026-10-09
## Context
Left after ADR 0042: singleplayer's server worker is saturated on `laptop-floor`; memory headroom is
thin (a 4 GB Chromebook gives the tab ~3 GB; page and worker hold 350–400 MB of heap each, the
renderer 2 GB+); and small leads (channel wakeups, wasm-opt, cold start).
Heap snapshots showed ~50 MB in every copy of the game is the program itself (vtables, wrappers,
type data). The page also held 27 MB of Unicode font (271,000 glyphs, three objects each), and both
page and workers kept the whole 40 MB client jar in a buffer.
## Decision
Nothing here is a mod's code. Bracketed options turn a change off.
### World generation: less garbage
A quarter of the terrain step's allocated bytes (`TerrainStepBench` on the JVM) were positional
randoms: three objects to draw one number. In WebAssembly GC each is a real allocation.
- **First draw without the random** (`PositionalRandoms`) [`?randoms=game`]: a Xoroshiro128++
generator's first number is a function of its seeds, so compute it directly.
`PositionalRandomsTest` checks 100,000 positions bit for bit.
- **Density buffers reused** (`SurfaceBuffers`) [`?surfacebuffers=game`]: ore-vein rules filled four
~200 kB float arrays per chunk, too large for V8's young space. A thread now reuses them.
- **Chunks saved at zlib level 1** (`ChunkCompression`) [`?deflate=game`]: 2.7x faster than level 6,
2.4 vs 2.0 kB a chunk; region sectors are 4 KiB, so files barely grow.
`TerrainEquivalenceTest` covers the first two.
### Memory
- **Client jar compacted** (`ZipArchive.compact`): only the entries a mount needs are copied out,
still compressed. The page keeps 7.6 MB (assets and data packs); workers 4.4 MB (data packs,
languages, root files) [`?workerjar=all`].
- **Unicode font packed** (`PackedUnihex`) [`?unihex=game`]: glyph rows in one byte array (~9 MB),
rebuilt on request. `PackedUnihexTest` checks every glyph.
### Small leads
- **wasm-opt on by default for the Fast release build**: `-O3 --closed-world`, with inlining off
(`-aimfs 0 -fimfs 0 -ocimfs 0 -pii 0`). Under a minute on Fast. ADR 0034's inlining made the
fly-through's slowest frames slower; without it they aren't, and the module is 4.6 MB smaller.
`-Pteavm.noWasmOpt` leaves it out.
- **Channel wakeups stay off on the page** (`?wakeups=channel`): 6% faster warm start, but in one of
two singleplayer runs the page hung at spawn. The worker keeps them (ADR 0040).
- **`-Pbenchmark.heapSnapshot`** now snapshots the server worker too.
Looked at and left: smaller allocations (biome search 5%, aquifer 1.5%, ore randoms 1.3%); V8's lazy
compilation (turning it off didn't speed creation and slowed cold start by 2 s); the per-instance
program memory (the compiler's; closed world trims some); the 12 s cold start.
## Results
`laptop-floor`, Fast release, singleplayer benchmark, medians:
| | Before | After | After, changes off |
| --- | ---: | ---: | ---: |
| Create world | 27.7 s | 28.1 s | 27.8 s |
| Save and Quit | 4.0 s | 3.2 s | 3.7 s |
| Page heap live, spawn / fly-through | 384 / 367 MB | 334 / 318 MB | 352 / 335 MB |
| Peak renderer memory | 2389–2569 MB | 2265–2299 MB | 2275–2397 MB |
| Fly-through 1% low / combat 1% low | 16.4 / 34.2 | 20.4 / 39.3 | 18.0 / 23.2 |
The page holds ~50 MB less (jar ~32, font ~17). Creation time is within noise; the fly-through drew
12% more terrain.
wasm-opt, same build with and without:
| | Without | With |
| --- | ---: | ---: |
| Module raw / gzip | 38.5 / 12.4 MB | 33.6 / 11.2 MB |
| Warm start | 8.0 s | 7.5 s |
| Join | 16.0 s | 14.7 s |
| Singleplayer create / open | 28.1 / 21.4 s | 26.5 / 20.3 s |
| Server tick at spawn | 15.6 ms | 13.2 ms |
The fly-through's longest GC pause varies 11–42 ms across all builds; none holds the 16 ms budget
every run. `laptop-floor`'s baselines were re-recorded on this build (the multiplayer ones were still
Compatible's: lobby 32 vs 61 fps on Fast).
## Consequences
- The page holds ~60 MB less; each worker ~35 MB less outside its heap.
- Fast release builds need Binaryen (fetched to `work/cache/binaryen/`, Linux x86-64 only so far);
elsewhere use `-Pteavm.noWasmOpt`.
- Browser-saved chunks take about a fifth more bytes inside the same sectors.
- The worker sees only the jar's data packs and languages (`?workerjar=all` to check if a server
ever needs more).
@@ -0,0 +1,48 @@
# ADR 0044: Defaults and fixes before M4
- Status: accepted
- Date: 2026-10-09
## Context
Six things players met before any of the client's own features: picking a server's version meant
clicking a cycle button through some forty releases; a first start used Fancy graphics at render
distance 16 on a Chromebook; the tab list showed no heads on offline-mode servers; every join showed
the "chat messages can't be verified" toast and every message a not-secure mark; `/login` and a
login plugin's password dialog showed the password as typed; and a respawn sometimes paused the game
as if the player had pressed Escape.
## Decision
- **Version list.** The edit-server screen's version button opens `VersionSelectScreen`: every
version in one scrolling list, newest first under "Auto", with a search box ("1.8" leaves the
1.8 releases). A double-click, Enter or Done picks; the button shows the pick. No patch changed:
ADR 0017's hook adds whatever widget `ServerVersions.button` returns.
- **Potato graphics, the default.** A Potato preset before Fast (`GraphicsPreset.POTATO`, its
values in `PotatoGraphics`): render distance 4, simulation distance 5 (the game's floor), biome
blend off, no smooth lighting, clouds, entity shadows, mip levels or menu blur, minimal particles,
entity distance 50%, the smallest cloud and weather ranges. New installs start on it, and the game
applies a saved preset at every start as it always has; a saved Fancy stays Fancy. The benchmarks
and screenshot diffs pin their own options and don't change.
- **Heads in the tab list** whatever the server's mode: the game drew them only on online-mode
servers. On Eagler servers they are the players' Eagler skins (ADR 0016).
- **No secure-chat warnings.** Offline-mode servers sign no messages, so the join toast and the
per-message not-secure and modified marks are off.
- **Passwords as stars** (`HiddenPasswords`): in chat, the arguments of a login plugin's commands
(`/login`, `/l`, `/register`, `/changepassword` and their aliases, with or without a namespace);
in a server dialog, a text box whose label names a password. Only the drawing changes, through the
box's formatter; the text sent is what was typed. A selection or click inside the stars lands by
the hidden characters' widths, a small error in exchange for no change to `EditBox`'s measuring.
- **No Escape on respawn.** The page turned the end of Pointer Lock while the game wanted the mouse
into an Escape (the browser keeps the player's Escape from the page). A death screen releases the
mouse and a respawn a tick later takes it back, before the page reports the release, so the
release looked like the player's and paused the game. The event queue now remembers that it asked
for the release (`DomEventQueue.exitAsked`); that release makes no Escape, and if the game wants
the mouse again by then it asks for the lock again (a lock the page let go of comes back without a
click; a click takes it back if not).
## Consequences
- Four new patches (budget raised to 124).
- Login commands are still kept in the game's chat history as typed (`command_history.txt`), as
in vanilla.
@@ -0,0 +1,55 @@
# ADR 0045: An Eagler server's pause menu, voice chat in a panel, the player on the title screen
- Status: accepted
- Date: 2026-10-09
## Context
EaglerXServer customizes its clients' pause menu (`pause_menu.yml`): a "server info" button (a
store, rules, a web page), a Discord button, and small icons beside the menu's buttons and title.
It sends this only to clients that ask for the `PAUSE_MENU` capability at login, which Incari
didn't, so servers' buttons were missing. Voice chat (ADR 0019) was a "Voice Chat..." button in the
pause menu that opened a settings screen; Eagler's 1.8 client puts the channel switch in the pause
menu's top right corner, one click away.
## Decision
- **The pause menu message.** Incari asks for `PAUSE_MENU` (capability bit 4) and reads V5 message
`0x18` (`EaglerPauseMenu` in `net`): the two buttons, their modes and addresses, and the icons
(16-bit images up to 64×64, each named by a key such as `icon_discord_L`). `ServerPauseMenu`
keeps it for the connection, uploads each image once, and releases them when the connection
ends.
- **Buttons.** Below the row of icon buttons: the server info button and the Discord button, side
by side when both fit in half the width, else one a row. They open their address in a new tab;
only `http` and `https` addresses open. A server info button meant for an embedded web view of
an address opens that address in a tab instead. One that shows markup the server downloads to a
web view isn't shown: the page has no web view, and the markup can't be opened in a tab without
running the server's HTML on the client's own origin.
- **No Server Links button** when the server sent buttons of its own: they take its place.
- **Icons** are drawn 16×16 beside the text of the buttons they name. The server's own buttons
centre an icon and their text as one group, as Eagler's client does; on the vanilla buttons (back
to game, advancements, statistics, options, disconnect) and the "Game Menu" title they're drawn
over the widgets beside the centred text, so no vanilla button changes. The background and
watermark images aren't drawn.
- **Voice panel.** `VoicePanel` in the pause menu's top right on servers with voice: the channel
as one segmented control (Off, Nearby, Global), whether the microphone is live or the player is
talking, everyone connected with who is talking lit and a mute toggle each, and a link to the
full settings (`VoiceScreen`: volumes, proximity range). Its width leaves the menu's buttons
clear down to a GUI 432 pixels wide. The pause menu's "Voice Chat..." button is gone.
## Consequences
- Three patches in `PauseScreen`: the button hook replaces the voice button's, one more after the
menu's widgets adds the panel and the icons, and one leaves out Server Links.
- Embedded web views (server info markup, and the web view message API) wait for a sandboxed
iframe over the canvas.
## The player on the title screen
The title screen's "Edit Profile (name)" link in the top left corner (ADR 0029) gives way to the
player beside the main buttons, on the right (`TitleProfile`): their model in 3D with their skin
(the game's skin preview, as Edit Profile shows it), turning toward the pointer, their name over
their head on a faint plate like a name tag, and an "Edit Profile" button below. A click on the
model opens Edit Profile too. The model waits for the entity models, which load just after the
title screen first shows (ADR 0026). A screen too narrow to fit it keeps the corner link. The
patch is ADR 0029's title screen hook, which now adds Incari's widgets itself.
@@ -0,0 +1,62 @@
# ADR 0046: The module framework
- Status: accepted
- Date: 2026-10-09
## Context
The client's features number in the dozens, many written in parallel by agents. Each needs an on/off switch,
keybinds, settings with a screen, a HUD place, game events, and saved state. This builds that once:
done when a sample module's settings screen and keybind come from its schema alone.
The look will be redone, so nothing may tie features to the game's widgets. And on a
Chromebook, a feature that's off must cost nothing, and one that's on must not allocate on hot paths.
## Decision
- **`:framework`**, a strict module with no game types: `Module`, `ModuleSystem`, the event bus,
settings, HUD elements, profiles. Only the JDK, JSpecify and Gson's tree API (`BoundaryTest`).
- **Features are `features/<name>` projects** depending on `:framework` only. `:client` lists them
in `incari.client.modules.Features`: no reflection or service loading (the browser's closed world
can't see them). Toggle Sprint is the first.
- **Adapters in `incari.client.modules`** are the only code seeing both sides: hooks fire events,
`ModuleHud` draws, `GameKeys` reads binds.
- **A module declares; the framework runs it:** settings as fields, HUD elements and listeners in
the constructor. Listeners are subscribed only while enabled.
- **Events** are channels with their own listener interface (`TICK`, `MOVEMENT`, `JOIN`, `LEAVE`;
later ADRs add more). Listeners are an array replaced on (un)subscribe: firing allocates nothing,
and an unheard channel costs a length check. A listener that throws is logged and its module
turned off.
- **Settings are a typed schema:** boolean, integer, decimal, choice, colour, keybind; each with an
id (config key), name, tooltip, default, optional `visibleWhen` and `hidden()`. `SettingVisitor`
makes a new kind fail to compile wherever it isn't handled. Reads are primitive.
- **Keybinds use the game's key handling:** each `KeySetting` gets its own `KeyMapping`, outside
Controls and `options.txt`. Every module has a toggle key (unbound by default). The module menu is
Right Shift.
- **HUD elements** draw on a `HudCanvas` in GUI units. Placement (anchor of nine, offsets, scale) is
settings saved with the profile; offsets are hidden, for the editor (ADR 0049). In the browser
they're drawn into the HUD's cached texture (ADR 0030).
- **Colours are tones** (`Tone`: text, muted, accent, positive, warning, negative, background) that
the theme resolves. Player-picked `ColorSetting`s are drawn as given.
- **Profiles:** named JSON sets of module states and settings in `incari/modules/profiles/`. A new
one copies the active one. Saved a second after the last change, or at once on closing a module
screen or leaving a world. Reading is forgiving: bad values keep defaults, broken files aren't
overwritten until something changes, unknown modules keep their entries.
- **The UI is generated through one seam:** `incari.client.ui` (`Theme`, `Ui`, `ControlList`,
`ListScreen`, `SettingControls`) builds the module menu, settings screens and profiles screen. The
restyle replaces `Theme` and `Ui`, and every screen follows.
- **Two patches:** `KeyboardInput.tick` (keys to `ModuleInput`) and `Hud.extractRenderState`
(`ModuleHud` before chat). Ticks, the menu key and the pause button use existing hooks.
## Not yet (at the time)
- World-render and packet events come with their first users, in the framework's own terms (done in
ADRs 0050–0053).
- **Server feature control**: `Module.setEnabled` is the one way on, so a server veto goes there.
- **Language files:** names are English for now.
## Consequences
- A feature is one class plus tests, a dependency line and a line in `Features`. `TestGame` fakes the
game for tests.
- `smokeModules` (desktop) and `modules.steps` (page) check it end to end.
@@ -0,0 +1,51 @@
# ADR 0047: The game's screens changed and redrawn without a patch each
- Status: accepted
- Date: 2026-10-10
## Context
The restyle reaches Incari's screens through `incari.client.ui` (ADR 0046), but players mostly see
the game's: title, pause, options. Each change to one had been its own patch; a restyle of a dozen
screens would add dozens of hooks in vendor code that moves every release. And it must change how
everything looks, not just where it sits.
## Decision
Five hooks; the rest in `incari.client.ui`.
**Changing what's on a screen:**
- **`ScreenEdits.edit(type, edit)`:** after each layout (`init`, `rebuildWidgets`, `resize`), edits
get an `EditedScreen` to find widgets by their label's translation key and move, resize, relabel,
remove, or add Incari's. Edits state where things go, so they're idempotent across resizes; what
they added is removed before they run again.
- **`ScreenEdits.replace(type, replacement)`:** `Gui.setScreen` shows Incari's screen instead.
Edits match a screen's exact class. One that throws is logged and skipped. Nothing registered: a map check.
**Redrawing**, through one `GuiSkin` (`Skins.use`). Each method is asked first and returns whether
it drew, so a skin takes what it knows and the game draws the rest:
- **`widget`:** a whole widget (with `Skins.cursor`).
- **`sprite`, `spritePart`, `texture`:** any GUI sprite or texture by name, wherever drawn, HUD
included. The name carries the state (`widget/button_highlighted`).
- **`background`:** the default backdrop.
While a skin draws, its own calls aren't skinned again. A skin that throws is dropped and the game's
look returns. No skin: a field read. With one: a call per sprite, so skins must not allocate.
## Limits
- Text is the game's font; a new font is a resource, not a hook.
- Screens that draw their own backdrop (title, pause, death, chat) skip `background`; their sprites
still go through the skin.
- A screen that re-lays out without a rebuild or resize puts edited widgets back until its next layout.
- Widgets inside lists aren't the screen's children, so edits can't reach them (the skin can).
- A replaced screen's class is no longer what the game finds: check `instanceof` uses first.
- Existing per-screen patches stay where they add widgets inside layouts.
## Consequences
- The restyle is a `GuiSkin`, edits and replacements; Incari's screens follow with no change.
- `smokeScreens` checks edits (also after a resize), a replacement, a test skin, and a throwing skin dropped.
@@ -0,0 +1,75 @@
# ADR 0048: The client's look, Frost, in Potato and Normal presets
- Status: accepted
- Date: 2026-10-10
## Context
ADRs 0046 and 0047 left a seam for the restyle: Incari screens draw through `incari.client.ui`, game
screens can be edited or replaced, and a `GuiSkin` can redraw any widget or texture. The maintainer
picked **Frost** from mockups: translucent white glass over a cold dimmed backdrop, white text, an
ice-blue accent (`#A9DCFF`), Red Hat Display, compact sizes. Most of the game's GUI is replaced;
health, hunger and experience stay.
It must cost almost nothing on the reference Chromebook, so it comes in two presets.
## Decision
### Presets
`GuiPreset` in `incari/look.txt`, switched live from the module menu's sidebar. Same layout, colours
and font in both:
- **Potato** (default): solid darker panels, no blur, no animation (hover gets an accent edge).
- **Normal:** menu blur (even when the game's blur option is 0), eased hover glows, a light sweep on
buttons, title snow.
The HUD is never blurred or animated: its cost is every frame's. It gets tinted glass.
### Shapes without a shader
`RoundRects` draws rounded fills, outlines and soft shadows in screen pixels from small
anti-aliased nine-slice textures made once per size: one pipeline (`GUI_TEXTURED`), batched, no
custom shader. `Icons` draws line icons the same way.
### The skin
`FrostSkin` redraws by sprite and texture name: buttons, sliders, fields, checkboxes, tabs,
scrollers, tooltips, toasts, slots, hotbar, and every backdrop. `ScreenPanels` draws glass panels
under edited or Incari-laid-out screens.
### Fonts
Red Hat Display (text) and Michroma (wordmark), both OFL, in **Incari's built-in pack**
(`IncariPack`, always on top). The browser has no FreeType, so **every** TrueType provider loads
through `SmoothFont` over a new `PlatformFonts`: FreeType on the desktop, a 2D canvas in the
browser (`CanvasFonts`: glyphs drawn white, alpha read back; coverage from the `cmap`, `FontCmap`).
Glyphs are drawn at the GUI scale so they stay sharp, and again on a scale change. Resource packs'
TrueType fonts now work in the browser too.
### Screens
- **Title** (`TitleLook`, two hooks; `TitleScreen` stays the class): wordmark and icon buttons on the
left, the player on a glass card on the right, language and accessibility top right, version and
copyright at the foot. Realms, the splash and Friends are left out. (The backdrop is now the
menus' photo, `MenuBackdrop`.)
- **Pause** (`PauseLook`): one centred card. Voice and Eagler server icons keep working.
- **Module menu** (`ModuleListScreen`): categories with counts on the left, the preset and profile
below, a search field over module cards with switches; the gear opens settings.
- **Containers** (`ContainerSkin`): inventory, chests, shulker boxes, hoppers, dispensers, crafting
table and furnaces become dark glass with a rounded well per slot. Others keep their texture,
cooled to slate, so what the game draws on it stays put.
- **HUD** (`HudLook`): tab list, sidebar, chat and chat field as rounded tinted glass; modules' HUD
panels rounded.
## Limits
- Older Incari screens (voice, Edit Profile, version list) use the game's widgets, which the skin draws.
- Uncommon containers keep their texture's shapes.
- Normal's eased effects reset when a screen is recreated.
## Consequences
- Patches: blur radius, `SmoothFont` load and rescale, Incari's pack, title (two), tab list,
scoreboard, chat and its field, container labels (two).
- `smokeLook` screenshots the main screens and HUD in both presets and fails if the skin was dropped.
@@ -0,0 +1,70 @@
# ADR 0049: The HUD editor
- Status: accepted
- Date: 2026-10-10
## Context
ADR 0046 gave every HUD element a placement (one of nine anchors, offsets, a scale) and left the
offsets for an editor. The player needs to see elements where they'll be in play, tell them apart
from the game's HUD, move and resize them, and reset them.
A blurred backdrop separates movable elements from everything else. But Potato exists because a
full-screen blur every frame is what a Chromebook can't spare (ADR 0048).
## Decision
### The editor
`HudEditorScreen` opens from **Edit HUD** beside the module menu's search, and from a module's
settings when it has HUD elements. It draws every enabled module's elements through the HUD's own
canvas, so what's shown is what play shows.
- **Frames:** each element on rounded glass, highlighted on hover, accent-edged when chosen, with a
name tag, a resize handle and a bar showing its anchor side.
- **Moving:** drag snaps edges and middles to the screen's sides (2 units in), its middle, and other
elements, with guide lines. Shift or the Snap toggle places freely. Arrows nudge (Shift: 10). Each
move takes the **nearest anchor** (`Anchor.nearest`), so placement holds when the window or GUI
scale changes.
- **Resizing:** scroll over an element, or drag its corner.
- **Undo and reset:** Ctrl+Z per action; Reset for the chosen element or all.
- **Right-click** opens the module's settings. With nothing to place, a card says so.
- **Samples:** elements with nothing to show draw a sample while editing (`HudCanvas.editing()`);
ones a setting hides for good report `isPlaceable() == false`.
A glass toolbar at the top (title, Snap, Reset, Done) with a caption that explains or shows the
anchor and offsets mid-drag.
### The backdrop: blurred in both presets, cheap on Potato
Both presets blur the backdrop, lightly tinted. On **Potato**, `BackdropCache` redraws it **10
times a second** and copies it to a texture after the blur; frames in between skip the level and
HUD entirely and reuse the copy. Elements and toolbar draw every frame, so dragging stays smooth.
Normal blurs every frame. Three hooks: `GameRenderer.extract`, `GameRenderer.render` (don't age
pooled render targets on reuse frames), `GuiRenderer.draw`.
## Results
`laptop-floor`, Fast release, `hudeditor.txt`, 20 s at spawn:
| | HUD only | Pause menu | Editor, Potato | Editor, Normal |
| --- | ---: | ---: | ---: | ---: |
| 1% low (fps) | 32.8 | 12.5 | 36.6 | 50.2 |
| p99 frame (ms) | 26.8 | 21.4 | 20.5 | 19.1 |
| GPU (ms) | 6.4 | 7.2 | 2.3 | 8.1 |
All hold 60 fps at the median; the Potato editor's GPU cost is under a third of Normal's. A first
version recreated the render targets on each refresh (the pool aged them on skipped frames): fixed,
p99 34.2 → 20.5 ms.
## Consequences
- One patch (three hooks).
- `:framework` gains `Anchor.nearest`, `HudElement.bounds/place/resetPlacement/isPlaceable`,
`HudCanvas.editing()`, and `ModuleSystem.drawHud` for one element.
- `smokeHudEditor` and `hudeditor.steps` (with a new `drag:` step) cover it.
## Not yet
- Grouping, multi-element alignment, a grid.
- Elements of disabled modules aren't shown.
@@ -0,0 +1,61 @@
# ADR 0050: The first modules, and what they read of the game
- Status: accepted
- Date: 2026-10-10
## Context
The next modules players asked for are PvP and QoL staples: **Low Fire**, **No Hurt Cam**, **Armor &
Potion View** (with readable durability), **Clear Chat** and **Custom Scoreboard** (the server's
sidebar, placed by the player). Each needs something the framework didn't expose: equipment and
effects, game options, a game HUD part to move, and a say over the fire overlay. As ADR 0046 requires,
all in the framework's terms, no game types.
## Decision
### Framework additions (`incari.framework.game`)
- **`Game`** (`ModuleSystem.game()`): the local player (`PlayerView`), a sample player for the HUD
editor, and game options. `Game.NONE` outside a game; `TestGame` with a `FakePlayer` in tests.
- **`PlayerView`, `ItemView`, `EffectView`:** equipment per slot (count, damage, max) and effects as
the game's HUD shows them (name, level, ticks left, category). Reused holders; names made once per
language, so reading them allocates nothing.
- **`HudCanvas.item`, `HudCanvas.effect`:** draw item and effect icons (with durability bar and count).
- **Held options, `Module.holdOption(GameOption, value)`:** while on, the option takes the module's
value. Off gives back the player's (kept in a hidden setting across restarts). Moving the game's
slider turns the module off and keeps the player's choice. So far `TEXT_BACKGROUND_OPACITY`,
`DAMAGE_TILT`.
- **Game parts, `GamePartElement(GamePart)`:** draws a game HUD part (`SCOREBOARD`) where the player
places it; the game skips it while held. Sized as the game draws it, so the editor works normally.
- **`Events.FIRE_OVERLAY`:** listeners may lower the flames.
### Modules
| Module | Category | What it does |
| --- | --- | --- |
| Low Fire | Visual | Fire overlay lowered 0–25% (default 10%; measured: at 30% it's gone) |
| No Hurt Cam | Visual | Holds Damage Tilt at 0% |
| Armor & Potion View | HUD | Armor and held item with durability (% / uses / of max / none; green, amber below half, red below a fifth); effects with level and time left |
| Clear Chat | HUD | Holds Text Background Opacity at 0 (not Chat Text Opacity, which would hide chat) |
| Custom Scoreboard | HUD | The server's sidebar as a placeable, scalable element |
Strings are made only when what they say changes.
### Patches
Two: the fire overlay's pose lowered (`ScreenEffectRenderer.submit`), and the sidebar handed to
`GameParts` (`Hud`). Clear Chat and No Hurt Cam need none.
## Consequences
- Two patches, 17 changed lines.
- `smokeFeatures` checks all five in a world (options held and given back, a slider turning Clear
Chat off, the sidebar moved) and screenshots them.
- More game data goes into `PlayerView` or `GameOption`; more movable HUD parts are `GamePart`s
with two hooks each.
## Not yet
- The game's own effect icons (top right) still show beside Armor & Potion View.
- Custom Scoreboard's extras (hide red numbers, background opacity) need hooks inside the sidebar.
- Only the main hand is shown with the armor.
@@ -0,0 +1,77 @@
# ADR 0051: Minimap and waypoints
- Status: accepted
- Date: 2026-10-10
## Context
Players asked for a good-looking **minimap**, and **waypoints** with a name, colour and icon, shown
on the minimap and over the world with their distance and an optional beacon-like beam. Both must be
easy to use and cheap on the reference Chromebook.
The framework couldn't yet tell a feature where the player is, draw more than text and rectangles,
follow the camera, draw into the world, keep non-setting data, or open screens. And the browser
refreshes the HUD only a few dozen times a second (ADR 0030), so anything that turns with the camera
would lag.
## Decision
### Framework additions
- **Player position:** `PlayerView.x/y/z()` (interpolated), `heading()`, `dimension()`, `isDead()`;
`Game.world()` names the world stably (`server/<address>`, `world/<folder>`).
- **Waypoints belong to the framework** (`incari.framework.waypoint`), since minimap and waypoints are
separate features. One file per world, `incari/modules/waypoints/<world>-<hash>.json`, saved a
second after a change, independent of profiles. `ModuleSystem.waypoints()`.
- **Drawing:** `HudCanvas.shape`, `disc`, `ring`, `terrain` (the minimap), the `EDGE` tone, fractional `push`.
- **Live HUD elements** (`HudElement.isLive()`): drawn every frame with the crosshair, not with HUD refreshes.
- **Events:** `OVERLAY` every frame on a `WorldOverlay` (with `project`: a world point on screen, or
which way to turn); `WORLD` during the world's submit, on a `WorldCanvas` (`beam`).
- **Screens:** `Game.openWaypoints()`, `Game.editWaypoint()`; `ActionSetting` for a button in settings.
### Modules
| Module | What it does |
| --- | --- |
| Minimap (HUD) | Live map; round or square; turning or north-up; 7 zooms (= and -); waypoints (on the edge when beyond); compass; coordinates; world map on M; explored map remembered |
| Waypoints (Utility) | A glass tag per waypoint (icon, name, distance), a beam, edge arrows for those off screen; N marks here, U lists them; deaths leave one |
- **Tags** are drawn on the overlay, not in the world: crisp at any distance, never hidden by
terrain, placed every frame. Off-screen waypoints get arrows on the screen's edge, spread apart.
- **Beams** are the game's beacon beam, so they look like one and terrain hides them. Beyond the fog
they're moved in along the line of sight and shrunk, so a waypoint 600 blocks off still shows.
- **Minimap terrain** (`MapTerrain`): a wrapping 512×512 texture, one texel per block. Each chunk is
drawn once into its square (map colour, biome tint, slope shading, water depth). Under a ceiling
(the Nether) it's a slice at the player's height. Up to 1.5 ms a tick, nearest first; nearby chunks
redrawn every half second. Drawn as a triangle fan, so turning is free; no custom shader.
- **Screens:** the list (search, nearest first, hide, edit, delete with a second click) and the
editor (tag preview, 12 colours or hex, 8 icons, coordinates, Here, beam). Frost look; new icons.
### World map and remembered map
- **World map** (`WorldMapScreen`, M): drag, zoom round the pointer, the player as an arrow, waypoint
tags. Click a waypoint to edit; right-click to add one. Each 512×512 region is a texture made as it
comes into view; up to 48 kept while open.
- **Remembered map** (`MapMemory`): every chunk the minimap draws is kept as its 256 colours, by
32×32-chunk region, per world and dimension. With **Remember explored map** on (default), regions
are saved to `incari/map/<world>/<dimension>/<x>.<z>.map` (deflated RGB, 100–250 KB a full
region). Only top-down colours are kept: chunks would be tens of times larger.
### Patches
Two: the live HUD beside the crosshair (`Hud.extractRenderState`), and the world event after
particles (`LevelRenderer.submitFeatures`).
## Consequences
- Two patches, 6 lines.
- `smokeWaypoints` and `waypoints.steps` cover both modules, the screens, the world map and saving.
- Remembered maps grow with exploring (100–250 KB per 512×512 blocks).
- Cost while on: ≤ 1.5 ms a tick drawing new chunks, 1 MB of texture, a few draws per waypoint a
frame. Off: nothing.
## Not yet
- Cave maps in the Overworld; entities on the map; another dimension's world map.
- Waypoints shared from servers or in chat; per sub-world sets.
- Teleport to a waypoint; sorting the list by name.
@@ -0,0 +1,54 @@
# ADR 0052: The HUD modules: Keystrokes, CPS, FPS, Reach, Coordinates, Shield & Totem
- Status: accepted
- Date: 2026-10-10
## Context
Next the player asked for the PvP clients' HUD staples: **Keystrokes**, **CPS**, **FPS Display**,
**Reach Display**, **Coordinates**, and a **Shield & Totem HUD**. Each needs something the framework
didn't offer: clicks, a hit's distance, held binds, frame rate, biome, item ids, cooldowns, counts.
## Decision
### Framework additions
- **Events:** `CLICK` (mouse presses over the world, no screen open) and `ATTACK` (an entity hit,
with the reach from the eyes to where the crosshair met its box).
- **`ClickCounter`:** a ring of 64 press times; `perSecond(now)`.
- **`Game`:** `isDown(GameKey)` and `keyName(GameKey)` for the nine movement/attack/use binds as
bound ("W", "LMB"); `fps()`; `millis()`; `item(id)`.
- **`PlayerView`:** `biome()` (localized, cached) and `count(id)`. **`ItemView`:** `id()` and
`cooldown()`.
- **`TextElement`:** one line of text on glass, in a tone or a chosen colour, width kept steady as
digits change. **`Tone.ON_ACCENT`.**
- `TestGame`/`FakePlayer` fake all of it.
### Modules
| Module | Shows | Default place |
| --- | --- | --- |
| Keystrokes | W A S D, LMB/RMB with clicks per second, space; lit while held | Top right, below the minimap |
| CPS | "12 \| 4 CPS" (left, right or both) | Left, stacked |
| FPS Display | "120 FPS" (three formats), optional colour by rate | Left, stacked |
| Reach Display | "3.04 blocks" for 3 s after a hit; long hits amber if asked | Left, stacked |
| Coordinates | X Y Z, facing and axis, biome, the matching Nether/Overworld spot | Left, below |
| Shield & Totem HUD | The shield's durability by wear, "Disabled" during an axe cooldown; totems carried | Beside the hotbar |
Keystrokes shows the player's own bindings (AZERTY reads "Z Q S D") and what the game reads as held,
not Toggle Sprint's latch. Text is rebuilt only when it changes; none of these is live.
### Patches
Two, three lines each: `MouseHandler.onButton` (clicks) and `Minecraft.startAttack` (attacks).
## Consequences
- Two patches, six changed lines.
- `smokeHudModules` clicks a villager, holds keys, and checks clicks, reach (~2.3 blocks), FPS,
bind names, totem count, shield id and biome. `newmodules.steps` covers the page.
## Not yet
- Keystrokes lights at the HUD's refresh rate (every 50 ms in the browser), without a fade.
- Reach is measured client-side; a server's lag compensation may differ.
@@ -0,0 +1,61 @@
# ADR 0053: The visual and combat modules: Cooldown, Crosshair, Freelook, Weather, Low Shield, 1.7
- Status: accepted
- Date: 2026-10-10
## Context
The second set the player asked for changes how the game looks: **Cooldown Indicator**,
**Crosshair Editor** (presets, sliders, a 15×15 grid), **Freelook** (hold Left Alt; toggle and
invert options; no per-server blocking, by choice), **Weather Changer** (client weather and a held
time of day), **Low Shield**, and **1.7 Animations** (block-hit and held-item poses only).
## Decision
### Framework additions
- **Events:** `CROSSHAIR` (draw your own; the game's is then skipped), `TURN` (the mouse's turn,
consumable), `CAMERA` (yaw and pitch, settable without turning the player), `HELD_ITEM` (per hand
in first person: lower, legacy poses, swing while using). Each is one reused object and costs a
length check when nobody listens.
- **`Game`:** `attackStrength()`, `onTarget()`, `perspective()`/`setPerspective()`, `overrideSky(Weather, timeOfDay)`.
- **`GameOption.ATTACK_INDICATOR`**, held by index; options gained `max()` so a held choice survives.
- **`GridSetting`** with `GridScreen` (draw, erase, clear, reset, preview).
- **`HudCanvas`:** coloured `disc`/`ring` and `arc`.
### Modules
| Module | Category | What it does |
| --- | --- | --- |
| Cooldown Indicator | Combat | Holds the game's indicator Off and draws the charge as a bar, ring or percentage; hidden when charged unless on a target |
| Crosshair Editor | Visual | Cross, T, circle or dot from sliders, or a pixel grid; colour, opacity, on-target colour; presets |
| Freelook | Visual | Left Alt (hold or toggle) turns the camera, not the player; release restores the view |
| Weather Changer | Visual | Clear, rain, thunder or snow, and an optional held hour. Answers where the client reads weather; the server's weather runs on underneath |
| Low Shield | Visual | First-person shield lowered (default 35%), optionally only when not blocking |
| 1.7 Animations | Visual | Block-hit swing; 1.7's flat item, rod and sword-blocking poses (where swords block, ADR 0020) |
The **block-hit** only animates the arm on the client (`LivingEntity.swing`); no extra packet reaches
the server. The **1.7 poses** are 1.7's own transforms, applied after undoing today's first-person
display transform. Their numbers were checked against Animatium (a PolyForm Shield mod); none of its
code is used, only the figures, which are Mojang's own.
### Patches
Four: crosshair blit skip (`Hud.extractCrosshair`); turn and camera (`MouseHandler.turnPlayer`,
`Camera.alignWithEntity`); held item (`FirstPersonHandsAndItemsRenderer`, four hooks); weather
(`Level`, `WeatherEffectRenderer`, `ClientClockManager`). Cooldown Indicator needs none.
## Consequences
- Four patches, 42 changed lines.
- `smokeVisualModules` screenshots every crosshair preset, the cooldown bar and ring (checking the
game's option is held and given back), weather over the server's rain, Freelook, Low Shield and
1.7 poses. `TestGame` gains matching fixtures. `newmodules.steps` covers the page.
## Not yet
- **Legal review of 1.7 Animations' figures before release** (numbers from Animatium, a
PolyForm Shield mod, though they are Mojang's own).
- 1.7 Animations isn't checked beside a real 1.7.10 client; the bow's pull isn't 1.7's.
- Crosshair Editor blends normally; the game's inverts what's behind it.
- Weather Changer's held time applies to the dimension's day clock only.
@@ -0,0 +1,57 @@
# ADR 0054: The screen modules: Shulker Tooltips, Screenshot Manager, Theme Editor
- Status: accepted; Screenshot Manager and the Theme Editor changed in ADR 0062 (the gallery is the
client's; Theme is always on, with fonts)
- Date: 2026-10-10
## Context
The third set the player asked for adds screens: **Shulker Tooltips** (contents at a glance), a
**Screenshot Manager** (view, name, sort, download; F2 optionally to the clipboard), and a **Theme
Editor** (presets, colours, opacity, rounding, live on menus and HUD, shared as a code; no extra
fonts at the time, for download size).
## Decision
### Framework additions
- **Events:** `CONTAINER_TOOLTIP` (whether Shift is held; listeners set `preview`, `tinted`) and
`SCREENSHOT` (the saved file's name, on the game thread).
- **Menu buttons:** `Module.menuButton(...)` shows a module's buttons on the title and pause menus
while it's on.
- **`Game`:** `openScreenshots()`, `copyScreenshot()`, `applyTheme(ThemeColors)`, `clipboard()`,
`copy()`. **`ThemeColors`** with `FROST`.
- **`PlatformShell.setClipboardImage(png)`:** the browser's Clipboard API; false on the desktop.
### The theme became the player's
`Theme`'s colours and radii were constants. Now they're static fields every screen reads as it draws,
and `Theme.apply` derives them all from `ThemeColors` (button edges from the text colour, HUD glass
from the panel colour, readable text on the accent). Frost's own values are restored exactly.
### Modules
| Module | What it does |
| --- | --- |
| Shulker Tooltips | A container item's tooltip shows its slots nine across with counts, on the box's dye colour, in place of the first five names; optionally only with Shift |
| Screenshot Manager | A gallery (`ScreenshotsScreen`): thumbnails sorted by date or name; a viewer with arrows; rename, delete (confirmed), download or copy; select several to download as one zip. "Copy to clipboard" for each F2 |
| Theme Editor | Presets (Frost, Midnight, Ember, Mint, Rose, Mono) or custom colours, opacity and rounding, applied next tick; copy and paste theme codes (`incari-theme:…`) |
Thumbnails are made one a frame as they scroll into view (a full PNG decode costs tens of ms on a
Chromebook). The gallery works on the screenshots folder, kept in OPFS.
### Patches
Two: `Screenshot.grab` (the event after saving) and the tooltip image path (`ItemStack`,
`ClientTooltipComponent`, `ItemContainerContents`), answered from one event so they agree.
## Consequences
- Two patches, 13 changed lines.
- `smokeScreenModules` covers the tooltip, F2 events, the gallery and viewer, themes on menus and
HUD, and Frost restored. `newmodules.steps` covers the page.
## Not yet
- Copying a picture works only in the browser.
- The gallery has no search and no grouping by day.
@@ -0,0 +1,29 @@
# ADR 0055: The built-in packs in the page, and Old Textures
- Status: accepted
- Date: 2026-10-11
## Context
The game's built-in packs, **Programmer Art** (pre-1.14 textures) and **High Contrast**, are zips in
the asset index, not the jar. The page never fetched them, so the Resource Packs screen listed
neither. Players asked for **Old Textures**, a module that switches Programmer Art and follows the
pack screen.
## Decision
- **Fetched at start** (`WebAssets`, 0.7 MB, before the game starts, since the repository lists them
before the first reload) and **copied by `./incari build`**. Mojang's files on the builder's machine,
as with sounds; nothing committed. A failed fetch leaves them out.
- **`Game.packSelected(id)` / `selectPack(id, on)`:** select as the Resource Packs screen does (at
the pack's default place, under Incari's fixed pack), then save and reload. No patch.
- **`Module.followPack(id)`:** on turns the pack on, off turns it off; each tick the module's switch
follows the game's pack, so the pack screen moves the module too. At start the game's choice wins
(no extra reload).
- **Old Textures** (Visual): `followPack("programmer_art")`, no other settings.
## Consequences
- 0.7 MB more on a first visit.
- Toggling reloads resources, as the pack screen does: seconds on the floor device.
- `smokeFeatures`, `PackSwitchTest`, `OldTexturesTest` and `old-textures.steps` cover it.
@@ -0,0 +1,53 @@
# ADR 0056: The look's first performance pass
- Status: accepted
- Date: 2026-10-11
## Context
The look (ADR 0048) builds screens from rounded rectangles, icons and shapes, each a small texture.
Nobody had measured it. Four costs grew with the number of controls:
- **A shape was many render states:** a rounded rectangle was nine blits, each a state with its own
pose copy, bounds, texture setup and lookup. A button was up to 26; the inventory over 800.
- **The GUI places each state by searching what's under it,** which grows with the square of the
states, and an edge over its fill always starts a new layer.
- **A texture per corner size and icon,** so each change cost a draw call.
- **The skin matched sprite names with an `equals` chain** (up to 35 comparisons) before every sprite.
## Decision
- **One atlas for the look's images** (`UiAtlas`): corners, icons, shapes, and a white square for
plain fills, in shared 512-pixel pages, so they batch.
- **One render state per shape** (`RoundRects.box`: shadow or glow, fill and edge as one object).
Buttons, wells, tabs, toasts, panels, slot wells, chat field and HUD editor frames use it. Icons
and shapes go straight in as plain blits. The title's 110 snowflakes are one state.
- **Two accessors on `GuiGraphicsExtractor`** (one patch): the current scissor and a submit, so
states built outside it clip inside scrolled lists. `Circles` now clips too.
- **`FrostSkin.sprite` uses a map** from name to kind.
- **A GUI player skin is redrawn only when it changes** (`SkinPictures`, one patch): the title
screen's player was re-rendered every frame. The title player's turn now settles instead of easing forever.
- **`Circles` uses a corner table;** menus stop building strings every frame.
Nothing looks different (checked with `smokeLook` and side-by-side crops).
## Results
`menus.txt` benchmark, desktop with CPU throttled 4x, Fast release, means per frame:
| Scenario | Extract (ms) | Render submit (ms) | Draws | GCs / 20 s |
| --- | ---: | ---: | ---: | ---: |
| HUD alone | 0.52 → 0.49 | 1.14 → 1.13 | 27 → 26 | 8 → 7 |
| Module menu, Potato | 2.87 → 1.02 | 2.60 → 1.69 | 56 → 44 | 300 → 184 |
| Pause menu, Potato | 1.29 → 0.62 | 1.85 → 1.48 | 51 → 44 | 226 → 117 |
| Inventory, Potato | 7.13 → 0.75 | 3.41 → 1.80 | 57 → 48 | 170 → 97 |
| Inventory, Normal | 7.12 → 0.71 | 3.58 → 1.96 | 68 → 54 | 170 → 112 |
The inventory's 7 ms was mostly the layer search over 800 blits. The page is capped at 60 fps, so
the saving is CPU a Chromebook doesn't have.
## Left for later
- The screenshot gallery decodes full screenshots on the render thread for thumbnails.
- The game's GUI sort boxes keys and hashes texture records on every comparison.
- The atlas never frees a page; a GUI scale change paints every size again.
@@ -0,0 +1,54 @@
# ADR 0057: One HTML file (`./incari build --html`)
- Status: accepted
- Date: 2026-10-11
## Context
The goal: an offline HTML file a player opens from disk, as Eaglercraft's offline download
works. ADR 0028 left it out because `file://` pages can't do what the folder relies on. Measured in
Chromium:
- `fetch` of a neighbouring file fails, and so does `<script src>` unless it's a Blob URL.
- Module workers can't start from a Blob URL; classic ones can.
- A worker can't read the page's Blob URLs, only its own.
- OPFS throws; IndexedDB works (shared with Blob URL workers). No service worker.
The game loads files from the page and from four kinds of worker (storage, mesher, the server worker
and its terrain helpers), each fetching by URL.
## Decision
- **`./incari build --html [--out <file>]`** writes the web folder (without sound files) and
`:app-web:singleFile` (`SingleFile`) packs it into one file, default `dist/incari.html`.
- **Every file is a `<script type="application/x-incari-file">`** with path, type and base64
contents (gzipped where it saves a tenth). Service worker, `.htaccess` and `README.txt` stay out.
- **A file shim in every realm** (`offline.ts`): `fetch` of an embedded file answers from a Blob;
`importScripts` and `new Worker` of embedded scripts start classic workers from the shim's own
source, which installs the shim, receives the files (shared Blobs), then runs the script
(`import()` for modules, with relative imports rewritten). Everything else (WebSockets, servers)
goes to the browser as usual.
- **Lazy decoding:** scripts are decoded at once; everything else on first fetch, so the unpicked
build and unused languages are never decoded. Workers ask the page for files they lack.
- **Two hooks** where scripts load without `fetch` (`boot.ts` and `game-worker.ts` use
`incariFiles.url`). The game's Java code is unchanged.
- **The notice travels with the file:** a comment at the top says never to share it; `SingleFile`
only overwrites its own files; the build refuses an output git would track.
- **`browserCheck -Pbrowser.html=<file>`** runs checks against a file.
- **The folder's client jar is cut to resources only** (`WebFolder.resourcesOnly`): 41 → 12 MB, for
both outputs.
## Results
87 MB with both builds (languages, panorama, font and packs 32 MB, Compatible 28, Fast 15, jar 10);
~60 MB with `--only fast`. From `file://` in headless Chromium: title at 60 fps in both builds; in
Fast, singleplayer creates, saves, survives a reload from IndexedDB and reopens. Firefox reaches the
title. Not measured: the Chromebook, Firefox singleplayer, Compatible singleplayer.
## Consequences
- Undecoded file text stays in the DOM (15–28 MB for the unpicked build, 24 for languages), and the
browser parses the whole file before the loader starts.
- The file was silent at first; ADR 0062 added every sound but music, re-encoded smaller.
- Every page opened from disk shares one origin in Chrome, so copies of the file share worlds.
- Licensing is unchanged: it's a build, for the person who made it.
@@ -0,0 +1,95 @@
# ADR 0058: Incari accounts and the online service (client side)
- Status: accepted
- Date: 2026-10-12
## Context
Friends, messages, cosmetics and seeing who else uses Incari need an identity that lasts across
servers. A Minecraft name can't be it: on offline-mode and Eagler servers anyone can take any name.
Incari runs its own online service. Its server is closed source and not in this repository; the
protocol is public ([`docs/online-protocol.md`](../online-protocol.md)). This ADR is the client side.
Already decided: accounts are **optional**; a **username and password** only (no email or personal
data); **recovery codes** instead of email; cosmetics belong to the account; players can block.
Constraints: many players are students playing at school, so collect little and never let strangers use the
service to find someone. Schools may block the service but not game servers, and the game mustn't
notice. The page may run from `file://` (origin `null`). The browser has only WebSockets.
## Decision
### Connection
- **One `wss://` connection**, opened after the title screen on the background pool, never holding
up a join. JSON text frames with numbered requests, answers and events. The first message each way
states the protocol version.
- **URL set at build time** (`incari.online.url`; empty turns accounts off). No keys or secrets in
the client.
- **Back-off:** 1 s doubling to 5 minutes with jitter, reset after a minute connected. Offline, the
game carries on; nothing waits on the service.
### Accounts
- **Sign-up:** username (3–16 of `[A-Za-z0-9_]`, unique ignoring case, separate from any Minecraft
name), password (10+ characters, not a common one), and a **proof of work** sized for about a
second on the reference Chromebook, solved on the background pool, in place of a CAPTCHA.
- **Recovery codes:** ten at sign-up, shown once with Copy and Download, and the player confirms
saving them. One code plus a new password resets it. No password and no code: the account is
lost, and the screens say so.
- **Sign-in** returns a session token, stored in `incari/online/session.json` (never the password).
- **Account screen** from the title screen's player card (not a module): Sign In, Create Account,
Forgot Password; signed in, Change Password, New Recovery Codes, Sign Out, Sign Out Everywhere,
Delete Account. Password fields are starred whole (`HiddenPasswords`).
- **Errors are general:** a failed sign-in says only "wrong username or password", and rate limits
look the same, so usernames can't be probed.
### Presence and lookups
- **Joining a world** reports a `serverHash` (SHA-256 of the normalized address, or a relay code),
the Minecraft name there, and the plain address only if "Show friends which server I'm on" is on
(default on; friends only). Singleplayer sends nothing. Leaving clears it.
- **Lookups:** the client sends tab-list names; the service answers only for names an account has
reported on the asker's own `serverHash` right now, with a per-server id (so accounts can't be
followed between servers), friend status and cosmetics. Two accounts claiming one name get nothing.
- **Modules see it** through `ModuleSystem.online()` (`incari.framework.online.Online`): signed in,
account name, `incariPlayer(UUID)`, friends, events.
### Blocking and reporting
- **Blocks are on accounts** and **enforced by the service**: no requests, no messages, neither shown
to the other as an Incari player. The blocked player isn't told.
- **Reports** carry a reason; the service keeps the reported account's recent messages to the reporter.
### Code
- **`:online`** (depends on `platform-api`, `framework`): connection, protocol, session store, proof
of work, presence and lookups. No game types; tested against an in-process fake.
- **`client`'s `incari.client.online`:** the screens, and a tick that reports joins and reads the
tab list, so no patch is needed.
- **`framework`'s `incari.framework.online`:** the `Online` view, events, a test fake.
## Consequences
- With the service blocked, the game is unchanged apart from "offline" on the account screen.
- The service learns, per signed-in player: username, server hashes and names there, the plain
address if shared, friends, blocks, messages, and connection IP. Its privacy notice says how long.
- `serverHash` keeps plain addresses out of storage and logs; it isn't protection against someone
with the database and a list of popular servers.
- Different addresses for one network split players into groups that can't see each other (accepted).
- A stored token is readable by anything in the page's origin. The page loads no third-party
scripts, and must stay that way. Sign Out Everywhere is the remedy.
- The service must accept origin `null` for offline HTML builds; it yields nothing without credentials.
## Built (2026-10-12)
- `:online`: `OnlineService`, `WorldPlayers`, `ServerHash`, `ProofOfWork` (4,096 nonces a step, no
allocation), `SessionStore`, `Backoff`, `Credentials`, `RecoveryCodes`.
- `incari.framework.online`: `Online`, `IncariPlayer`, `FakeOnline`.
- `incari.client.online`: the account screens on one `FormScreen`.
- `tools/onlinedev` serves the fake service on `ws://127.0.0.1:8090/v1/ws` for trying the screens.
- `smokeOnlineA` + `smokeOnlineB`: two clients make accounts, see each other, go through friends,
messages and blocking (ADR 0059), then delete their accounts. Passed against Incari's service.
- Since built: the Incari badge (ADR 0062).
- Friend requests from the tab list were settled by ADR 0059 (by per-server id).
@@ -0,0 +1,78 @@
# ADR 0059: Incari chat: friends, messages and the chat menu
- Status: accepted
- Date: 2026-10-12
- Builds on: ADR 0058 (accounts and the online service)
## Context
ADR 0058 left friends, messages, and where blocking and reporting happen in a world for this ADR.
The client's documents set the wire format.
Decided by the maintainer:
- **One place for people: the Incari chat menu**, from a key or a button below the chat box.
- **Laid out like Discord:** people on the left, the conversation on the right.
- **Friends always above other Incari players**, and styled differently.
- **Messages and friend requests can each be turned off completely.**
- **Block, Add Friend, Accept and the like are easy to reach.**
- **No age gate:** no real names, active moderation, free blocking. An age question only teaches
people to type a higher age.
## Decision
### The chat menu
- **Opens with the Friends key** (O) and an **Incari Chat** button below the chat box (with an
unread count). Mojang's Friends overlay needs a Microsoft account, so the key was dead; one patch
hands it to `ChatMenu.toggle`. The button is a `ScreenEdits` edit, no patch.
- **Left bar:** Add Friend; **Friend Requests** (Accept and Decline on the row, Cancel for sent);
**Friends** (online first, presence dot, server if shared); **On This Server** (other Incari
players, with skin faces, below every friend); your own strip with Chat Settings.
- **Conversation:** a header with labelled Unfriend/Add Friend, Block (second click within 4 s),
Report. Messages grouped by sender, Discord-style. Sending shows dimmed; refused shows red "Not
delivered". Scroll up for older pages.
- **Chat Settings:** who can message you, friend requests on/off, sharing your server, Blocked
Players, account.
- **Signed out**, it explains accounts and offers Sign In. If the service lacks friends support, it
says so; blocking and reporting still work.
- **Toasts** for messages and requests while the menu is closed.
### Friends
- **Requests go to a username, or to an Incari player on your server** (by `pid`). Usernames are
shared only between friends; sending a request shares yours.
- **A request to someone with requests off, or across a block, answers `ok` and is never
delivered.** Unknown usernames are `bad_request`.
- **Crossing requests make a friendship.** Friends see each other's usernames, online state, and
server if shared. **Blocking a friend ends the friendship** on both sides.
### Messages
- **Who can message you:** `everyone` (friends and Incari players on your server), `friends`
(default), or `nobody`. Refused or blocked messages both answer `closed`, indistinguishably.
- **Friends' messages are kept 30 days** and delivered later, with unread counts and history pages.
- **Same-server messages** go by `pid` and live only in the client while both are there (the service
keeps them for reports, never as history).
- **≤ 500 characters**, trimmed. Shown at once as sending, then sent or failed.
### Code
`:online`'s `Social` and `OnlineService` requests (`FakeService` answers them); `client`'s
`ChatMenuScreen`, `ChatMenu`, `ChatToast`, `Avatars`, and new icons. Wire format in
`docs/online-protocol.md` (new types only; older services answer `bad_request`).
## Consequences
- With messages `nobody` and requests off, nobody can reach the player through Incari; they can
still reach out themselves.
- A `pid` conversation can't continue after either player leaves the server.
- The Friends key opens Incari Chat; Mojang's friends screen never worked without a Microsoft account.
- One more patch.
- Tests: `SocialTest`; tried on the desktop against `tools/onlinedev` with scripted peers;
`smokeOnlineA` + `smokeOnlineB` end to end (see each other, `pid` request, messages, a block, accounts deleted).
## Open
- Group conversations, read receipts and typing indicators aren't planned.
- Unread counts for same-server players live only in the client.
@@ -0,0 +1,54 @@
# ADR 0060: The update notice
- Status: accepted
- Date: 2026-10-12
- Builds on: ADR 0058 (the online service)
## Context
Incari Client is published as source, and players play builds that whoever hosts them made
(`./incari build`, `docs/self-hosting.md`). Nothing told a player, or the person hosting their
build, that a newer release is out. The maintainer asked for a notice on the title screen when there is
one, linking to the public GitHub repository, with the information coming through the backend, and
for dev builds never to show it (tests aside).
The client had no version of its own until now: only the game's (26.3).
## Decision
- **The client has a version**, `incari.version` in `incari.properties` (`0.1.7` now), raised with
each release, and the public repository's URL, `incari.repository`
(`https://github.com/incari-client/incari-client`). `:client`'s `buildInfoSource` writes
both into `incari.client.IncariBuild`, with `RELEASE`: whether the build is a release build
(`-Pteavm.release`, which `./incari build` and `:app-web:webFolder` require).
- **The service names the latest release in its `hello` answer** (`release: {"version"}`,
`docs/online-protocol.md`). Every connection says hello, signed in or not, so no extra request
and no new connection. `OnlineService.latestRelease()` keeps the last one named, checked against
`Releases`' form (one to four whole numbers) so nothing else the service sends reaches the screen.
- **The client compares**, and shows the notice only when the named release is newer than its own
(`Releases.newer`). A service answering `update` (this protocol no longer served) shows it too,
without a version.
- **The URL is the client's, not the service's.** The notice always leads to the built-in
repository, through the game's own link confirmation (`ConfirmLinkScreen`), so a wrong or
compromised service can't send players elsewhere.
- **Release builds only.** A dev build's version is the one being worked toward, and its developer
doesn't need telling. Tests turn it on: `-Dincari.updates=on` on the desktop
(`-Pincari.updates=on` for `:app-desktop:run`), `?updates=on` on the page.
`tools/onlinedev --release <version>` names a release to test against.
- **On the title screen**, centered at the top: "Incari Client 0.2.0 is out", with a "GitHub" hint
and a tooltip, in the menu buttons' look. It's laid out with the screen, hidden until the service
answers, and kept clear of the small screens' links and the language and accessibility buttons.
It isn't dismissible: it goes away when the build is updated.
## Consequences
- With no online service (`incari.online.url` empty, or unreachable), there's no notice.
- The backend has to be told the latest version at each release (its configuration), as well as
`incari.version` being raised here. A release whose `incari.version` wasn't raised would tell its
own players to update to what they have only if the backend were ahead of it.
- Switching between release and dev builds rewrites `IncariBuild`, so `:client` recompiles the
classes that use it.
- Tests: `:online`'s `ReleasesTest` and `OnlineServiceTest` (`release` from hello, ill-formed ones
ignored), `:client`'s `UpdateNoticeTest` (a dev build never shows it; newer shown, the same or
older not). The notice was checked on the desktop against `tools/onlinedev --release 0.2.0`: shown
at the top, its link confirmation opening the repository's URL.
@@ -0,0 +1,98 @@
# ADR 0061: Cosmetics: the Wardrobe, worn cosmetics, emotes and personal effects
- Status: accepted
- Date: 2026-10-12
- Builds on: ADR 0058 (cosmetics belong to the account), ADR 0046 (modules), ADR 0048 (the look)
## Context
ADR 0058 made cosmetics belong to an Incari account, and its lookups already carry cosmetic ids.
This ADR decides what they are, how they're drawn and picked, and how the service learns what's worn.
Asked for: capes (animated too), hats, wings and back items, name tag colours, trails, emotes, saved
outfits, and personal effects only the player sees; easy and familiar to use; a switch to hide
others' cosmetics.
Constraints: nothing may cost a frame where it isn't seen (4 GB Chromebook); no Mojang art; no
one-of-a-kind cosmetics (they'd let an account be followed between servers); the service is one
WebSocket, no HTTP.
## Decision
### Two kinds
- **Worn cosmetics** (others see them): capes, hats, wings and back items, name tags, trails (one of
each), and emotes (owned and played). Picked in the **Wardrobe**, not the module menu.
- **Personal effects** are ordinary modules only the player sees: Block Outline, Hit Color, Enchant
Glint, Hit & Kill Effects.
### Catalog and art
- **37 cosmetics** in `:online`'s `Catalog`: 7 capes (4 animated), 6 hats, 4 back items, 8 name tags,
4 trails, 8 emotes. Ids `<slot>.<name>` never change. All free for now; the service decides ownership.
- **Art is painted in code** (`CosmeticArt`, `CosmeticModels`): no images, nothing of Mojang's. Moving
capes repaint 10x a second, only while seen in the last 2 s.
- **The service sends only ids;** unknown ids are skipped, so the catalog can grow on the service first.
- **No uploads, no unique cosmetics.**
### Drawing
| Cosmetic | How |
| --- | --- |
| Hats, back items | One render layer (`CosmeticsLayer`) through the game's model submits, so instancing takes them. Hidden under helmets and elytras; not drawn past 48 blocks or on invisible players |
| Capes | The game's own cape with the cosmetic's texture, so physics, elytra and the Cape option all work. A backpack hides the cape |
| Name tags | Restyle the name unless the server colours it (a team colour means something) |
| Trails | The game's particles behind a moving player: every other tick, ≤ 12 a tick in total, within 32 blocks |
| Emotes | Pose arms and head at the end of `setupAnim`, eased over 4 ticks; legs still walk. Your own emote turns the camera to face you; moving ends it |
`Cosmetics` works out each player's `Worn` once, when their list or emote changes, not per frame.
### Wardrobe
- **Laid out like the module menu:** kinds on the left with counts, a card grid, the player in 3D on
the right. Hover tries on; click wears; click again (or None) takes off. The preview turns to show
capes and wings and can be dragged.
- **Outfits:** up to 12 saved per device; **Take Off All**.
- **Under the preview:** "Incari players see these" or "Only you see these" with Sign In, and the
**Show others' cosmetics** switch (per device).
- **Opens from** the title card's Cosmetics button, Incari Settings, and the module menu.
- **Emote wheel:** hold **G** in a world.
### Service sync
- `:online`'s `Wardrobe` keeps worn, owned, outfits and the switch in `incari/online/wardrobe.json`.
Everything works without an account (you see your own).
- Changes apply at once; `equip` is sent once clicking stops (≤ 1/s), and after a reconnect.
- On sign-in the account's wardrobe wins, unless it wears nothing and the device does: then the
device's carries over.
- Protocol: `wardrobe`, `equip`, `emote`, their events, and `not_owned`. A service without them
answers `bad_request` and the client stays device-only.
### Personal effects
- **Block Outline:** colour, opacity, width, optional fill. High contrast keeps the game's outline.
- **Hit Color:** the hurt tint's colour and strength (repaints the overlay texture's rows).
- **Enchant Glint:** the glint textures repainted in the chosen colour; off restores the game's.
- **Hit & Kill Effects:** one of 10 particle effects on hits, bigger on kills (within 3 s), optional sound.
- Framework: `Game.overrideBlockOutline`, `overrideHitColor`, `overrideGlintColor`, `effectOnTarget`,
`Effect`, and the `KILL` event.
### Patches
Four: a field on `AvatarRenderState` and the layer in `AvatarRenderer`; emotes' pose in
`PlayerModel.setupAnim`; Block Outline in `LevelRenderer.submitBlockOutline`; Hit Color in `OverlayTexture`.
## Consequences
- No cost for a player who wears and sees none: the layer returns at once.
- Others' cosmetics need both players signed in on the same server address, with a service that
speaks cosmetics. Singleplayer and LAN show only your own.
- New cosmetics need a client release for their art (until art can be fetched), but no protocol change.
- `smokeCosmetics` and `WardrobeTest` cover it.
## Not yet
- Fetching new art from the service.
- Earning or buying cosmetics (`owned` is ready; selling needs Mojang's commercial guidelines checked first).
- Whole-body emotes, shoulder pets, a hand position module.
- Cosmetics in the tab list.
@@ -0,0 +1,64 @@
# ADR 0062: Incari Settings, and the 2026-10-12 batch
- Status: accepted
- Date: 2026-10-12
- Builds on: ADRs 0019, 0039, 0046, 0048, 0054, 0058–0061
## Context
One batch of seventeen features and two fixes, with these decisions made up front:
- **Short Swords:** first-person swords smaller, with a slider; other items unchanged.
- **An Incari icon**, drawn in code (there was only the wordmark).
- **Theme fonts:** a few open fonts in Incari's pack, loaded only when picked.
- **Usage counts:** on by default with a switch; anonymous, once a day.
- **Featured server:** Carrotcraft, pinned, clearly Sponsored, not deletable; replaceable by the service.
- **Incari's badge** beside other Incari players' names, with an opt-out.
- **Presets:** 1.8 PvP, Modern PvP, QoL (module lists in `Presets`).
- **Feedback** to GitHub Discussions, **bugs** to Issues.
- **Shared worlds** through Eaglercraft's public relays; **the recorder** as Eaglercraft 1.8's.
- **The pause menu** keeps one Incari button.
## Decision
| Item | What was built |
| --- | --- |
| Incari Settings | One pause-menu button with the new icon (`Icons.INCARI`, a hexagon with an I). `IncariSettingsScreen` opens the module menu, HUD editor, Wardrobe, screenshot gallery, recorder, chat and account, and holds the device's own switches (`ClientSettings`, `incari/settings.txt`) |
| Screenshots | No longer a module: the gallery is the client's, from Incari Settings. "Copy screenshots" is a switch there |
| Always-on modules | `Module.alwaysOn`: on from load, hidden from cards and presets, no toggle key. Theme is one: **Theme** in the module menu's sidebar |
| Theme fonts | `UiFont`: Red Hat Display, Minecraft (pixel), Inter, Nunito, Poppins, JetBrains Mono, Michroma. The four new ones are OFL, subset to 406 characters (72 KB gzip together). `SmoothFont.useFont` swaps the font in place, scaled to Red Hat Display's metrics. Share codes gain an eighth field; old codes still paste |
| Short Swords | `HeldItem.sword()` and a scale; 40–100%, default 70%, optionally not while blocking |
| Presets | `ModuleSystem.applyPreset`: switch to a profile of the preset's name (copied the first time) with exactly its modules on; settings kept |
| Featured server | `incari.featured` in `incari.properties`; `hello` may replace it. `FeaturedServers` adds them on each load, never saves them, and protects them from edit and delete; a **Sponsored** label |
| Usage counts | `count`: random install id, version and build kind, once a UTC day; off in Incari Settings. The service keeps a keyed hash per day (35 days) |
| Badge | Account setting "Show others I use Incari" (default on). `Badges` puts one glyph of a bitmap font (`incari:badge`) before the name tag, the tab list name and the first mention of the player's name in each chat line (matched by tab list name, since most servers send chat as plain text): no new drawing in the world. Only signed-in players see badges |
| Screen recorder | `PlatformRecorder` (browser only): canvas + game sound (+ mic) into a `MediaRecorder` (MP4 or WebM), downloaded on stop. F8 or Incari Settings; blinking REC. ~19 MB a minute in memory |
| Shared worlds | World Options' LAN shares a worker world through a relay (`RelayHost`): a join code in chat, up to 8 players. WebRTC lives on the page (`WorldSharing`) and relays to the worker (`GuestLink`). Incari hosts send a `HostHello`, so Incari guests join natively; Eaglercraft 1.8 clients can't join an Incari host (would need ViaRewind) |
| Repository and links | `github.com/incari-client/incari-client`; Report Bugs → issue template; Give Feedback → Discussions |
| Mojang's social features | Player Reporting removed; every Friends button opens Incari Chat |
| Tab title | Stays "Incari Client" |
| Death waypoints | Removed when the player returns within 4 blocks after being 8 away |
### Fixes
- **Text drawn over itself:** the game's shadow and bold redraw text a whole GUI unit away, which
reads as a second copy with anti-aliased fonts. `SmoothFont` uses half a unit.
- **Missing sounds:** a failed first download left a sound silent all session and held its channel.
Downloads now retry three times (`Fetch.bytesRetrying`); a sound that still fails plays a moment
of silence so the channel returns, and retries five seconds later (`sound-retry.steps`).
- **The HTML file's sounds:** it had none. Now it carries every sound but music, re-encoded by ffmpeg
as 22 kHz Ogg Vorbis (84 → 40 MB; file 87 → 133 MB). Without ffmpeg, only common sounds (~10 MB).
## Alternatives rejected
- **Fonts from Google Fonts at run time:** a third-party request from school devices, and nothing offline.
- **A drawn quad or entity for the badge:** a font glyph rides the name tag's existing drawing and culling.
- **Data channels moved into the worker:** Chrome can't hand them over reliably.
- **ViaRewind for Eaglercraft 1.8 guests:** another GPL component, and a 26.3 world shown to 1.8 loses most blocks.
## Verified
- Desktop: `smokeScreenModules`, `smokeLook`; unit tests across the framework, Theme, Short Swords,
Waypoints, `:online` (`Adr0062Test`), `:net` (`RelayHostTest`), `FeaturedServersTest`.
- Chrome: `incari-settings.steps` (recording, sounds), `share-host.steps` + `share-guest.steps` (a
guest joins, sees the world, chats). A pattern `switch` broke TeaVM's linking; `RelayHost` uses `instanceof`.
@@ -0,0 +1,62 @@
# ADR 0063: The modules' first performance pass
- Status: accepted
- Date: 2026-10-14
## Context
A new benchmark script, `features.txt`, plays the page's own world with every HUD and play module
on (`?modules=`, a development option) and with none, standing at spawn and flying east over new
terrain. With all on, the page spent about 1 ms more CPU a frame at 4x throttle, a third more than
without. The modules' own code was careful; the cost was under them:
- **The minimap redrew every drawn chunk on a timer**, changed or not: 2 to 3 chunks of 256 columns
a tick, each with a texture upload and a world-map record.
- **Its refresh loop read the clock up to 729 times a tick.** In the browser each reading is a call
out to the page.
- **The player's view was rebuilt on every call** (equipment, sorted effects, position), 30 times
or more a refresh with a full HUD. Coordinates looked the biome up three times a refresh; Totems
counted the inventory three times.
- **Saving the explored map deflated every changed region in one tick**, every 30 seconds.
## Decision
- **The minimap redraws a chunk only when the game marks it changed**, through one patch: a hook
beside the particle light's in `LevelExtractor.setSectionDirty`, which every block change, light
update and chunk load passes. Changed chunks near the player redraw at most every half second,
the rest every second. A redraw that comes out the same isn't uploaded or recorded.
- **The minimap's tick reads the clock only after a redraw.**
- **The player's view refreshes once a frame and once a tick** (`ModuleGame.newTick`, and the
frame's partial tick). The biome's name is kept until the player changes block; an item count
until the next refresh.
- **The HUD canvas keeps the last 128 text widths** (by hash), forgotten when the font changes and
every 64 draws.
- **The explored map saves one region a tick** when its half minute comes round.
- **The minimap's round mesh uses `Circles`' corner table**, not two trig calls a corner a frame.
- **The pixel-grid crosshair's outline is drawn as runs**, not four 1x1 fills a lit cell.
Nothing looks different: the benchmark's HUD and minimap screenshots match, and `smokeWaypoints`,
`smokeHudModules`, `smokeVisualModules` and `smokeFeatures` pass.
## Results
`features.txt`, desktop, CPU throttled 4x, Fast release, CPU a frame (tick + extract + render
submit). Mean of runs: before 2, after 3 with modules; 2 each without.
| Scenario | Modules | Before (ms) | After (ms) | Over none, before → after |
| --- | --- | ---: | ---: | ---: |
| Standing | none | 3.06 | 3.16 | |
| Standing | all | 4.02 | 3.65 | +0.96 → +0.49 |
| Flying | none | 4.45 | 4.44 | |
| Flying | all | 5.51 | 5.31 | +1.06 → +0.87 |
The tick's share is gone: 1.54 → 1.26 ms standing (1.28 with none), 1.42 → 1.23 flying (1.11). The
page is capped at 60 fps, so the saving is CPU a Chromebook doesn't have.
## Left for later
- **Drawing remains:** about 0.25 ms extract and 0.3 ms render submit a frame. `?drawcensus` counts
9.3 GUI draws a frame with all modules against 1.3 with none, mostly the minimap's. It draws every
frame, and its backdrop, terrain, rim, arrow, badges and letters stack into separate GUI layers;
each pipeline change in a layer is a draw.
- `Circles` gives a circle a side every 0.8 pixels round; fewer would look the same.
@@ -0,0 +1,95 @@
# ADR 0064: TeaVM 0.16.0
- Status: accepted
- Date: 2026-10-20
## Context
TeaVM 0.16.0 (2026-10-02) is mostly C backend work, but it also fixes several of the bugs
`tools/teavm-patches` carried for the browser build, adds class library methods, makes some
WebAssembly GC code faster, and ships WebGPU bindings. The patches are copies of TeaVM's own
classes, so each one was merged onto 0.16.0's source (three-way, with 0.15.0 as the base) and
checked by hand.
## Decision
Pin TeaVM 0.16.0 (and its jzlib 1.1.3, unchanged).
**Patches dropped**, 0.16.0 having the same fix: `WasmTypeInference`, `TThrowable`, `Heap`,
`WasmGCInstructionGenerationVisitor`.
**Patches cut down** to what 0.16.0 still lacks:
| Class | Still ours | Now TeaVM's |
| --- | --- | --- |
| `CoroutineTransformation` | Nullable block types; nullable locals | The type after a suspending `c ? a : b` |
| `WasmGCSupertypeFunctionGenerator` | Binary search of tag ranges (ADR 0026) | `instanceof Item[]` |
| `TByteBufferImpl`, `TByteBufferNative` | Absolute `getLong(int)` keeps the position | Absolute bulk `put` |
| `TCollections` | `unmodifiableCollection` lookups | `unmodifiableSet` and `unmodifiableMap` lookups |
| `TDefaultPath` | `resolve` | `iterator`, `equals` |
**Patches rebased** with the fix unchanged: `TTemplateCollections`, `ReflectionMetadataGenerator`,
`Fiber` (`Fiber.Jspi`), `TObject`, and the rest as they were. The probes that guarded the dropped
patches still run, now guarding TeaVM's fixes.
**A new patch: the coroutines' fiber checks.** 0.16.0 has every coroutine call
`Fiber.isPresentAndSuspending(fiber)` after each call that may suspend, and
`isPresentAndResuming(fiber)` in its prologue, where 0.15 called `fiber.isSuspending()` and
`fiber.isResuming()`. The new ones accept a null fiber, which takes a test and a branch: twice the
code. Profiles of the lobby showed the game's own small methods (`ChunkPos.isValid`,
`LevelHeightAccessor.isInsideBuildHeight`, `getMaxY`, `ItemStack.isEnchanted`) no longer inlined
into their callers, their bodies unchanged: V8 spends its inlining budget on the checks first. The
Compatible build was 17% slower in the lobby. `CoroutineFunctions` (with `WasmGCDependencies`
linking the instance methods) goes back to 0.15's checks. The game runs coroutines only on fibers,
so the fiber is never null there. Reading the field in `isPresentAndSuspending` instead of calling
`isSuspending` won back only half; typing coroutine values as 0.15 did (no `forceNullable`) won
nothing.
**Using what 0.16.0 adds:**
- `web-classlib`: `RandomAccessFile.read()` is TeaVM's own (it now reads bytes unsigned);
`LocaleAdditions` uses `Locale.of`.
- `WebGpuCallProbe` uses `org.teavm.jso.webgpu` (`GPUDevice`, `GPUBindGroup`,
`GPURenderPassEncoder`) and record-style `@JSProperty` getters. It keeps one overload TeaVM's
binding lacks: `setBindGroup` with a range of the offsets array, without which each draw would
allocate a subarray.
- With no code: `Math.min`/`max` as WebAssembly instructions, `getEnumConstants` cached
(`Enum.valueOf`, `EnumSet`, `EnumMap`), `System.getLogger` (Via's snakeyaml now links it instead
of having it removed).
Not taken: the C backend, Maven toolchains. Nothing in the survey's rules covered what 0.16.0 adds.
**Found on the way, fixed here:** `buildManifest` could hash the module while `teavm` was still
writing it, in the same run (`mustRunAfter` now orders them). The page then had a manifest for the
last build, and a benchmark's cold start right after a compile never reached its first frame.
And `checkDownloadSize` failed before measuring: three loader scripts had no classification, and
two limits were already passed (`index.html` with its inline images, the pack with Incari's own
textures and fonts); they're raised in `download-budget.properties`, which says why.
## Results
The desktop (Ryzen 5 9600X, RX 9060 XT), CPU throttled 4x as a stand-in for the floor laptop,
which was down. Release builds; CPU a frame is tick + extract + render submit; means of runs.
| Build | Runs | Flythrough (ms) | Combat (ms) | Lobby (ms) | Lobby fps | Warm start (s) | Join (s) |
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| Compatible, 0.15.0 | 3 | 5.15 | 5.04 | 33.07 | 27.8 | 9.75 | 21.9 |
| Compatible, 0.16.0 without the fiber checks | 3 | 5.54 | 5.73 | 38.55 | 24.3 | 10.08 | 21.4 |
| Compatible, 0.16.0 | 2 | 5.03 | 5.20 | 32.59 | 27.9 | 9.68 | 19.9 |
| Fast, 0.15.0 | 2 | 3.51 | 3.14 | 17.89 | 50.8 | 7.83 | 16.4 |
| Fast, 0.16.0 | 2 | 3.28 | 2.96 | 17.68 | 51.8 | 7.73 | 15.6 |
Two runs of one build differ by up to 12% in flythrough and combat and 6% in the lobby, so 0.16.0
is as fast as 0.15.0, not measurably faster. Memory is unchanged (lobby live heap 361 against
362 MB).
The modules grew: Compatible 66.3 to 68.2 MB raw (21.7 MB gzip), Fast 33.0 to 34.7 MB. Not broken
down; by its source, 0.16.0 gives nearly every class a supertype function, where 0.15 gave one only
to classes something tested against, and its field metadata grew for `Field.get*`/`set*`. Well
inside the budget (40 MB gzip).
## Left for later
- Report upstream: the fixes still in `tools/teavm-patches`, and the fiber checks' cost to inlining.
- `FileInputStream.read()` still reads bytes signed, and `RandomAccessFile`'s `"rw"` still
empties the file; `web-classlib` still covers both.
@@ -0,0 +1,41 @@
# ADR 0065: Wispcraft: Java servers through a Wisp proxy
- Status: accepted
- Date: 2026-10-25
- Builds on: ADR 0009 (the transport), ADR 0017 (a version per server)
## Context
A page has only WebSockets, so the browser build joins only Eagler servers (ADR 0016).
[Wispcraft](https://github.com/MercuryWorkshop/wispcraft) lets Eaglercraft join plain Java servers
by tunnelling TCP over [Wisp](https://github.com/MercuryWorkshop/wisp-protocol), a protocol for TCP
streams over one WebSocket, through a public proxy. The maintainer asked for the same, switched per
server on the add and edit server screens, like the version.
## Decision
- **Transport, not a proxy in the page.** `incari.net.wisp.WispConnection` is a `NetConnection`: a
WebSocket to the proxy, one Wisp v1 stream to the server, its bytes passed up as TCP's. The game's
own TCP pipeline (framing, encryption, compression) and Via run on top unchanged. Wispcraft
re-implements the protocol in JavaScript; Incari already has the game's.
- **v1 only.** No `Sec-WebSocket-Protocol` header, so v2 proxies speak v1. Flow control is honoured
(CONTINUE); what's sent between flushes goes as one DATA packet.
- **SRV through the proxy.** A host with no port asks `1.1.1.1:53` over DNS-over-TCP on a second
stream, as the game does over JNDI. No answer: the address as written.
- **Per server, saved with it.** `ServerData.incariWisp` (on/off and the proxy, default Wispcraft's
`wss://anura.pro/`). The edit-server screen's version button is halved and a Wispcraft button sits
beside it (a screen edit, no patch); it opens a screen to switch it and set the proxy.
- **The last proxy is remembered.** Done saves it to `incari/wisp-proxy.txt` at once; a server
not yet set up (off, default proxy) starts from it, so it's typed once.
- **Routing by thread.** The connect screen and the pinger name the server before resolving
(`WispServers.route`); the resolver hook then hands back a `WispAddress` with no DNS lookup.
`ServerConnections` gives it the plain pipeline. `ws://` addresses never go through Wisp.
## Limits
- **Offline-mode servers only**, like any join from Incari: there's no Microsoft sign-in, which
Wispcraft adds for online-mode servers. (Superseded: ADR 0070 adds it.)
- Everything the player sends passes through the proxy; the screen says so. On an online-mode
server it's encrypted once the login handshake is done (ADR 0070).
- A server's transfer packet to another host keeps the server's choice only when the game reuses its
list entry.
@@ -0,0 +1,51 @@
# ADR 0066: Schematics, written clean-room
- Status: accepted
- Date: 2026-10-25
- Builds on: ADR 0002 (the license)
## Context
Players asked for Litematica. Litematica and malilib are LGPL-3.0. Incari's Minecraft exception
(ADR 0002) can't be added to their code, so a port would have to stay LGPL in its own modules, carry
rebuild duties for anyone hosting a build, and risks LGPL §2 (a modified library that depends on the
application may have to go plain GPL). The author can't be expected to answer. A port is close to a
rewrite anyway: mixins become patches, malilib duplicates `framework`, the renderer must move to
`GpuDevice`.
## Decision
- **Clean-room implementation.** No Litematica or malilib code. Nobody writing it reads their source.
Work from the file format and observed behaviour only.
- **Compatible, not branded.** Reads `.litematic` files. Not called Litematica.
- **Formats:** `.litematic` first; vanilla structure `.nbt` and Sponge `.schem` after. All are NBT.
- **Where code goes:** `features/schematics`: format readers, placement, material list, verifier,
no game types. `client` adapter: block-state lookup, world reads, ghost rendering through
`GpuDevice`. Hooks are patches, per AGENTS.md.
- **First version:** load, place, move, rotate, mirror, ghost render, material list, highlight
missing and wrong blocks. Not in scope: easy-place, schematic editing and saving, area tools.
## `.litematic` format
Gzipped NBT. Enough to implement without reading Litematica:
- Root: `Version` (int), `MinecraftDataVersion` (int), `Metadata` (compound: `Name`, `Author`,
`EnclosingSize`, `TotalBlocks`, `TimeCreated`, ...), `Regions` (compound, one entry per region).
- Region: `Position` and `Size` (`x y z` ints; size components can be negative, meaning the region
extends the other way from `Position`), `BlockStatePalette` (list of `{Name, Properties}`),
`BlockStates` (long array), `TileEntities`, `Entities`, `PendingBlockTicks`,
`PendingFluidTicks`.
- `BlockStates`: palette indices, `max(2, ceil(log2(paletteSize)))` bits each, packed tightly so
an entry can span two longs (unlike vanilla's padded chunks). Index order is
`y * sizeX * sizeZ + z * sizeX + x` over absolute sizes.
- Upgrade block states older than the target's `MinecraftDataVersion` with the game's DataFixer.
Check each point against real files before relying on it.
## Consequences
- No LGPL modules, no extra notices, no rebuild duties on hosted builds.
- Reviewers reject code that mirrors Litematica's structure or names. `./incari copycheck` covers
only game code, so this is review-enforced.
- AI-written code: the model may have seen Litematica in training. Implement from this ADR and real
files, and keep the design Incari's own.
@@ -0,0 +1,31 @@
# ADR 0067: Custom Sky: resource packs' OptiFine skies
- Status: proposed
- Date: 2026-10-30
- Builds on: ADR 0046 (modules), ADR 0007 (the renderer's backend API)
## Context
Most PvP resource packs ship a custom sky in OptiFine's format: `optifine/sky/world0/sky<N>.properties`
(MCPatcher's `mcpatcher/sky/world0` in older packs), each naming a texture of a cube's six faces in a
3 by 2 grid, with fade times, a blend and a rotation. The game ignores them. Players asked for them.
## Decision
- **A module, Custom Sky** (`customsky`), off by default, with a brightness. It parses the files
(`SkyLayer`, no game types) and asks for them through `Game.showPackSkies`.
- **Two hooks in `SkyRenderer`**: `extractRenderState` reads the time and the weather as shown
(so Weather Changer's held time and weather apply), and `render` draws the layers after the
sunrise, before the sun, moon and stars, as OptiFine does. A new `SkyRenderer` (made after every
resource reload) means the packs may have changed: no reload listener.
- **The end sky's shader, nine pipelines.** Each OptiFine blend is a pipeline over
`core/position_tex_color` with OptiFine's blend factors, so the browser needs no new shader.
- **Loaded only while on.** Sky textures are large; they're loaded the first frame the module is on
and released when it's off.
## Limits
- Overworld only. `biomes`, `heights`, `days`, `transition`, `sun.properties` and
`moon_phases.properties` aren't read yet: a layer shows everywhere, every day.
- The face layout, rotation axis and blend factors follow OptiFine's; check them against a pack in
OptiFine before calling it exact.
@@ -0,0 +1,85 @@
# ADR 0068: An experimental Rust build on Horizon
- Status: proposed
- Date: 2026-11-01
- Builds on: ADR 0001 (patch-only repo), ADR 0036 (Fast and Compatible builds), ADR 0046 (modules)
## Context
[Horizon](https://github.com/horizon-rust/horizon) (MIT) is Minecraft: Java Edition 26.3 rewritten
in Rust and checked against the Java game by differential harnesses. A fork,
[horizon-web](https://github.com/nobuildersnotools/horizon-web) (branch `web`), compiles its client
to `wasm32-unknown-unknown` with threads as Web Workers and draws through WebGPU. It opens
single-player worlds, joins Eagler servers and plays sound, and runs well in early tests.
Incari's two builds compile the same Java to WebAssembly two ways. Horizon shares none of that code,
so it can't be a third way to compile Incari: Incari's features have to be written again for it.
The aim is to ship it beside Fast and Compatible without a second project to maintain.
## Decision
- **A third build, Rust, marked experimental.** It's listed in `build.json` beside `fast` and
`compatible` as `"rust": {"page": "rust/index.html"}` (format 2 still: older pages ignore it). The
loading screen offers it only where `navigator.gpu` gives an adapter, never recommends it, and
`?build=rust` picks it. Browsers without WebGPU are out of scope.
- **Its own page.** Picking Rust opens `rust/index.html`: Horizon's page, files and service worker,
untouched. Incari's worker leaves `rust/` alone, and its file list doesn't name Horizon's files.
- **Horizon is pinned, fetched and never committed**, as the game is (ADR 0001).
`incari.properties` names `horizon.repository` and `horizon.revision` (a commit on the fork's
`web` branch). `./incari setup` clones it into `work/horizon` (a warning, not a failure, when
it can't). `INCARI_HORIZON_DIR=<path>` builds a local checkout instead, for work on Horizon itself (its files
as git sees them, copied into `work/horizon-override`: horizon-mixins refuses the symlink a
checkout's own web build leaves).
- **One game download.** `horizon-prepare` reads the pinned 26.3 jars, libraries and assets
`./incari setup` and `./incari assets` already fetched (`--client-jar`, `--libraries-dir`,
`--assets-dir`, `--server-jar`). The prepared resources stay in `work/horizon-resources/` and are
never committed or published.
- **Incari's changes are Horizon native mods**, in `rust/mods/<name>/`: horizon-mixins bundles that
use only Horizon's native hook points (`"hooks": N`, never a pinned commit), so they keep building
as Horizon moves. A missing hook point is added to the fork, and offered upstream. A change no
mod can make is committed to the fork and the pin bumped; there's no second patch system. What
every mod shares (settings pages, HUD boxes by corner) is a bundle of its own, `rust/mods/common`,
with no hooks.
- **One build command.** `./incari build` builds Rust before Fast and Compatible: horizon-mixins
(pinned too) applies `rust/mods` into `work/horizon-stage`, then Horizon's `web/package.py`
builds its threaded module (the fork dropped the single-threaded one) into `app-web/build/rust/`. `--only rust` builds
it alone. The web folder has it in `rust/`; the single file doesn't (`--html` leaves it out:
Horizon's offline file is a page of its own).
- **Its tools are optional.** It needs Rust `nightly-2026-10-14` with `rust-src` and the
`wasm32-unknown-unknown` target, `wasm-bindgen-cli` 0.2.129 and binaryen. Without them
`./incari build` skips Rust and says why; Fast and Compatible still build.
- **Contracts are shared, code isn't.** Java and Rust can't share modules, so both read one source:
| Contract | Source |
| --- | --- |
| Version, featured servers, online URL | `incari.properties`, turned into Rust constants at build time |
| Accounts, friends, cosmetics | `docs/online-protocol.md` |
| Settings and profiles | One file format in browser storage, so switching builds keeps them |
| What a feature does | The feature's `README.md`, the spec for both ports |
- **Tracked per feature.** `features/README.md` has a Rust column (Ported, Not yet, Won't port), and
`tools/ci/check-rust-status.sh` fails when a feature has none.
- **Releases don't wait for it.** When Horizon is behind (Incari on a newer game version, or a
broken pin), `build.json` marks `rust` unavailable with a reason and the release goes out.
Bumping `horizon.revision` is its own pull request.
## Consequences
- Every feature is written twice. Rust ports start with the PvP HUD and visual modules.
- No ViaVersion in the client: Horizon speaks only 26.3, so it joins servers whose proxy translates
(Eagler servers with ViaVersion, Horizon servers). Servers that cap the version refuse it.
- Horizon's web port is experimental: its README lists page-side locks that can stop the game, no
screenshots or world icons, and no online mode.
- CI runs the mods' own tests (`rust/`'s `cargo test`, `clippy`, `fmt`), not the Rust build: that
needs the game's files. Whether headless Chromium (SwiftShader) can run WebGPU for `browserCheck`
is unchecked.
- Renderer, networking and licensing reviewers (`.github/CODEOWNERS`) review the Rust build.
Horizon is MIT, which GPL-3.0 Incari may include.
- `rust/` isn't a Gradle module, so `gradle/module-boundaries.txt` doesn't list it; its rules are in
`rust/AGENTS.md`.
## Open questions
- Upstreaming the web port to horizon-rust/horizon, which would leave only the mods to maintain.
- Measurements: Rust against Fast on the same machine (`docs/benchmark.md` scenarios) before the
loading screen describes it as faster.
@@ -0,0 +1,56 @@
# ADR 0069: Incari Client itself on Horizon
- Status: proposed
- Date: 2026-11-01
- Changes: ADR 0068 (its mods' settings pages and HUD corners)
## Context
ADR 0068's Rust build ported Incari's features as Horizon mods: each listed in Horizon's
Options > Mods, settings as cycling buttons, HUD boxes in four corners, on Horizon's vanilla title
and pause screens. It played like Horizon with some extras, not like Incari: a player had to learn
it anew, and their profiles didn't carry over.
## Decision
The Rust build is the same client: at first glance it looks and works as the Java build does.
- **The client is one crate**, `incari_core` (`rust/mods/incari/core`, a horizon-mixins bundle
crate), with no game types: the Frost look (theme, rounded glass, icons, the mark, the wordmark),
Incari's screens (title, pause, module menu, module settings, HUD editor, Incari Settings,
profiles), the module framework with every module declared with the Java ids
(`modules.rs`), and profiles in the Java JSON format. It draws by listing fills, canvas images
and text; `rust/mods/incari/glue.rs` replays the list into Horizon's HUD batch and does what the
client asks of the game through `native_*` helpers.
- **Feature mods keep their hooks, not their pages.** Each reads its module's settings
(`incari_client::settings`) and draws its HUD elements where the player placed them
(`incari_client::element`). Nothing is listed in Horizon's Options > Mods.
- **The fork gains generic hook points** (pending fragment `incari_shell_hooks.json`), offered
upstream: a mod draws a screen itself (`native_screen_claim`), draws over every screen and hears
input first (`native_overlay`, `native_overlay_input`), draws its own backdrop in place of the
panorama (`native_backdrop_claim`, `native_backdrop`), and paints images at run time into a
2048x1024 atlas slot (`native_canvas_upload`). A GUI skin (`hud::set_skin`) is asked first for
every sprite drawn by name, so Frost covers Horizon's own screens and HUD, as `FrostSkin` covers
the game's in Java. Helpers: `native_open`, `native_connect`, `native_translate`,
`native_own_skin`, `native_clipboard`, `native_atlas` and others in the fragment.
- **Incari's pack is always on**, as in Java: `./incari build` copies it over Horizon's prepared
resources (Red Hat Display as the game's font) and the bundle's data (the mark, the backdrop,
Michroma) from `client/src/main/resources/incari-pack`. One copy in the repo.
- **Settings are shared with the Java build's files**: `incari/modules/profiles/*.json`,
`incari/look.txt` and `incari/settings.txt`, same keys.
## Consequences
- A screen of Incari's is written twice (Java and Rust), from the same layout constants. The
Java one is the spec.
- Ported besides the modules: Incari accounts, chat and friends (`incari_core::online`, the
socket only in the threaded browser build), screenshots, the screen recorder (the page's
`MediaRecorder`, browser only), credits, featured servers (the fork's
`multiplayer::set_featured`), waypoints and the world map (its land from the fork's
`native_map_tile`), Custom Sky (the fork's `native_sky_layers`, a render pass of sky layers), Schematics (the fork's
`native_ghosts`, ghost blocks meshed from the game's models).
- Cosmetics and the Wardrobe (the fork's `native_player_look`, name tag, tab list and chat hooks);
their previews are drawn by the client, not the game's renderer.
- Still open: linear sampling of the backdrop (Horizon's HUD samples nearest), and the Theme
Editor's font choice.
- Renderer reviewers review the fork's skin and canvas; they touch every GUI draw.
@@ -0,0 +1,72 @@
# ADR 0070: Microsoft sign-in for online-mode servers
- Status: proposed
- Date: 2026-11-04 (security review the same day: key-size limits, server-auth usage, file mode)
- Builds on: ADR 0065 (Wispcraft), ADR 0006 (the link step), ADR 0009 (the transport)
## Context
Through Wispcraft (ADR 0065) Incari joins plain Java servers, but only offline-mode ones: an
online-mode server sends an encryption request, and the client has to tell Mojang's session server
it's joining as a real account. Players asked for it; Wispcraft and other Eagler clients have it.
A page can't call Microsoft's, Xbox's or Mojang's APIs directly: they send no CORS headers.
Wispcraft gets past that by running TLS in the page over a Wisp stream (epoxy-tls, AGPL-3.0, wasm).
## Decision
- **The launcher's client id.** Sign-in asks `login.live.com` for tokens as the official Minecraft
launcher (`00000000402b5328`, scope `service::user.auth.xboxlive.com::MBI_SSL`), as other Eagler
clients do. An app of Incari's own would need Mojang's approval for `login_with_xbox`. It's one
constant, `MicrosoftEndpoints.CLIENT_ID`.
- **Device code flow.** The game shows a code; the player types it at `microsoft.com/link` on any
device. The password never reaches Incari.
- **TLS in Java, over any connection** (`incari.net.tls`). Bouncy Castle's lightweight TLS client
(MIT) in its non-blocking mode, over a `NetConnection`: a socket on the desktop, a Wisp stream in
the browser, through the player's last proxy (or Wispcraft's default). End to end: the proxy sees
only ciphertext. Chosen over epoxy-tls for its licence, and because it runs and is tested on the
JVM like the rest of `net`.
- **Pinned roots, strict checks** (`CertificateChain`). Only the four roots Microsoft's hosts chain to
(DigiCert Global Root G2 and G3, Microsoft RSA and ECC Root 2017). The leaf must name the host
(subject alternative names, one-label wildcards) and server auth; a CA that names purposes must
include it. Every link must be in date, a CA's, and signed with RSA 2048 to 4096 bits (exponent
≤ 32 bits) or ECDSA P-256/P-384 over SHA-2. Sizes are checked from the raw numbers before any key
is read, so a hostile proxy can't stall the client with huge keys. TLS 1.2 and 1.3 only.
- **A small HTTPS client** (`incari.net.https`): one request per connection, `Connection: close`,
capped sizes, 30 s limit, and an allow-list of the five hosts sign-in uses. Nothing else can be
reached through it, so a token can't be sent elsewhere.
- **The token chain** (`incari.net.msa`): Microsoft → Xbox Live (`RpsTicket "t="`, retried once as
`"d="`) → XSTS → `login_with_xbox` → profile. Microsoft's refresh token is kept, so the account
lasts past the Minecraft token's 24 hours. A token about to expire is renewed before a join.
- **The game's own handshake.** On the web, `web-classlib` now supplies the JCA classes the
handshake and chat signing call (`Cipher` for RSA/PKCS#1 and AES/CFB8, `KeyFactory`,
`Signature` for SHA256withRSA, `KeyGenerator`), over Bouncy Castle's engines, tested against the
JDK. They replace removals the survey made only because they were missing. `KeyFactory` refuses
RSA keys over 4096 bits or with exponents over 64 bits, as a server's key arrives unchecked. `KeyPairGenerator`
stays missing, so the worker's integrated server still makes no key pair.
- **Two hooks.** `authenticateServer` joins through `ServerJoins` (and, offline, says how to sign in
instead of "invalid session"); `getProfileKeyPairManager` gives the account's chat key, fetched
from `/player/certificates`. A launcher's own account (desktop, real token) keeps the game's path.
- **Stored on the device.** `incari/microsoft-account.json` in the game directory (OPFS in a page)
holds the name, id, Minecraft token and refresh token. Never logged; Sign Out deletes it. On the
desktop it's owner-only (0600) and replaced atomically.
- **Screen**: Edit Profile's "Microsoft Sign-In" link opens `MicrosoftScreen`. Signed in, the name
is the account's and can't be edited. Accounts can't change while in a world.
## Consequences
- Online-mode Java servers work through Wisp and on the desktop, with secure chat.
- Bouncy Castle is in both builds (credits and `NOTICE.md`). Only the classes reached are linked.
- If a host moves to a root that isn't pinned, sign-in fails ("not issued by a trusted root") until
`TrustAnchors` is updated. No revocation checks, as browsers soft-fail them.
- Using the launcher's id borrows its identity: Microsoft's page names it, and Microsoft could block
it for everyone at once.
- The refresh token on disk is as safe as the device's storage for the page. Anyone with the
player's browser profile can use it, and so can any page on the same origin: host Incari on an
origin of its own (not a shared `user.github.io`); `docs/self-hosting.md` says so.
- On the desktop, a signed-in token reaches vanilla code too (Realms, over the JDK's trust store),
as a launcher's would.
- CFB8 runs one AES block per byte: the cost of every byte on an online-mode server. Measure it on
a Chromebook before calling it free.
- Not in the Rust build: Horizon has no Wisp and no online mode (ADR 0068).
- Networking and licensing reviewers (`.github/CODEOWNERS`) review it.
@@ -0,0 +1,31 @@
# ADR 0071: Via is off unless the player turns it on
- Status: accepted
- Date: 2026-11-04
- Amends: ADR 0017 (Via in the client), ADR 0018 ("Auto" finds the version by joining)
## Context
"Auto" (ADR 0018) joined every server through version detection: pings, quick probes, retries on a
refusal, guesses after a silent Eagler drop, learned versions. It caused more trouble than it fixed:
wrong guesses, extra logins, and wrong versions remembered for multi-version servers.
## Decision
- **Each server's Via choice is Off, Auto or a release; Off is the default**, like Wispcraft. The
edit-server screen's button reads "Via: Off" and opens the list, with Off first.
- **Off joins as the game's own version**: no ping, probe, retry or learned version. The server list
marks other versions incompatible, as the game does.
- **Saved as `incariVia`**, not `incariVersion`. Older builds saved "Auto" as their default, so their
choices are left unread and every existing server starts with Via off.
- **A hint on refusal**: with Via off, a join refused for its version ("Outdated server!",
"Incompatible client!") or dropped during an Eagler login shows the server's reason with a line
below it: edit the server and set Via to Auto (`ViaHint`, one hook in `DisconnectedScreen`).
- **Auto for the smoke tests' servers**, and for a quick play join whose page asks with `?via=auto`
(the browser checks of other versions). A server an Eagler server redirects to gets Auto if Via
was on for the one that sent the player. Featured servers keep the default: they run the game's version.
## Consequences
- Players of 1.8 servers turn Via on once per server.
- The Rust build has no Via, so it has nothing to change.
@@ -0,0 +1,30 @@
# ADR 0072: A hidden page keeps time in a worker
- Status: accepted
- Date: 2026-11-04
## Context
The page runs the game on timers: TeaVM wakes every thread with `setTimeout`, and a hidden tab's
frames come from a quarter-second `setTimeout` (no animation frames when hidden). Chrome holds a
hidden page's chained timers to one wake-up a second, and after five minutes hidden and silent to
one a minute. Packets reach the game once a frame and Netty's threads wake on timers, so the
server's keep-alive went unanswered and players came back to "Timed out".
## Decision
- While the page is hidden, every TeaVM wakeup and both quarter-second fallbacks (frames,
background pool) go to a small Blob worker's `setTimeout`, which answers with a message
(`wakeups.ts`: `createPageTimer`, `createPageAsyncImports`; `window.incariTimer`).
- While visible, nothing changes: TeaVM's own `setTimeout`, and animation frames.
- Not the `MessageChannel` wakeups of ADR 0040: on the page they once hung singleplayer at spawn
(ADR 0043), and a spinning wait would busy a hidden tab's core.
- `?wakeups=timers` turns it off.
## Consequences
- A hidden tab runs the game at about four frames a second instead of
one a minute: more battery used in the background.
- Not measured in a real browser yet: whether Chrome exempts a dedicated worker's timers from its
intensive throttling is from its documentation, not a test. `browserCheck` can't hide its page
for five minutes.
@@ -0,0 +1,31 @@
# ADR 0073: Combat modules predict; they never play for the player
- Status: accepted
- Date: 2026-11-06
## Context
Players asked for Fast Crystal: an end crystal or respawn anchor gone as soon as they break it, not
a ping later, so the next one goes in its place sooner. The same name also covers cheats that place
and hit crystals by themselves (CrystalAura, AutoCrystal).
## Decision
- **A combat module may predict what the player's own click already did, and nothing more.** One
click sends the one packet the game sends, at the time the game sends it. No packet is added,
repeated, sent sooner or sent without a click. No cooldown or reach check is skipped.
- **What the server keeps comes back.** A crystal comes back after twice the ping (0.6 to 3 s)
without the server's removal. An anchor is predicted inside the game's own block prediction, so
the server's acknowledgement puts it back.
- **Only where the server agrees:** no crystal is taken away for a hit doing no damage (weakness
with a bare hand) or for an invulnerable crystal; no anchor where it sets the spawn (the Nether).
- **Off by default**, with a toggle key like every module, since some servers ban even prediction.
- In code: `Game.predictBreaks` (`:framework`), `ModuleBreaks` (`:client`), three one-line hooks.
## Consequences
- Fast Crystal sends exactly what the vanilla client sends, so an anticheat sees nothing new.
- Auto-place, auto-hit and similar requests are refused under this ADR.
- The Rust build has it as a mod (`rust/mods/fastcrystal`) on the fork's prediction hooks
(`object_attacked`, `block_used`, `native_take_crystal`, `native_predict_air`: fragment
`incari_fast_crystal`), which keep to the same rule.
@@ -0,0 +1,36 @@
# ADR 0074: The browser build never calls Mojang's services on its own
- Status: accepted
- Date: 2026-11-13
- Builds on: ADR 0070 (Microsoft sign-in)
## Context
The browser build started the game as an online client with token `0`. Mojang's authlib then
called out at once and kept retrying: service discovery, the services' public keys, the player's
profile, user properties, the chat key pair, telemetry. Mojang's APIs send no CORS headers
(ADR 0070), so a page can't reach them: every request failed, each one a console error and wasted
work on a slow Chromebook.
## Decision
- **Off in the browser.** `WebMain` calls `OnlineServices.disableMojang()` and starts the game with
`--offlineDeveloperMode`: no profile, property, key pair or telemetry requests.
- **Offline discovery.** The game's discovery service comes from `OnlineServices.discovery` (one
hook in `Minecraft`): the offline one, which never fetches. The singleplayer worker's server
uses it too.
- **Skins without the services** (`ProfileTextures`, one hook in `SkinManager`). With no discovery
there is no texture host list, so every skin and custom head would stay the default. Textures
are accepted from Mojang's domains (`*.minecraft.net`, `*.mojang.com`) over http(s), and a
signed property counts as signed: its signature can't be checked without Mojang's keys.
- **Microsoft sign-in is unchanged.** It reaches Mojang over TLS in the page, only when the player
signs in or joins an online-mode server.
- The desktop keeps the game's own behaviour.
## Consequences
- No requests to Mojang from the browser build unless the player signs in with Microsoft. Skin
images still come from `textures.minecraft.net`, where profiles say they are.
- A server can show a player with another real Mojang skin; never an image from another host.
- Other players' chat keys still can't be checked in the browser (no Mojang keys), as before.
- The Rust build makes no Mojang requests, so it has nothing to change.
@@ -0,0 +1,81 @@
# ADR 0075: Server messages reach the game within a frame in the browser
- Status: proposed
- Date: 2026-11-16
- Builds on: ADR 0009 (WebSocket transport), ADR 0072 (hidden-page wake-ups)
## Context
In the browser a server message went from the socket's callback to a JavaScript queue, to the
game's thread at the next frame's `pollEvents`, to the connection's event loop (a Java thread,
which runs only when the render thread suspends), and back to the game's thread at the next frame.
Measured from the socket's `onmessage` (`desktop-cpu4`, release build, in play): **decoded after
~37 ms, handled by the game after ~40 ms**, two and a half frames.
A profile of the flythrough put the whole network path at ~6% of the page's time (event loop 1.7%,
sending 0.6%, packet handling 3.4%). So the cost to fix was the latency, not the CPU.
Splitting the time by stage showed the wait wasn't in Incari's code. In play, Chrome runs a
zero-delay `setTimeout` set from a socket's `onmessage` **~36 ms late**, and a `MessageChannel`
message ~70 ms late, while animation frames and socket messages come on time. TeaVM wakes every
thread through `setTimeout` (`teavmAsync.offer`), so the connection's thread, woken to read a
message, waited two frames. `EventLoopHopProbe` shows the hand-off itself is immediate when the
page isn't busy.
## Decision
| Change | Where |
| --- | --- |
| The render thread waits for the next frame **or** a socket message (`window.__incariNetWake`), and delivers a message as it comes | platform-web `Dom`, `WebPlatform`, `WebSocketNetwork` |
| The woken connection thread runs at once: the wake calls `incariRunWoken`, which runs the events offered during it (and those they chain, at most 32), not leaving them to their timers [`?netwake=timers`] | app-web `wakeups.ts` (`runWoken`), `boot.ts` |
| A burst of messages reaches the pipeline as one event-loop task with one read-complete | net `NetConnectionChannel` |
| `Inflater.reset` and `Deflater.reset` reset jzlib's stream in place, not a new one per packet; `TInflater` reads and writes a buffer's own array | web-classlib `TInflater`, `TDeflater`, `StreamResets` |
| A whole-array send skips one copy | platform-web `WebSocketNetwork` |
Only the events a wake caused run early. Each still has its timer, which finds nothing to do.
Events offered before the wake (the background pool's runners) stay on their timers.
## Results
`desktop-cpu4` (RX 9060 XT, Chrome 151, CPU throttled 4x), release build, wsbridge server.
Latency is from `onmessage`, in 10 s windows during play (temporary instrumentation):
| | Before | Wake only | Wake + `runWoken` |
| --- | ---: | ---: | ---: |
| Decoded, mean | ~37 ms | ~35 ms | **~2 ms** |
| Handled by the game, mean / p95 | ~40 / ~53 ms | ~38 / ~50 ms | **~4 / ~8 ms** |
Frames, benchmark reports: medians, with ranges. "Without" is 7 runs (before, and the wake
without `runWoken`); "with" is 6:
| | Without `runWoken` | With |
| --- | --- | --- |
| Median fps, flythrough / combat / lobby | 59.8 / 59.5 / 28.1 | 61.0 / 61.8 / 28.0 |
| 1% low, flythrough | 25.9 (24.4–29.4) | 24.7 (22.3–29.7) |
| 1% low, combat | 30.8 (26.1–34.5) | 28.3 (25.3–32.4) |
| 1% low, lobby | 15.9 (14.2–16.5) | 15.2 (14.9–15.9) |
| 99th percentile frame, lobby | 56.1 ms (55.7–57.3) | 58.8 ms (56.7–61.1) |
Median frame rates hold. The slowest frames pay: the lobby's (the busiest traffic) are ~2.5 ms
longer, clear of noise; the 1% lows are 4–8% lower, inside the run-to-run spread but in every
scenario. That is the price of ~34 ms less latency, so `?netwake=timers` turns it off, and the
default is for a reviewer to settle on a Chromebook (`laptop-floor`).
Compression (Wisp's Java servers; Eagler servers and the benchmark send uncompressed),
`InflatePacketProbe`, best of six alternated rounds, per packet: inflate **14.2 → 11.2 µs**,
deflate **74.5 → 60.4 µs**, and no 32 KB window or deflate state allocated per packet.
## Looked at and left
- **One wake each 8 ms:** messages come in bursts, so most were held back, and every message not
handed over by a wake still waited two frames (decoded ~33 ms). No gain.
- **Running every due event on a wake:** decoded in 0.5 ms, but it pulled the background pool's
meshing out of its idle slots into the tasks before a frame. Lobby slowest frames +7 ms.
- **`MessageChannel` wake-ups on the page** (ADR 0043): later still in play (~70 ms).
- **Waking the event loop for a sent packet as the frame ends** (marked wake-ups run when the
frame's callback returns): no change. A packet the game sends reaches its event loop ~3-8 ms
later in the flythrough and combat and ~26-30 ms in the lobby, with or without it: the send's
wake isn't held back as a message's was; the loop just waits for the render thread to finish
its frame. Less would need the pipeline to run on the render thread.
- **Per-message delivery cost** (`SocketDeliveryProbe`): 0.49 µs a message, nearly all the copy
out of the page's buffer. Not worth changing.
+96
View File
@@ -0,0 +1,96 @@
# Architecture decision records
Each ADR records one decision: the problem, what was chosen and why, and what it costs. They're
the project's memory. Read the ones for the area you're changing before you change it, and add one
when you make a decision someone would otherwise have to rediscover.
## Writing one
- Copy the header of a recent ADR: `- Status`, `- Date`, and `- Builds on` when it extends
earlier ones. Then **Context**, **Decision**, **Consequences**, and measurements when
there are any.
- Number it after the last one, and add it to the table below.
- Status is `accepted` once the change is merged. When a later ADR replaces part of one, say so in
its status line ("superseded in part by ADR NNNN") rather than editing the old decision.
- Write for someone who wasn't there. Measurements say where they were taken (the machine names in
[`docs/benchmark.md`](../benchmark.md)).
## Index
| ADR | Decision |
| --- | --- |
| [0001](0001-patch-only-repo.md) | The repo is patch-only, built on the Spigot/Paper model |
| [0002](0002-license-gpl3-with-minecraft-exception.md) | GPL-3.0-or-later with a Minecraft additional permission, and DCO sign-off |
| [0003](0003-module-boundaries-and-quality-gates.md) | Enforced module boundaries and one set of quality gates |
| [0004](0004-vendor-tree-builds-from-source.md) | The game is built from the patched source tree, starting with decompile fixes |
| [0005](0005-platform-layer.md) | The platform layer: whole-class replacements over Platform interfaces |
| [0006](0006-browser-build-link-step.md) | How the browser build links: removals by rule, a class library for the rest |
| [0007](0007-webgl2-backend-and-build-time-shaders.md) | The WebGL2 backend, under Mojang's frontend, with shaders translated at build time |
| [0008](0008-off-heap-memory-in-linear-memory.md) | Off-heap memory in the module's linear memory, and Netty in heap mode |
| [0009](0009-websocket-transport.md) | A WebSocket transport under the game's Connection, one packet per message |
| [0010](0010-browser-input.md) | Browser input: focus, a text input element, an asynchronous clipboard, dropped files |
| [0011](0011-storage.md) | Storage: the file system in memory, written behind to OPFS by a worker |
| [0012](0012-webgl2-backend-complete-and-screenshot-diffs.md) | Every pipeline in WebGL2, and screenshot diffs against the desktop |
| [0013](0013-web-audio.md) | Sound over Web Audio, with the browser's decoder and the desktop's panning |
| [0014](0014-loader-and-packaging.md) | The loader page, the build manifest, the service worker and the asset pack |
| [0015](0015-background-work-between-frames.md) | The background pool runs between frames, and the render thread's waits are counted |
| [0016](0016-eagler-handshake-in-the-client.md) | The Eagler handshake in the client, and Eagler skins |
| [0017](0017-via-in-the-client.md) | Via in the client, and choosing a server's version |
| [0018](0018-auto-finds-the-version-by-joining.md) | "Auto" finds a server's version by joining |
| [0019](0019-eagler-extras.md) | Eagler's extras: passwords, cookies, redirects, voice chat and shared worlds |
| [0020](0020-legacy-behaviour-layer.md) | The legacy behaviour layer: playing 1.8 servers as 1.8 did |
| [0021](0021-profiler-and-benchmark.md) | The profiler, the benchmark and the performance gate |
| [0022](0022-terrain-multi-draw.md) | Terrain in a few multi-draws a frame |
| [0023](0023-worker-mesher.md) | Terrain meshed in Web Workers by Incari's own mesher |
| [0024](0024-entities-particles-text.md) | Entities, particles and text |
| [0025](0025-memory-diet.md) | The memory diet |
| [0026](0026-startup.md) | Start-up |
| [0027](0027-performance-follow-ups.md) | Performance follow-ups: the compile, the backend's calls, and the game's own costs |
| [0028](0028-web-folder.md) | The web folder (`./incari build`) |
| [0029](0029-edit-profile.md) | Edit Profile |
| [0030](0030-game-side-optimizations.md) | Ideas from the Java optimization mods: draw lists, facing culling, sprite animation |
| [0031](0031-floor-device-profiles.md) | What the floor stand-in's profiles found: items, ambient particles, glyphs, tints, indices |
| [0032](0032-pacing-tables-light-particles.md) | Catch-up ticks paced, mesher tables kept, light maps updated in place, particles instanced |
| [0033](0033-packet-handoff.md) | Throws off the page's main thread: the packet handoff, and Via's dropped packets |
| [0034](0034-fixed-orders-lookups-and-sweeps.md) | Fixed translucent orders, the class library's lookups, collision sweeps, and Binaryen |
| [0035](0035-pool-floor.md) | A floor for the background pool's share of a late frame |
| [0036](0036-fast-and-compatible-builds.md) | Fast and Compatible builds (JSPI instead of coroutines) |
| [0037](0037-index-assets.md) | The Unicode font and the languages from the asset index |
| [0038](0038-singleplayer-in-the-page.md) | Singleplayer in the page |
| [0039](0039-singleplayer-server-in-a-worker.md) | Singleplayer's server in a Web Worker |
| [0040](0040-singleplayer-server-speed.md) | Singleplayer's server, faster: wakeups, math, spawn settings, stronghold rings |
| [0041](0041-singleplayer-storage-and-world-generation.md) | Singleplayer's files in place, a direct line to storage, and cheaper world generation |
| [0042](0042-lazy-density-branches-terrain-helpers-goal-flags.md) | Density functions' branches sampled where used, terrain helpers, and goals' flags as masks |
| [0043](0043-world-generation-garbage-jar-compaction-wasm-opt.md) | Less garbage in world generation, the client jar compacted, faster saves, and wasm-opt and channel wakeups measured again |
| [0044](0044-defaults-and-fixes-before-m4.md) | Defaults and fixes before M4 |
| [0045](0045-eagler-pause-menu-and-voice-panel.md) | An Eagler server's pause menu, voice chat in a panel, the player on the title screen |
| [0046](0046-module-framework.md) | The module framework |
| [0047](0047-screen-edits-and-skins.md) | The game's screens changed and redrawn without a patch each |
| [0048](0048-the-clients-look.md) | The client's look, Frost, in Potato and Normal presets |
| [0049](0049-hud-editor.md) | The HUD editor |
| [0050](0050-first-modules-game-view.md) | The first modules, and what they read of the game |
| [0051](0051-minimap-and-waypoints.md) | Minimap and waypoints |
| [0052](0052-hud-modules.md) | The HUD modules: Keystrokes, CPS, FPS, Reach, Coordinates, Shield & Totem |
| [0053](0053-visual-and-combat-modules.md) | The visual and combat modules: Cooldown, Crosshair, Freelook, Weather, Low Shield, 1.7 |
| [0054](0054-screen-modules.md) | The screen modules: Shulker Tooltips, Screenshot Manager, Theme Editor |
| [0055](0055-built-in-packs-and-old-textures.md) | The built-in packs in the page, and Old Textures |
| [0056](0056-the-looks-first-performance-pass.md) | The look's first performance pass |
| [0057](0057-single-file.md) | One HTML file (`./incari build --html`) |
| [0058](0058-incari-accounts-client-side.md) | Incari accounts and the online service (client side) |
| [0059](0059-incari-chat-friends-and-messages.md) | Incari chat: friends, messages and the chat menu |
| [0060](0060-update-notice.md) | The update notice |
| [0061](0061-cosmetics.md) | Cosmetics: the Wardrobe, worn cosmetics, emotes and personal effects |
| [0062](0062-incari-settings-and-the-2026-10-12-batch.md) | Incari Settings, and the 2026-10-12 batch |
| [0063](0063-the-modules-first-performance-pass.md) | The modules' first performance pass |
| [0064](0064-teavm-0-16.md) | TeaVM 0.16.0 |
| [0065](0065-wispcraft.md) | Wispcraft: Java servers through a Wisp proxy |
| [0066](0066-schematics-clean-room.md) | Schematics, written clean-room |
| [0067](0067-custom-sky.md) | Custom Sky: resource packs' OptiFine skies |
| [0068](0068-rust-build.md) | An experimental Rust build on Horizon |
| [0069](0069-incari-client-on-horizon.md) | Incari Client itself on Horizon |
| [0070](0070-microsoft-sign-in.md) | Microsoft sign-in for online-mode servers |
| [0071](0071-via-off-by-default.md) | Via is off unless the player turns it on |
| [0072](0072-hidden-page-wakeups.md) | A hidden page keeps time in a worker, so servers don't time it out |
| [0073](0073-combat-prediction-not-automation.md) | Combat modules predict; they never play for the player |
| [0074](0074-no-mojang-services-in-the-browser.md) | The browser build never calls Mojang's services on its own |
| [0075](0075-network-latency-in-the-browser.md) | Server messages reach the game within a frame in the browser |
+143
View File
@@ -0,0 +1,143 @@
# The benchmark and the profiler
Every performance change states what it did to these figures, on the same scenes. A change that
makes them worse fails. ADR 0021 has the decisions; this page is how to use the tools.
## Profiler overlay
F9 in game (or `?overlay`) shows, on every screen:
- frame rate and 1% low;
- CPU time per frame: **tick** (ticks, packets), **extract** (preparing the frame), **render**
(every WebGL call), and **GPU** time where the browser offers timer queries;
- draw calls, terrain draws and sections, the mesh queue;
- JavaScript heap (Chrome; exact only with `--enable-precise-memory-info`), linear memory, GC;
- a frame-time graph with a 60 fps line.
Times come from zones the game already marks for its own profiler. It costs nothing unless shown
or asked for (`?profile`, or `-Dincari.profile=true` on the desktop). The page keeps the last
16384 frames and start-up marks in `window.__incariFrames`.
## Running it
```sh
./gradlew :app-web:checkDownloadSize -PdownloadSize.noBrotli -Pteavm.release # optional: size in the report
./gradlew :app-web:benchmark -Pbenchmark.machine=desktop -Pteavm.release
```
Use `-Pteavm.release`: it's what players get and what baselines are recorded with.
The runner starts a vanilla server with a fixed-seed world (`app-web/benchmark/server.properties`),
then opens the page four times: **cold start** (cleared origin), **warm start** (reload),
**join** (render distance 8, no frame limit), **rejoin** (from a reload). Then it plays
`app-web/benchmark/benchmark.txt` from the rejoined page:
| Scenario | Does | Stresses |
| --- | --- | --- |
| `flythrough` | Flies east at 11 blocks/s over unseen terrain, 55 s | Loading, meshing and drawing terrain |
| `combat` | Iron golems against waves of raiders in an arena, 40 s | Entities, animation, particles, projectiles |
| `lobby` | A crowded lobby: 80 armored mannequins, holograms, signs, a sidebar, particle fountains, 40 s | Entity models, text, particles |
The camera rides an invisible armor stand the server moves, so every run sees the same frames.
### Figures
Per scenario: median FPS and 1% low, p99 frame time, mean tick/extract/render/GPU ms, draw calls,
terrain sections, mesh queue, peak and live heap and linear memory (`heapLiveMB`, `nativeLiveMB`
after a full GC), and GC pauses. `slow1.*` breaks down the slowest 1% of frames (never gated).
Then the four load times, the warm start's parts, the title screen's live memory, and the download
size.
Reports: `app-web/build/benchmark/report.md` and `report.json`. Each run is appended to
`~/.incari/benchmark-history.jsonl` for the trend charts (never committed).
### Budgets and baseline
- **`app-web/benchmark/budgets.properties`:** absolute limits. Over budget fails, whatever the
baseline says. Memory budgets apply to every machine; time budgets are per machine.
- **`app-web/benchmark/baseline.properties`:** each machine's recorded figures, and how much worse
each may get (a percentage *and* an absolute amount, so noise doesn't fail). Figures without a
rule never fail.
Record a machine, or accept a deliberate change (say why in the PR):
```sh
./gradlew :app-web:benchmark -Pbenchmark.machine=desktop -Pteavm.release -Pbenchmark.updateBaseline
```
### Options
| Property | Does |
| --- | --- |
| `-Pbenchmark.machine=<name>` | Whose baseline to use (default: host name) |
| `-Pbenchmark.updateBaseline` | Record instead of compare |
| `-Pbenchmark.only=flythrough` | Only these scenarios |
| `-Pbenchmark.script=<file>` | Another script in `app-web/benchmark/` (`hudeditor.txt`, `menus.txt`, `features.txt`); give it its own `-Pbenchmark.history` |
| `-Pbenchmark.query=<options>` | Extra page options, to compare a change on and off |
| `-Pbenchmark.query=modules=<ids>` | Modules on from the start (`all`, or ids by commas): `features.txt` run with and without them |
| `-Pbenchmark.gpu=gl\|vulkan\|swiftshader` | GPU backend; SwiftShader only gives draw counts |
| `-Pbenchmark.headed` | A visible window |
| `-Pbenchmark.cpuThrottle=4` | Slow the page's CPU 4x (a Chromebook stand-in); record as e.g. `desktop-cpu4` |
| `-Pbenchmark.connect=<host:port>`, `-Pbenchmark.pageHost=<addr>` | Drive a Chrome on another device (below) |
| `-Pbenchmark.skipBuild` | Use the existing build |
| `-Pbenchmark.profile` | CPU profiles per scenario and warm start (figures don't count) |
| `-Pbenchmark.gcTrace` | V8's GC events per scenario |
| `-Pbenchmark.heapProfile`, `-Pbenchmark.heapSnapshot` | Heap sampling or snapshots at the title and after each scenario (`-Pteavm.names` names the types) |
| `-Pbenchmark.desktopJfr` | Play on the desktop under Flight Recorder, for allocation sites (no figures) |
Every run also writes each scenario's frames to `build/benchmark/<scenario>.frames.csv`.
## Singleplayer
```sh
./gradlew :app-web:benchmark -Pbenchmark.singleplayer -Pbenchmark.machine=desktop -Pteavm.release -Pteavm.fast
```
No server: the page creates the seeded world itself (`?world=&seed=`), plays 15 s, saves, quits,
reopens from a reload, then plays `singleplayer.txt` (commands typed in chat):
| Scenario | Does |
| --- | --- |
| `spawn` | Hovers over spawn, 30 s: the worker server ticking |
| `flythrough` | The same flight, with the page's own server generating terrain |
| `combat` | The arena's waves, summoned by chat: mob AI on the page's server |
Extra figures from the server worker: ticks per second, tick times (mean, p95, max), loaded chunks,
`workerHeapLiveMB`; loads `createMillis`, `saveQuitMillis`, `openMillis`, and `leftHeapLiveMB`.
Its baseline is `singleplayer-baseline.properties`; budgets are shared.
## Reference devices
| Machine | What | Status |
| --- | --- | --- |
| `chromebook-4gb` | The floor device: the 60 fps gate | Not measured: needs the device |
| `laptop-floor` | i5-8250U held to 2 cores at 2.8 GHz, Chromium in a 3 GB scope with zram (ADR 0031). Faster than the floor, so an upper bound | Recorded |
| `desktop` | Ryzen 5 9600X, RX 9060 XT (the development desktop and CI runner) | Recorded |
| `chromebook-mid`, `laptop-igpu` | Other reference machines, for choosing quality tiers | Not measured |
### Measuring a Chromebook (or any remote Chrome)
1. In developer mode, add `--remote-debugging-port=9222` to `/etc/chrome_dev.conf`, run
`sudo restart ui`, and tunnel to it: `ssh -N -L 9222:127.0.0.1:9222 root@<device>`.
2. Let the page count as secure: `chrome://flags` → **Insecure origins treated as secure** →
`http://<desktop address>:18313`. Or reverse-tunnel the page too
(`-R 18312:127.0.0.1:18312 -R 18313:127.0.0.1:18313`) and use `pageHost=127.0.0.1`.
3. Run:
```sh
./gradlew :app-web:benchmark -Pbenchmark.machine=chromebook-4gb -Pteavm.release \
-Pbenchmark.connect=127.0.0.1:9222 -Pbenchmark.pageHost=<desktop address>
```
Private networks only: the page is a build with Mojang's code. After a failed run, check
`http://127.0.0.1:9222/json/list` for a leftover tab still running a game.
## CI's `perf` job
Runs the benchmark on a self-hosted runner labelled `incari-perf` and posts the report in the job
summary; a regression fails the job. Off until set up:
1. Register a runner with the label `incari-perf` (JDK 25, Node 24+, Chrome, a GPU). Nothing is uploaded.
2. Set repository variables `INCARI_PERF_RUNNER=true` and `INCARI_PERF_MACHINE` (default `desktop`).
It never runs for pull requests from forks, whose code would run on that machine. Keep it that way.
+53
View File
@@ -0,0 +1,53 @@
# EaglerXServer notes
How Incari joins EaglerXServer, and what a future Incari server add-on could hook into. Researched
from EaglerXServer 1.1.1's source (2026-09-27). The client side is ADR 0016.
## Joining needs no add-on
The client runs Eagler's V5 handshake itself, as the first stage of its pipeline, and joins stock
EaglerXServer with default settings. EaglerXServer accepts any Minecraft protocol number by default
and, after the handshake, passes one plain packet per binary WebSocket message to the proxy.
How EaglerXServer takes a connection:
1. A WebSocket upgrade fires `EaglercraftWebSocketOpenEvent` (headers, path, channel).
2. A first text frame is a MOTD query. A first binary frame starting `01 02` is Eagler's
handshake (V2–V5), `01 01` is V1, `02 xx` a legacy handshake for the Rewind API. **Anything
else, including a vanilla handshake, is closed silently.**
3. After the handshake, EaglerXServer writes the vanilla handshake and Login Start into the proxy
itself (no online mode, compression always off).
4. Then every binary message is a vanilla packet. Messages starting `0xEE` are Eagler's own (skins,
voice, cookies); no vanilla packet uses that id.
So the client's Eagler stage runs the V5 exchange, then plays the vanilla login locally: it
swallows the game's handshake, Login Start and Login Acknowledged, answers with a Login Success from
`ALLOW_LOGIN`'s name and UUID, and routes `0xEE` messages to Incari.
Limits: the protocol number must fit 16 bits, no online mode, no compression, and the proxy must
support the game's version (or Via handles it, ADR 0017).
## For a future add-on (`server-plugin`)
Useful only for Incari-only features (plugin channels, letting servers switch modules off).
- **Rewind API** (`IEaglerXRewindService.registerLegacyProtocol`): for a `02 <byte>` first message,
it can inject Netty handlers and emulate the Eagler handshake with any protocol number. Public API.
- **`EaglercraftWebSocketOpenEvent`**: the raw channel before the first frame. Handler names are
internal, not API.
- **`EnumPipelineEvent`**: events at each stage (`EAGLER_HANDSHAKE_COMPLETE`, …).
## Constraints
- **License:** EaglerXServer is All Rights Reserved. Never copy or fork it. An add-on may compile
against its published API jars (compile-only), but ask the author before publishing one.
- **Platform:** Java 17+. Its Velocity support uses Velocity internals by reflection, so check
each Velocity version.
- **Upstream bugs seen:** `RewindService.registerLegacyProtocol`'s range check is never true;
`VanillaInitializer` drops the connection on any unexpected login packet.
## Testing
- Desktop: `./gradlew :app-desktop:smokeServer -Pincari.server=ws://<eaglerxserver>` (see `net`'s README).
- Without EaglerXServer: `tools/wsbridge` runs Eagler's handshake in front of any vanilla server.
- Browser: `app-web/browser-checks/README.md` has the BungeeCord + EaglerXServer setup.
+28
View File
@@ -0,0 +1,28 @@
# Glossary
Incari uses Mojang's official names for game concepts (since 26.1 the game ships unobfuscated),
so a name in Incari code means what it means in the game. These are the project's own terms.
| Term | Meaning |
| --- | --- |
| **Drop** | A Minecraft release Incari follows (26.3 now). Each drop means re-pinning `incari.properties`, re-fixing decompile errors and rebasing patches. |
| **Vendor tree** | The decompiled, patched game source in `work/client`. Generated, never tracked. |
| **Vendor code** | Mojang's code, in the vendor tree. Touched minimally, never reformatted. |
| **Incari code** | Everything in this repo's modules. Held to the full quality gates. |
| **Patch** | One commit in `work/client` after the `base` tag, saved as a file in `patches/<subsystem>/`. |
| **Decompile fix** | A patch in `patches/decompile/` that makes the decompiled source compile without changing behavior. |
| **Hook** | The one- or two-line call a patch adds into an Incari module. |
| **Class manifest** | `patches/classes.txt`: whole vendor classes deleted, or replaced by an Incari source file. |
| **Platform** | One implementation of `platform-api`: desktop (LWJGL) or web (browser APIs). |
| **Backend** | A Mojang `GpuBackend`: the graphics API under the renderer. OpenGL on the desktop, WebGL2 in the browser, later WebGPU. |
| **Section** | Mojang's 16×16×16 block unit of a chunk, the unit the renderer meshes. |
| **Region** | A group of sections drawn together (terrain batching, ADR 0022). |
| **Pipeline** | Mojang's `RenderPipeline`: shaders plus fixed render state. |
| **Tier** | A quality tier (Potato, Standard, High) the performance budgets scale by; to be picked from the device, player-adjustable. |
| **Floor device** | The reference 4 GB Chromebook every performance gate is measured on. |
| **Fast build** | The browser build whose threads suspend through JSPI: quicker and smaller, for browsers with JSPI (ADR 0036). |
| **Compatible build** | The browser build whose threads are TeaVM's coroutines: slower, for every browser with WebAssembly GC (ADR 0036). |
| **Eagler server** | A Minecraft server reached over a WebSocket through EaglerXServer, which runs its own login exchange first (ADR 0016). Every `ws://` or `wss://` address is taken to be one. |
| **Eagler stage** | The first stage of a WebSocket connection's pipeline (`EaglerHandshake`): Eagler's login, standing in for the vanilla one, then Eagler's own messages beside the game's packets. |
| **Via** | ViaVersion and ViaBackwards: translation between Minecraft versions, a stage of the pipeline when a server speaks another version than the game (ADR 0017). |
| **Server version** | The Minecraft protocol a server speaks, as the player chose it on the server's edit screen or as the ping found it ("Auto"). |
+208
View File
@@ -0,0 +1,208 @@
# The online service's protocol
What the client sends to Incari's online service and expects back. The service is closed source;
it implements this file, so a change here is a change to both. Client code: `:online`'s
`OnlineService`. `FakeService` (test fixtures, also served by `tools/onlinedev`) answers as the
service should. Decisions: accounts ADR 0058, friends ADR 0059, releases ADR 0060, cosmetics
ADR 0061, counts/featured/badge ADR 0062.
Protocol version: **1**.
## Framing
- One WebSocket, `wss://<host>/v1/ws`. JSON text frames, one message each, at most 16 KiB.
- Request: `{"t": "<type>", "id": <n>, ...}`, `id` counting from 1 per connection.
- Answer: `{"t": "ok", "id": <n>, ...}` or `{"t": "err", "id": <n>, "code": "<code>"}`.
- Event: a message without `id`. The client ignores unknown event types.
- Timeouts: an answer after 20 s counts as failed. No answer to `hello` within 15 s, or to
`signup`/`signin`/`recover`/`resume` in time, and the client reconnects (the service may have
signed in a connection the client doesn't know about; a fresh one starts both signed out).
### Errors
| Code | Means | Client shows |
| --- | --- | --- |
| `unauthorized` | Wrong credentials, code or password; unknown token | The form's wrong-credentials message |
| `no_session` | Needs sign-in, connection isn't | "You were signed out", and signs out |
| `taken` | Username taken | "That username is taken" |
| `bad_request`, `weak_password` | Broke a rule (length, common password, stale challenge) | "The service turned that down" |
| `closed` | Recipient doesn't take messages from the sender (setting, block, or `pid` gone). Indistinguishable on purpose | "They aren't taking messages from you" |
| `rate_limited` | Too many tries. **Never sent for sign-in**, which answers `unauthorized` after the usual delay | "Too many tries" |
| `not_owned` | `equip`/`emote` named an unowned cosmetic | Nothing; re-fetches the wardrobe |
| `update` | This protocol version is retired; the service then closes | "Update the client"; stops reconnecting |
| `unavailable`, other | Service trouble, or (`signin`, `resume`) too many connections for the account | "The service is having trouble" |
## Before signing in
| `t` | Sent | `ok` answer |
| --- | --- | --- |
| `hello` | `v` (1), `client` (`incari/<game version>`) | `v`; optionally `limits`, `release`, `featured` |
| `count` | `install`, `version`, `kind` | — |
| `challenge` | — | `challenge` (16 bytes, base64url, no padding), `bits` (0–40) |
| `signup` | `username`, `password`, `challenge`, `nonce` | `token`, `recoveryCodes` (10), `account` |
| `signin` | `username`, `password` | `token`, `account` |
| `resume` | `token` | `account` |
| `recover` | `username`, `code`, `newPassword` | `token`, `account` (all other sessions end) |
- **`release`**: `{"version": "<latest release>"}`, 1–4 dot-separated numbers of up to 6 digits.
A release build shows a title-screen notice, linking to the built-in repository URL, when it's
newer than its own (missing parts count as 0). Malformed or absent: no notice. Sent signed in or not.
- **`featured`**: up to 4 `{"name": <1–32 chars>, "address": <1–128 chars>}` pinned atop the server
list as Sponsored. Present (even `[]`) it replaces the built-in list for this run; absent, the
built-in list stays. Out-of-bounds entries are dropped. Sent signed in or not.
- **`count`**: an install ran today. `install` is 16 random bytes (base64url, 22 chars), made once,
never tied to an account; `version` as `release`; `kind` is `fast`, `compatible`, `html` or
`desktop`. At most once a UTC day, after `hello`, never with Usage Counts off. Any answer but
`rate_limited` uses the day (errors too); `rate_limited` retries after 30 minutes, no answer after
a minute. The service keeps no IP or account: a keyed hash of `install` per day (35 days) and
daily totals by `version` and `kind`. Repeats get `ok`; malformed is `bad_request`.
- **`account`**: `{"username", "settings": {"shareServer": <bool>, "messages": "everyone" |
"friends" | "nobody", "friendRequests": <bool>, "badge": <bool>}}`. Older services may omit
`messages`/`friendRequests` (client assumes `friends`/`true`) or `badge` (assumes `true`).
- **Resume:** sent right after `hello` if a token is saved. `unauthorized` or `no_session` forgets it.
- **Proof of work:** SHA-256 of the 16 challenge bytes then the nonce as 8 bytes big-endian must
start with `bits` zero bits. Nonce is 0 to 2^53−1, a JSON number, tried from 0 up. A challenge
lasts 2 minutes and one successful sign-up (a wrong nonce doesn't use it).
- **Recovery codes:** `XXXX-XXXX-XXXX`, Crockford base32 upper case. The client normalizes input
(case, spaces, dashes; I and L → 1, O → 0).
- **Usernames:** 3–16 of `[A-Za-z0-9_]`, unique ignoring case. **Passwords:** 10–128 characters,
not common, not containing the username.
## Signed in
| `t` | Sent | `ok` answer |
| --- | --- | --- |
| `presence` | `serverHash`, `name`, `server` (only while shared); or `serverHash: null` to clear | — |
| `lookup` | `names` (1–256 Minecraft names) | `players`: `[{"name", "pid", "friend", "cosmetics", "badge"}]` for Incari players on the asker's server |
| `settings` | any of `shareServer`, `messages`, `friendRequests`, `badge` | — |
| `password` | `old`, `new` | — (all other sessions end) |
| `codes` | `password` | `recoveryCodes` (10 new; old ones stop working) |
| `signout` | `everywhere` (bool) | — |
| `delete` | `password` | — |
| `block` | `pid` and `name` (as seen), or `username` | — |
| `blocks` | — | `blocks`: `[{"bid", "label"}]` |
| `unblock` | `bid` | — |
| `report` | `pid` or `username`, `reason`, `note` (≤500 chars) | — |
- **Server hash:** SHA-256 (64 lowercase hex) of `incari-server-v1\n` + the normalized address:
- trimmed;
- plain address: host lower case, no trailing dot, port only if not 25565 (`[v6]:port` for IPv6);
- `ws://`/`wss://`: scheme and host lower case, port only if not 80/443, path as written without
a trailing slash, query and fragment dropped;
- `relay:<code>` for a relay-shared world, code as typed.
Test vectors (made with Python's hashlib): `:online`'s `vectors.json`.
- **Presence:** singleplayer and the player's own LAN world are never reported. A `presence`
replaces the last; the service clears it when the connection drops. The client sends one only
when it changes what the service holds, one at a time. On leaving a world it waits 10 s before
clearing (a proxy server switch rejoins the same address, which isn't a change; the service limits
changes to about 30 an hour). Retries after `rate_limited`, `unavailable` or no answer: 1 minute,
doubling to 15. After `bad_request`: not until the place changes. Resent after a reconnect.
- **Lookups:** the whole tab list on join, then names as they're added, at most one lookup per
6.5 s; all again after a reconnect. The service sends `seen`/`gone` only for names this connection
looked up, so reporting a server's hash without being there reveals nothing. It answers only for
names an account has reported on the asker's `serverHash` right now; nothing for a name two
accounts claim; nothing across a block either way.
- **`pid`:** the account's id on that server only, so it never follows an account between servers.
- **Block `label`:** the name the blocker saw (by `pid`) or typed (by `username`). Never reveals a
blocked account's username. `bid` is opaque.
- **Report reasons:** `harassment`, `inappropriate_name`, `spam`, `impersonation`, `other`.
- **`badge`** ("Show others I use Incari", default `true`): carried by `lookup` and `seen`; the client
draws the Incari icon only when `true`. Changes go out as a `badge` event like a wardrobe change.
It hides the icon, not the account: lookups still answer.
## Friends and messages
The client sends `friends` after every sign-in. `bad_request` means the service has no friends
support; the client says so and stops asking.
| `t` | Sent | `ok` answer |
| --- | --- | --- |
| `friends` | — | `friends`: `[F + "unread"]`, `requests`: `[R]` |
| `befriend` | `pid` and `name`, or `username` | `request`: R, or `friend`: F (they'd already asked) |
| `accept` | `rid` (received) | `friend`: F |
| `decline` | `rid` (declines received, withdraws sent) | — |
| `unfriend` | `fid` | — |
| `send` | `fid` or `pid`, `text` (1–500 chars) | `mid`, `at` |
| `history` | `fid`, optional `before` (a `mid`) | `messages`: `[M]` (≤50, before `before` or newest), `more` |
| `read` | `fid`, optional `mid` (newest read) | — |
- **F:** `{"fid", "username", "online", "server"}`; `server` only while online and shared.
`unread` (in `friends` only) counts unread messages.
- **R:** `{"rid", "incoming", "label"}`. Received: the sender's username. Sent: the `name` or
`username` it went to. A request by `pid` never reveals the receiver's username.
- **M:** `{"mid", "from": "me" | "them", "text", "at"}`, `at` in ms since 1970 UTC.
- `fid`, `rid`, `mid` are opaque strings.
- **`befriend`:** unknown username or yourself → `bad_request`. To someone with `friendRequests`
off, or across a block: `ok` with R, never delivered. Repeats return the first R. Crossing
requests make a friendship.
- **`send`:** to a friend needs the friendship and their `messages` not `nobody`. By `pid` needs the
recipient on the sender's server now with `messages: everyone`. Otherwise, or across a block:
`closed`. Text is trimmed; empty is `bad_request`.
- **Blocking a friend** ends the friendship (`unfriended` both sides; pending requests →
`requestgone`).
- **History** is kept for friends only (30 days). Messages by `pid` are live only, kept just for reports.
- **After a reconnect** the client takes the unread counts as given and re-fetches the newest
`history` page for each held conversation when next shown. It sends `read` only after that page,
so it never marks unseen messages read.
## Cosmetics
The client sends `wardrobe` after every sign-in and resume. `bad_request` means no cosmetics
support; worn cosmetics then stay on the device.
| `t` | Sent | `ok` answer |
| --- | --- | --- |
| `wardrobe` | — | `owned`: `[id]`, `equipped`: `[id]` |
| `equip` | `cosmetics`: `[id]` (everything worn now; `[]` for none) | `equipped`: `[id]` |
| `emote` | `emote`: an id | — |
- **Ids:** `<slot>.<name>`, lowercase letters, digits, `_`, one dot. The catalog is `:online`'s
`Catalog`; the service keeps the same list and which are free.
- **`owned`** includes free ones. **`equipped`**: at most one per worn slot (`cape`, `hat`, `back`,
`nametag`, `trail`). Emotes are owned, never equipped.
- **`equip`** replaces what's worn. Unknown id, an emote, two in a slot or more than five →
`bad_request`; unowned → `not_owned`; nothing changes. On `ok`, a `cosmetics` event goes to every
connection that looked this account up on a server it's on (as `seen`, blocks respected), and a
`wardrobe` event to the account's other connections. Grants and revokes fan out the same way.
The client sends at most one a second after changes stop; the service may limit (~30/minute).
- **`emote`:** an `emote` event to every connection that looked the player up on their current
server (blocks excepted); `ok` even if nobody hears. Client: at most one per 2 s; service may limit
(~20/minute). Never stored.
- `lookup`, `seen` and `cosmetics` carry the wearer's `equipped`. Clients draw only ids they know,
so the service can add cosmetics first.
- **No uploads or one-of-a-kind cosmetics:** a unique cosmetic would follow an account between
servers, past what `pid` hides.
| Slot | Ids (all free for now) |
| --- | --- |
| `cape` | `cape.frost`, `cape.aurora`, `cape.midnight`, `cape.ember`, `cape.sakura`, `cape.tide`, `cape.mono` |
| `hat` | `hat.crown`, `hat.halo`, `hat.top_hat`, `hat.beanie`, `hat.horns`, `hat.cat_ears` |
| `back` | `back.angel_wings`, `back.frost_wings`, `back.bat_wings`, `back.backpack` |
| `nametag` | `nametag.ice`, `nametag.gold`, `nametag.mint`, `nametag.rose`, `nametag.violet`, `nametag.frost`, `nametag.sunset`, `nametag.aurora` |
| `trail` | `trail.snow`, `trail.hearts`, `trail.sparkles`, `trail.notes` |
| `emote` | `emote.wave`, `emote.clap`, `emote.cheer`, `emote.salute`, `emote.facepalm`, `emote.shrug`, `emote.dab`, `emote.bow` |
## Events
| `t` | Fields | When |
| --- | --- | --- |
| `seen` | `name`, `pid`, `friend`, `cosmetics`, `badge` | A looked-up name arrived as an Incari player on the asker's server (no block either way) |
| `gone` | `pid` | They left, signed out, or a block came between (looked-up names only) |
| `cosmetics` | `pid`, `cosmetics` | A looked-up player on the asker's server changed what they wear |
| `wardrobe` | `owned`, `equipped` | The account's wardrobe changed elsewhere, or it was given a cosmetic |
| `badge` | `pid`, `badge` | A looked-up player on the asker's server changed `badge` |
| `emote` | `pid`, `emote` | A looked-up player on the asker's server played an emote |
| `request` | R | A friend request arrived (or one the asker sent from elsewhere, `incoming: false`) |
| `requestgone` | `rid` | A request was accepted, declined or withdrawn |
| `friend` | `friend`: F | A new friendship, or a friend went on/offline or changed server |
| `unfriended` | `fid` | Unfriended or blocked, either side |
| `message` | `mid`, `at`, `text`, and `fid` or `pid` + `name` | A message for the asker |
| `signedout` | — | The session ended elsewhere (sign out everywhere, new password, recovery, deletion, ban). The client forgets its token |
## The client never
- Sends or keeps a password beyond its form and the one message that carries it.
- Logs passwords, tokens or recovery codes.
- Waits on the service: nothing in the game blocks on an answer, and without a service the client
behaves as if accounts didn't exist.
+945
View File
@@ -0,0 +1,945 @@
# Port backlog: Minecraft 26.3 under TeaVM
Generated by `./incari survey`. Don't edit it by hand: change `tools/survey/rules.txt` and rerun.
TeaVM 0.15.0 (WebAssembly GC) reaches 41,519 classes when every client class is a root (not just what `net.minecraft.client.main.Main` reaches). 6,258 call sites use 2,306 APIs the browser build can't provide as-is, grouped below into 48 work items.
## Summary
| Category | Meaning | Work items | APIs | Call sites |
| --- | --- | ---: | ---: | ---: |
| Stub | A no-op or trivial implementation is enough. | 6 | 141 | 411 |
| Shim | Needs a real implementation, over a browser API or simpler Java. | 8 | 417 | 1737 |
| Rewrite | The calling code has to change: a patch or a replacement class. | 16 | 723 | 1883 |
| Delete | The feature is stripped from the browser build. | 18 | 1145 | 2227 |
| **Total** | | 48 | 2306 | 6258 |
By kind of finding:
| Kind | Call sites | What it means |
| --- | ---: | --- |
| missing class | 2664 | TeaVM can't find the class: not in its class library, or in a library left off the classpath |
| missing method | 340 | The class exists in TeaVM's class library but lacks this method |
| unsupported on target | 1 | TeaVM knows it but can't support it on WebAssembly GC |
| missing supertype | 1 | A class extends or implements something that isn't on the classpath |
| JDK class TeaVM lacks | 2832 | A JDK class that TeaVM's class library doesn't have; the game or a library uses it here |
| reflection | 420 | Reflective lookup that TeaVM's closed-world compile can't see |
## Stub
A no-op or trivial implementation is enough. 6 work items, 141 APIs, 411 call sites.
| Work item | APIs | Call sites | Where the calls are |
| --- | ---: | ---: | --- |
| sun.misc.Unsafe in libraries: stub it as unavailable so Netty, Guava and JOML take their safe fallbacks | 47 | 224 | `joml` (107), `netty-common` (100), `guava` (17) |
| Small JDK methods and classes TeaVM's class library lacks: add them to the class library | 57 | 124 | `net.minecraft.util` (21), `guava` (10), `com.mojang.blaze3d.platform` (9), `net.minecraft.nbt` (9), +33 more |
| JVM memory, GC and thread stats (debug overlay, crash reports, watchdog): report browser numbers or zeros | 19 | 28 | `net.minecraft` (10), `net.minecraft.client.gui.components.debug` (10), `net.minecraft.util` (4), `net.minecraft.client` (2), +2 more |
| Process control (exit, shutdown hooks, environment, native libraries): no-ops in a browser tab | 4 | 16 | `net.minecraft.client.main` (4), `net.minecraft.client` (3), `com.mojang.blaze3d.platform` (2), `netty-buffer` (2), +5 more |
| Caller lookup (StackWalker, modules): return nothing | 9 | 11 | `net.minecraft.util.profiling` (8), `logging` (3) |
| Thread details TeaVM lacks (ids, state, onSpinWait): trivial answers under coroutines | 5 | 8 | `net.minecraft.client` (2), `net.minecraft.client.renderer.chunk` (2), `netty-common` (2), `com.mojang.blaze3d.platform` (1), +1 more |
### sun.misc.Unsafe in libraries: stub it as unavailable so Netty, Guava and JOML take their safe fallbacks
| API | Kind | Call sites |
| --- | --- | ---: |
| `sun.misc.Unsafe#objectFieldOffset` | JDK class TeaVM lacks | 35 |
| `jdk.internal.misc.Unsafe#objectFieldOffset` | JDK class TeaVM lacks | 27 |
| `sun.misc.Unsafe#getLong` | JDK class TeaVM lacks | 20 |
| `sun.misc.Unsafe` | JDK class TeaVM lacks | 13 |
| `sun.misc.Unsafe#putLong` | JDK class TeaVM lacks | 10 |
| `jdk.internal.misc.Unsafe#getLong` | JDK class TeaVM lacks | 7 |
| `jdk.internal.misc.Unsafe#putLongUnaligned` | JDK class TeaVM lacks | 7 |
| `jdk.internal.misc.Unsafe#getLongUnaligned` | JDK class TeaVM lacks | 6 |
| `sun.misc.Unsafe#arrayBaseOffset` | JDK class TeaVM lacks | 6 |
| `sun.misc.Unsafe#putOrderedLong` | JDK class TeaVM lacks | 6 |
| `sun.misc.Unsafe#arrayIndexScale` | JDK class TeaVM lacks | 5 |
| `sun.misc.Unsafe#compareAndSwapLong` | JDK class TeaVM lacks | 5 |
| ...and 35 more | | 77 |
### Small JDK methods and classes TeaVM's class library lacks: add them to the class library
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.util.HexFormat#toHexDigits` | JDK class TeaVM lacks | 12 |
| `java.util.HexFormat#of` | JDK class TeaVM lacks | 11 |
| `java.util.HexFormat#withUpperCase` | JDK class TeaVM lacks | 7 |
| `java.lang.Character#toString` | missing method | 6 |
| `java.lang.Class#getGenericSuperclass` | missing method | 6 |
| `java.util.UUID#<init>` | missing method | 5 |
| `java.util.UUID#getMostSignificantBits` | missing method | 5 |
| `java.nio.ByteBuffer#slice` | missing method | 4 |
| `java.util.StringJoiner#add` | JDK class TeaVM lacks | 4 |
| `java.util.stream.StreamSupport#intStream` | missing method | 3 |
| `java.io.BufferedReader#transferTo` | missing method | 2 |
| `java.io.ObjectStreamClass` | JDK class TeaVM lacks | 2 |
| ...and 45 more | | 57 |
### JVM memory, GC and thread stats (debug overlay, crash reports, watchdog): report browser numbers or zeros
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.lang.management.ManagementFactory#getMemoryMXBean` | JDK class TeaVM lacks | 3 |
| `java.lang.management.ManagementFactory#getRuntimeMXBean` | JDK class TeaVM lacks | 2 |
| `java.lang.management.MemoryMXBean#getHeapMemoryUsage` | JDK class TeaVM lacks | 2 |
| `java.lang.management.MemoryMXBean#getNonHeapMemoryUsage` | JDK class TeaVM lacks | 2 |
| `java.lang.management.MemoryUsage#getCommitted` | JDK class TeaVM lacks | 2 |
| `java.lang.management.MemoryUsage#getInit` | JDK class TeaVM lacks | 2 |
| `java.lang.management.MemoryUsage#getMax` | JDK class TeaVM lacks | 2 |
| `java.lang.management.MemoryUsage#getUsed` | JDK class TeaVM lacks | 2 |
| `java.lang.management.GarbageCollectorMXBean` | JDK class TeaVM lacks | 1 |
| `java.lang.management.GarbageCollectorMXBean#getCollectionCount` | JDK class TeaVM lacks | 1 |
| `java.lang.management.ManagementFactory#getGarbageCollectorMXBeans` | JDK class TeaVM lacks | 1 |
| `java.lang.management.ManagementFactory#getPlatformMBeanServer` | JDK class TeaVM lacks | 1 |
| ...and 7 more | | 7 |
### Process control (exit, shutdown hooks, environment, native libraries): no-ops in a browser tab
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.lang.Runtime#maxMemory` | missing method | 8 |
| `java.lang.System#exit` | missing method | 6 |
| `java.lang.Runtime#addShutdownHook` | missing method | 1 |
| `java.lang.System#mapLibraryName` | missing method | 1 |
### Caller lookup (StackWalker, modules): return nothing
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.lang.StackWalker#getInstance` | JDK class TeaVM lacks | 2 |
| `java.lang.StackWalker$Option#RETAIN_CLASS_REFERENCE` | JDK class TeaVM lacks | 2 |
| `java.lang.StackWalker#getCallerClass` | JDK class TeaVM lacks | 1 |
| `java.lang.StackWalker#walk` | JDK class TeaVM lacks | 1 |
| `java.lang.StackWalker$StackFrame` | JDK class TeaVM lacks | 1 |
| `java.lang.StackWalker$StackFrame#getDeclaringClass` | JDK class TeaVM lacks | 1 |
| `java.lang.StackWalker$StackFrame#getFileName` | JDK class TeaVM lacks | 1 |
| `java.lang.StackWalker$StackFrame#getLineNumber` | JDK class TeaVM lacks | 1 |
| `java.lang.StackWalker$StackFrame#getMethodName` | JDK class TeaVM lacks | 1 |
### Thread details TeaVM lacks (ids, state, onSpinWait): trivial answers under coroutines
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.lang.Thread#onSpinWait` | missing method | 3 |
| `java.lang.Thread#threadId` | missing method | 2 |
| `java.lang.Thread#getState` | missing method | 1 |
| `java.lang.Thread#setContextClassLoader` | missing method | 1 |
| `java.lang.Thread#sleep` | missing method | 1 |
## Shim
Needs a real implementation, over a browser API or simpler Java. 8 work items, 417 APIs, 1737 call sites.
| Work item | APIs | Call sites | Where the calls are |
| --- | ---: | ---: | --- |
| CompletableFuture (async loading everywhere): a single-threaded implementation over TeaVM coroutines | 36 | 628 | `net.minecraft.server.level` (100), `net.minecraft.client.resources.model` (40), `net.minecraft.world.level.chunk.storage` (36), `net.minecraft.server` (31), +56 more |
| Locks, atomics and concurrent queues: single-threaded shims | 112 | 452 | `guava` (160), `netty-buffer` (65), `netty-common` (51), `net.minecraft.client.color.block` (28), +24 more |
| java.time (dates, durations, formatting): compile a java.time implementation for TeaVM | 128 | 342 | `gson` (98), `net.minecraft.world.level.storage` (29), `net.minecraft.util` (28), `authlib` (20), +35 more |
| Filesystem (java.nio.file, channels, locks, watching): an in-memory file system kept in OPFS or IndexedDB (ADR 0011) | 93 | 232 | `commons-io` (27), `netty-buffer` (24), `net.minecraft.util.filefix.virtualfilesystem` (21), `net.minecraft.util` (18), +26 more |
| Bidi text and localized dates (ICU): the browser's Intl, or a minimal shim | 26 | 33 | `net.minecraft.client.renderer.item.properties.select` (13), `net.minecraft.client.resources.language` (11), `net.minecraft.client.gui` (8), `net.minecraft.client.gui.screens` (1) |
| Executors, thread pools and futures: a coroutine scheduler, later Web Workers | 12 | 28 | `guava` (8), `netty-common` (8), `net.minecraft.util` (4), `netty-transport` (3), +4 more |
| Narrator: Web Speech API | 5 | 13 | `net.minecraft.client` (9), `net.minecraft.client.gui.screens` (4) |
| ScopedValue (Java 25): a thread-local style shim | 5 | 9 | `net.minecraft.world.level.block.state` (5), `net.minecraft.util.filefix.access` (2), `net.minecraft.util.filefix.operations` (2) |
### CompletableFuture (async loading everywhere): a single-threaded implementation over TeaVM coroutines
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.util.concurrent.CompletableFuture` | JDK class TeaVM lacks | 83 |
| `java.util.concurrent.CompletableFuture#supplyAsync` | JDK class TeaVM lacks | 63 |
| `java.util.concurrent.CompletableFuture#completedFuture` | JDK class TeaVM lacks | 60 |
| `java.util.concurrent.CompletableFuture#join` | JDK class TeaVM lacks | 60 |
| `java.util.concurrent.CompletableFuture#thenCompose` | JDK class TeaVM lacks | 37 |
| `java.util.concurrent.CompletableFuture#thenApply` | JDK class TeaVM lacks | 32 |
| `java.util.concurrent.CompletableFuture#thenAcceptAsync` | JDK class TeaVM lacks | 28 |
| `java.util.concurrent.CompletableFuture#complete` | JDK class TeaVM lacks | 27 |
| `java.util.concurrent.CompletableFuture#<init>` | JDK class TeaVM lacks | 24 |
| `java.util.concurrent.CompletableFuture#allOf` | JDK class TeaVM lacks | 22 |
| `java.util.concurrent.CompletableFuture#getNow` | JDK class TeaVM lacks | 21 |
| `java.util.concurrent.CompletableFuture#exceptionally` | JDK class TeaVM lacks | 16 |
| ...and 24 more | | 155 |
### Locks, atomics and concurrent queues: single-threaded shims
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.util.concurrent.atomic.AtomicReferenceArray#get` | JDK class TeaVM lacks | 45 |
| `java.util.concurrent.atomic.AtomicReferenceArray#length` | JDK class TeaVM lacks | 39 |
| `java.util.concurrent.atomic.AtomicReferenceArray#set` | JDK class TeaVM lacks | 26 |
| `java.util.concurrent.locks.ReentrantLock#lock` | JDK class TeaVM lacks | 16 |
| `java.util.concurrent.locks.ReentrantLock#unlock` | JDK class TeaVM lacks | 16 |
| `com.google.common.cache.LocalCache$Segment#unlock` | missing method | 13 |
| `java.util.concurrent.atomic.LongAdder` | JDK class TeaVM lacks | 11 |
| `java.util.concurrent.atomic.LongAdder#<init>` | JDK class TeaVM lacks | 11 |
| `java.util.concurrent.atomic.LongAdder#add` | JDK class TeaVM lacks | 11 |
| `com.google.common.cache.LocalCache$Segment#lock` | missing method | 10 |
| `java.util.concurrent.locks.ReentrantLock` | JDK class TeaVM lacks | 10 |
| `java.util.concurrent.locks.ReentrantLock#<init>` | JDK class TeaVM lacks | 10 |
| ...and 100 more | | 234 |
### java.time (dates, durations, formatting): compile a java.time implementation for TeaVM
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.time.Instant#now` | JDK class TeaVM lacks | 49 |
| `java.time.ZoneOffset` | JDK class TeaVM lacks | 12 |
| `java.time.format.DateTimeFormatter#format` | JDK class TeaVM lacks | 10 |
| `java.time.Duration#between` | JDK class TeaVM lacks | 9 |
| `java.time.Duration#ofMinutes` | JDK class TeaVM lacks | 9 |
| `java.time.Duration#toMillis` | JDK class TeaVM lacks | 9 |
| `java.time.LocalTime` | JDK class TeaVM lacks | 8 |
| `java.time.Instant` | JDK class TeaVM lacks | 7 |
| `java.time.MonthDay#of` | JDK class TeaVM lacks | 7 |
| `java.time.ZonedDateTime#now` | JDK class TeaVM lacks | 7 |
| `java.time.LocalDateTime` | JDK class TeaVM lacks | 6 |
| `java.time.format.DateTimeFormatterBuilder#appendValue` | JDK class TeaVM lacks | 6 |
| ...and 116 more | | 203 |
### Filesystem (java.nio.file, channels, locks, watching): an in-memory file system kept in OPFS or IndexedDB (ADR 0011)
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.io.File#toPath` | missing method | 29 |
| `java.nio.channels.FileChannel#write` | JDK class TeaVM lacks | 13 |
| `java.nio.channels.FileChannel#close` | JDK class TeaVM lacks | 12 |
| `java.nio.channels.FileChannel#open` | JDK class TeaVM lacks | 9 |
| `java.nio.file.attribute.BasicFileAttributeView` | JDK class TeaVM lacks | 9 |
| `java.nio.channels.FileChannel#read` | JDK class TeaVM lacks | 8 |
| `java.nio.channels.GatheringByteChannel#write` | JDK class TeaVM lacks | 7 |
| `java.nio.file.Files#getFileStore` | missing method | 6 |
| `java.nio.channels.ScatteringByteChannel#read` | JDK class TeaVM lacks | 5 |
| `java.nio.file.PathMatcher` | JDK class TeaVM lacks | 5 |
| `java.nio.file.PathMatcher#matches` | JDK class TeaVM lacks | 5 |
| `java.nio.channels.FileChannel#tryLock` | JDK class TeaVM lacks | 4 |
| ...and 81 more | | 120 |
### Bidi text and localized dates (ICU): the browser's Intl, or a minimal shim
| API | Kind | Call sites |
| --- | --- | ---: |
| `com.ibm.icu.text.ArabicShaping` | missing class | 2 |
| `com.ibm.icu.text.ArabicShaping#<init>` | missing class | 2 |
| `com.ibm.icu.text.ArabicShaping#shape` | missing class | 2 |
| `com.ibm.icu.text.Bidi` | missing class | 2 |
| `com.ibm.icu.text.Bidi#<init>` | missing class | 2 |
| `com.ibm.icu.text.Bidi#setReorderingMode` | missing class | 2 |
| `com.ibm.icu.util.Calendar#getInstance` | missing class | 2 |
| `com.ibm.icu.text.ArabicShapingException` | missing class | 1 |
| `com.ibm.icu.text.Bidi#countRuns` | missing class | 1 |
| `com.ibm.icu.text.Bidi#getVisualRun` | missing class | 1 |
| `com.ibm.icu.text.Bidi#writeReordered` | missing class | 1 |
| `com.ibm.icu.text.BidiRun#getLength` | missing class | 1 |
| ...and 14 more | | 14 |
### Executors, thread pools and futures: a coroutine scheduler, later Web Workers
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.util.concurrent.RejectedExecutionException` | JDK class TeaVM lacks | 12 |
| `java.util.concurrent.ScheduledFuture` | JDK class TeaVM lacks | 3 |
| `java.util.concurrent.AbstractExecutorService` | JDK class TeaVM lacks | 2 |
| `java.util.concurrent.Future` | JDK class TeaVM lacks | 2 |
| `net.minecraft.util.Util$2#getName` | missing method | 2 |
| `com.google.common.util.concurrent.ListenableFuture#isDone` | missing method | 1 |
| `java.util.concurrent.ExecutorService` | JDK class TeaVM lacks | 1 |
| `java.util.concurrent.ForkJoinPool` | JDK class TeaVM lacks | 1 |
| `java.util.concurrent.ForkJoinWorkerThread` | JDK class TeaVM lacks | 1 |
| `java.util.concurrent.RunnableFuture` | JDK class TeaVM lacks | 1 |
| `java.util.concurrent.ScheduledExecutorService` | JDK class TeaVM lacks | 1 |
| `java.util.concurrent.ScheduledThreadPoolExecutor` | JDK class TeaVM lacks | 1 |
### Narrator: Web Speech API
| API | Kind | Call sites |
| --- | --- | ---: |
| `com.mojang.text2speech.Narrator#active` | missing class | 4 |
| `com.mojang.text2speech.Narrator#clear` | missing class | 3 |
| `com.mojang.text2speech.Narrator#getNarrator` | missing class | 3 |
| `com.mojang.text2speech.Narrator#say` | missing class | 2 |
| `com.mojang.text2speech.Narrator#destroy` | missing class | 1 |
### ScopedValue (Java 25): a thread-local style shim
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.lang.ScopedValue#get` | JDK class TeaVM lacks | 2 |
| `java.lang.ScopedValue#newInstance` | JDK class TeaVM lacks | 2 |
| `java.lang.ScopedValue#where` | JDK class TeaVM lacks | 2 |
| `java.lang.ScopedValue$Carrier#run` | JDK class TeaVM lacks | 2 |
| `java.lang.ScopedValue#isBound` | JDK class TeaVM lacks | 1 |
## Rewrite
The calling code has to change: a patch or a replacement class. 16 work items, 723 APIs, 1883 call sites.
| Work item | APIs | Call sites | Where the calls are |
| --- | ---: | ---: | --- |
| OpenGL backend: replace with a WebGL2 GpuDevice backend | 202 | 352 | `com.mojang.renderpearl.backend.opengl` (351), `com.mojang.blaze3d.platform` (1) |
| Library reflection: steer the library off the reflective path, or declare it for TeaVM | 33 | 286 | `netty-common` (136), `joml` (67), `guava` (36), `netty-transport` (24), +3 more |
| Off-heap memory (MemoryUtil, MemoryStack, pointers): rewrite over ArrayBuffer | 43 | 231 | `com.mojang.blaze3d.platform` (72), `com.mojang.renderpearl.frontend.shaders` (46), `com.mojang.blaze3d.vertex` (37), `net.minecraft.client.gui.font.providers` (15), +13 more |
| Window, input, clipboard and events (SDL3): canvas, Pointer Lock and DOM events | 129 | 209 | `com.mojang.blaze3d.platform` (183), `com.mojang.blaze3d.systems` (15), `net.minecraft.client` (4), `com.mojang.blaze3d` (3), +2 more |
| Socket addresses, proxies and HTTP: server addresses become WebSocket URLs, HTTP becomes fetch | 82 | 198 | `netty-transport` (73), `netty-common` (38), `guava` (21), `net.minecraft.client.main` (13), +14 more |
| VarHandle and MethodHandle (Netty, Guava atomics): the libraries probe for them and fall back when they throw; patch any game caller | 21 | 100 | `netty-common` (63), `netty-buffer` (24), `guava` (11), `com.mojang.blaze3d.platform` (2) |
| Netty's NIO transport (selectors, socket channels): in the browser, connections are WebSockets on local event loops | 43 | 91 | `netty-transport` (91) |
| Logging backend discovery (ServiceLoader, class loading): bind the console logger directly | 40 | 88 | `log4j-api` (74), `slf4j-api` (12), `logging` (2) |
| Shader toolchain: GLSL to SPIR-V (shaderc) and back (SPIRV-Cross) runs natively; move it to build time | 46 | 76 | `com.mojang.renderpearl.frontend.shaders` (66), `com.mojang.renderpearl.api.pipeline` (10) |
| Gson reflective type adapters: register explicit adapters, or keep Gson on JsonElement trees | 24 | 74 | `gson` (74) |
| Audio (OpenAL): Web Audio | 49 | 70 | `com.mojang.blaze3d.audio` (67), `net.minecraft.client.sounds` (2), `com.mojang.blaze3d.platform` (1) |
| Netty channels and pipeline: WebSocket transport under Connection | 31 | 43 | `netty-common` (19), `netty-buffer` (17), `netty-transport` (7) |
| TrueType fonts (FreeType): pre-baked glyph atlases, Canvas2D for pack fonts | 28 | 38 | `com.mojang.blaze3d.font` (14), `com.mojang.blaze3d.platform` (13), `net.minecraft.client.gui.font.providers` (11) |
| Game code using reflection: replace with direct references | 11 | 14 | `com.mojang.blaze3d.platform` (8), `net.minecraft.client.multiplayer.resolver` (2), `net.minecraft.world.entity.boss.enderdragon.phases` (2), `net.minecraft.network.syncher` (1), +1 more |
| Image decode and encode (STB): createImageBitmap or a pure-Java codec | 10 | 12 | `com.mojang.blaze3d.platform` (12) |
| Netty's own thread class (a ThreadGroup constructor TeaVM lacks): event loops get their threads from the game's factory | 1 | 1 | `netty-common` (1) |
### OpenGL backend: replace with a WebGL2 GpuDevice backend
| API | Kind | Call sites |
| --- | --- | ---: |
| `org.lwjgl.PointerBuffer#get` | missing class | 10 |
| `org.lwjgl.system.MemoryStack#close` | missing class | 10 |
| `org.lwjgl.system.MemoryUtil#memAddress` | missing class | 8 |
| `org.lwjgl.util.spvc.SpvcReflectedResource#id` | missing class | 7 |
| `org.lwjgl.opengl.GL33C#glBindTexture` | missing class | 6 |
| `org.lwjgl.opengl.GL33C#glEnable` | missing class | 6 |
| `org.lwjgl.opengl.GL33C#glSamplerParameteri` | missing class | 6 |
| `org.lwjgl.system.MemoryUtil#memCopy` | missing class | 6 |
| `org.lwjgl.util.spvc.Spvc#spvc_compiler_options_set_bool` | missing class | 6 |
| `org.lwjgl.util.spvc.Spvc#spvc_compiler_set_name` | missing class | 6 |
| `org.lwjgl.sdl.SDLVideo#SDL_GL_SetAttribute` | missing class | 5 |
| `org.lwjgl.system.MemoryStack#callocPointer` | missing class | 5 |
| ...and 190 more | | 271 |
### Library reflection: steer the library off the reflective path, or declare it for TeaVM
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.lang.Class#getDeclaredField` | reflection | 67 |
| `java.lang.Class#forName` | reflection | 37 |
| `java.lang.Class#getDeclaredMethod` | reflection | 32 |
| `java.lang.invoke.MethodHandles$Lookup#findVirtual` | reflection | 25 |
| `java.lang.Class#getMethod` | reflection | 14 |
| `java.lang.invoke.MethodHandles$Lookup#findStatic` | reflection | 14 |
| `java.lang.invoke.MethodHandles#lookup` | reflection | 10 |
| `java.lang.reflect.Method#invoke` | reflection | 10 |
| `java.lang.invoke.MethodHandles#publicLookup` | reflection | 8 |
| `java.lang.reflect.Field#get` | reflection | 7 |
| `java.lang.ClassLoader#getSystemClassLoader` | reflection | 6 |
| `java.lang.reflect.Constructor#newInstance` | reflection | 6 |
| ...and 21 more | | 50 |
### Off-heap memory (MemoryUtil, MemoryStack, pointers): rewrite over ArrayBuffer
| API | Kind | Call sites |
| --- | --- | ---: |
| `org.lwjgl.system.MemoryStack#close` | missing class | 50 |
| `org.lwjgl.system.MemoryStack#stackPush` | missing class | 25 |
| `org.lwjgl.system.MemoryUtil#memFree` | missing class | 15 |
| `org.lwjgl.PointerBuffer#get` | missing class | 14 |
| `org.lwjgl.system.MemoryUtil#memPutFloat` | missing class | 12 |
| `org.lwjgl.system.MemoryStack#mallocInt` | missing class | 11 |
| `org.lwjgl.system.MemoryStack#callocPointer` | missing class | 8 |
| `org.lwjgl.system.MemoryUtil#memCopy` | missing class | 8 |
| `org.lwjgl.system.MemoryUtil#memUTF8` | missing class | 8 |
| `org.lwjgl.system.MemoryUtil#memAlloc` | missing class | 7 |
| `org.lwjgl.system.MemoryUtil#memPutByte` | missing class | 7 |
| `org.lwjgl.system.MemoryUtil#memPutShort` | missing class | 5 |
| ...and 31 more | | 61 |
### Window, input, clipboard and events (SDL3): canvas, Pointer Lock and DOM events
| API | Kind | Call sites |
| --- | --- | ---: |
| `org.lwjgl.sdl.SDLError#SDL_GetError` | missing class | 25 |
| `org.lwjgl.sdl.SDLHints#SDL_SetHint` | missing class | 9 |
| `org.lwjgl.sdl.SDLInit#SDL_SetAppMetadataProperty` | missing class | 7 |
| `org.lwjgl.sdl.SDLVideo#SDL_SetWindowFullscreen` | missing class | 4 |
| `org.lwjgl.sdl.SDL_Event#type` | missing class | 4 |
| `org.lwjgl.sdl.SDLKeyboard#SDL_GetModState` | missing class | 3 |
| `org.lwjgl.sdl.SDL_DisplayEvent#displayID` | missing class | 3 |
| `org.lwjgl.sdl.SDL_Event#display` | missing class | 3 |
| `org.lwjgl.sdl.SDL_Event#window` | missing class | 3 |
| `org.lwjgl.sdl.SDL_MouseWheelEvent#x` | missing class | 3 |
| `org.lwjgl.sdl.SDL_Rect#malloc` | missing class | 3 |
| `org.lwjgl.sdl.SDL_WindowEvent#data1` | missing class | 3 |
| ...and 117 more | | 139 |
### Socket addresses, proxies and HTTP: server addresses become WebSocket URLs, HTTP becomes fetch
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.net.SocketException` | JDK class TeaVM lacks | 22 |
| `java.net.InetSocketAddress` | JDK class TeaVM lacks | 17 |
| `java.net.InetAddress` | JDK class TeaVM lacks | 8 |
| `java.net.InetSocketAddress#getAddress` | JDK class TeaVM lacks | 7 |
| `java.net.SocketAddress` | JDK class TeaVM lacks | 7 |
| `java.net.InetAddress#getHostAddress` | JDK class TeaVM lacks | 6 |
| `java.net.InetSocketAddress#<init>` | JDK class TeaVM lacks | 6 |
| `java.net.InetSocketAddress#getPort` | JDK class TeaVM lacks | 6 |
| `java.net.NetworkInterface` | JDK class TeaVM lacks | 6 |
| `java.net.ConnectException` | JDK class TeaVM lacks | 5 |
| `java.net.InetAddress#getByName` | JDK class TeaVM lacks | 5 |
| `java.net.UnknownHostException` | JDK class TeaVM lacks | 5 |
| ...and 70 more | | 98 |
### VarHandle and MethodHandle (Netty, Guava atomics): the libraries probe for them and fall back when they throw; patch any game caller
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.lang.invoke.MethodHandle#invokeExact` | missing method | 22 |
| `java.lang.invoke.VarHandle#get` | JDK class TeaVM lacks | 14 |
| `java.lang.invoke.VarHandle#set` | JDK class TeaVM lacks | 13 |
| `java.lang.invoke.MethodType#methodType` | missing method | 10 |
| `java.lang.invoke.MethodHandles#lookup` | missing method | 8 |
| `java.lang.invoke.MethodHandle#invoke` | missing method | 4 |
| `java.lang.invoke.MethodHandles$Lookup#findStatic` | missing method | 4 |
| `java.lang.invoke.VarHandle#compareAndSet` | JDK class TeaVM lacks | 4 |
| `java.lang.invoke.VarHandle` | JDK class TeaVM lacks | 3 |
| `java.lang.invoke.VarHandle#setRelease` | JDK class TeaVM lacks | 3 |
| `java.lang.invoke.MethodHandles$Lookup#findVirtual` | missing method | 2 |
| `java.lang.invoke.VarHandle#getAndAdd` | JDK class TeaVM lacks | 2 |
| ...and 9 more | | 11 |
### Netty's NIO transport (selectors, socket channels): in the browser, connections are WebSockets on local event loops
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.nio.channels.SelectionKey` | JDK class TeaVM lacks | 8 |
| `java.nio.channels.Selector#selectNow` | JDK class TeaVM lacks | 6 |
| `java.nio.channels.SelectionKey#interestOps` | JDK class TeaVM lacks | 5 |
| `java.nio.channels.CancelledKeyException` | JDK class TeaVM lacks | 4 |
| `java.nio.channels.Selector#wakeup` | JDK class TeaVM lacks | 4 |
| `java.nio.channels.SocketChannel#socket` | JDK class TeaVM lacks | 4 |
| `java.nio.channels.SelectionKey#attachment` | JDK class TeaVM lacks | 3 |
| `java.nio.channels.Selector#close` | JDK class TeaVM lacks | 3 |
| `java.nio.channels.Selector#keys` | JDK class TeaVM lacks | 3 |
| `java.nio.channels.Selector#selectedKeys` | JDK class TeaVM lacks | 3 |
| `java.nio.channels.ServerSocketChannel` | JDK class TeaVM lacks | 3 |
| `java.nio.channels.spi.SelectorProvider#provider` | JDK class TeaVM lacks | 3 |
| ...and 31 more | | 42 |
### Logging backend discovery (ServiceLoader, class loading): bind the console logger directly
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.util.concurrent.locks.Lock#unlock` | JDK class TeaVM lacks | 7 |
| `java.lang.reflect.Method#invoke` | reflection | 6 |
| `java.util.concurrent.locks.Lock#lock` | JDK class TeaVM lacks | 6 |
| `java.lang.Class#forName` | reflection | 5 |
| `java.lang.ClassLoader#getResources` | missing method, reflection | 4 |
| `java.lang.ClassLoader#loadClass` | missing method, reflection | 4 |
| `java.util.ServiceLoader#load` | reflection | 4 |
| `java.util.concurrent.locks.ReentrantLock` | JDK class TeaVM lacks | 4 |
| `java.util.concurrent.locks.ReentrantLock#<init>` | JDK class TeaVM lacks | 4 |
| `java.lang.ClassLoader#getSystemClassLoader` | reflection | 3 |
| `java.lang.Class#getMethod` | reflection | 2 |
| `java.lang.System#getenv` | missing method | 2 |
| ...and 28 more | | 37 |
### Shader toolchain: GLSL to SPIR-V (shaderc) and back (SPIRV-Cross) runs natively; move it to build time
| API | Kind | Call sites |
| --- | --- | ---: |
| `org.lwjgl.util.shaderc.Shaderc#shaderc_compile_options_add_macro_definition` | missing class | 5 |
| `org.lwjgl.util.spvc.SpvcReflectedResource#id` | missing class | 5 |
| `org.lwjgl.util.spvc.Spvc#spvc_compiler_get_binary_offset_for_decoration` | missing class | 4 |
| `org.lwjgl.util.spvc.Spvc#spvc_compiler_get_type_handle` | missing class | 3 |
| `org.lwjgl.util.spvc.Spvc#spvc_resources_get_resource_list_for_type` | missing class | 3 |
| `org.lwjgl.util.spvc.SpvcReflectedResource` | missing class | 3 |
| `org.lwjgl.util.spvc.SpvcReflectedResource#create` | missing class | 3 |
| `org.lwjgl.util.spvc.SpvcReflectedResource#nameString` | missing class | 3 |
| `org.lwjgl.util.spvc.SpvcReflectedResource#type_id` | missing class | 3 |
| `org.lwjgl.util.spvc.SpvcReflectedResource$Buffer#get` | missing class | 3 |
| `org.lwjgl.util.shaderc.ShadercIncludeResolve#close` | missing class | 2 |
| `org.lwjgl.util.shaderc.ShadercIncludeResult#address` | missing class | 2 |
| ...and 34 more | | 37 |
### Gson reflective type adapters: register explicit adapters, or keep Gson on JsonElement trees
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.lang.reflect.Method#invoke` | reflection | 11 |
| `java.lang.reflect.Field#getName` | reflection | 10 |
| `java.lang.reflect.Field#getAnnotation` | reflection | 7 |
| `java.lang.Class#getMethod` | reflection | 6 |
| `java.lang.Class#forName` | reflection | 4 |
| `java.lang.Class#getDeclaredMethod` | reflection | 4 |
| `java.lang.Class#getGenericSuperclass` | reflection | 4 |
| `java.lang.Class#getDeclaredConstructor` | reflection | 3 |
| `java.lang.reflect.Constructor#newInstance` | reflection | 3 |
| `java.lang.reflect.Field#get` | reflection | 3 |
| `java.lang.reflect.Field#getModifiers` | reflection | 3 |
| `java.lang.Class#getAnnotation` | reflection | 2 |
| ...and 12 more | | 14 |
### Audio (OpenAL): Web Audio
| API | Kind | Call sites |
| --- | --- | ---: |
| `org.lwjgl.openal.AL10#alSourcef` | missing class | 5 |
| `org.lwjgl.openal.AL10#alSourcei` | missing class | 5 |
| `org.lwjgl.openal.ALC10#alcGetString` | missing class | 3 |
| `org.lwjgl.openal.ALC10#alcIsExtensionPresent` | missing class | 3 |
| `javax.sound.sampled.AudioFormat#getChannels` | JDK class TeaVM lacks | 2 |
| `javax.sound.sampled.AudioFormat#getSampleRate` | JDK class TeaVM lacks | 2 |
| `javax.sound.sampled.AudioFormat#getSampleSizeInBits` | JDK class TeaVM lacks | 2 |
| `org.lwjgl.openal.AL10#alDeleteBuffers` | missing class | 2 |
| `org.lwjgl.openal.AL10#alGetSourcei` | missing class | 2 |
| `org.lwjgl.openal.AL10#alSourcePlay` | missing class | 2 |
| `org.lwjgl.openal.AL10#alSourceStop` | missing class | 2 |
| `org.lwjgl.openal.ALC10#alcGetError` | missing class | 2 |
| ...and 37 more | | 38 |
### Netty channels and pipeline: WebSocket transport under Connection
| API | Kind | Call sites |
| --- | --- | ---: |
| `io.netty.util.concurrent.MpscIntQueue$MpscAtomicIntegerArrayQueue#get` | missing method | 4 |
| `io.netty.util.concurrent.MpscIntQueue$MpscAtomicIntegerArrayQueue#lazySet` | missing method | 4 |
| `io.netty.util.concurrent.Future#isCancelled` | missing method | 3 |
| `io.netty.buffer.AllocateBufferEvent#commit` | missing method | 2 |
| `io.netty.buffer.AllocateBufferEvent#shouldCommit` | missing method | 2 |
| `io.netty.channel.ChannelFuture#isDone` | missing method | 2 |
| `io.netty.util.concurrent.MpscIntQueue$MpscAtomicIntegerArrayQueue#length` | missing method | 2 |
| `io.netty.buffer.AllocateBufferEvent#isEnabled` | missing method | 1 |
| `io.netty.buffer.AllocateChunkEvent#commit` | missing method | 1 |
| `io.netty.buffer.AllocateChunkEvent#isEnabled` | missing method | 1 |
| `io.netty.buffer.AllocateChunkEvent#shouldCommit` | missing method | 1 |
| `io.netty.buffer.FreeBufferEvent#commit` | missing method | 1 |
| ...and 19 more | | 19 |
### TrueType fonts (FreeType): pre-baked glyph atlases, Canvas2D for pack fonts
| API | Kind | Call sites |
| --- | --- | ---: |
| `org.lwjgl.util.freetype.FT_Bitmap#rows` | missing class | 4 |
| `org.lwjgl.util.freetype.FT_Bitmap#width` | missing class | 4 |
| `org.lwjgl.util.freetype.FT_Face#glyph` | missing class | 2 |
| `org.lwjgl.util.freetype.FT_GlyphSlot#bitmap` | missing class | 2 |
| `org.lwjgl.util.freetype.FreeType#FT_Done_Face` | missing class | 2 |
| `org.lwjgl.util.freetype.FreeType#FT_Load_Glyph` | missing class | 2 |
| `org.lwjgl.util.freetype.FT_Bitmap#buffer` | missing class | 1 |
| `org.lwjgl.util.freetype.FT_Bitmap#pixel_mode` | missing class | 1 |
| `org.lwjgl.util.freetype.FT_Face#create` | missing class | 1 |
| `org.lwjgl.util.freetype.FT_GlyphSlot` | missing class | 1 |
| `org.lwjgl.util.freetype.FT_GlyphSlot#advance` | missing class | 1 |
| `org.lwjgl.util.freetype.FT_GlyphSlot#bitmap_left` | missing class | 1 |
| ...and 16 more | | 16 |
### Game code using reflection: replace with direct references
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.lang.Class#forName` | reflection | 4 |
| `java.lang.Class#getConstructor` | reflection | 1 |
| `java.lang.Class#getDeclaredField` | reflection | 1 |
| `java.lang.Class#getDeclaredMethod` | reflection | 1 |
| `java.lang.ClassLoader#getResources` | reflection | 1 |
| `java.lang.invoke.MethodHandles#lookup` | reflection | 1 |
| `java.lang.invoke.MethodHandles$Lookup#unreflect` | reflection | 1 |
| `java.lang.reflect.Constructor#newInstance` | reflection | 1 |
| `java.lang.reflect.Field#get` | reflection | 1 |
| `java.lang.reflect.Field#setAccessible` | reflection | 1 |
| `java.util.ServiceLoader#load` | reflection | 1 |
### Image decode and encode (STB): createImageBitmap or a pure-Java codec
| API | Kind | Call sites |
| --- | --- | ---: |
| `org.lwjgl.stb.STBImage#stbi_failure_reason` | missing class | 3 |
| `com.mojang.blaze3d.platform.NativeImage$WriteCallback#address` | missing method | 1 |
| `com.mojang.blaze3d.platform.NativeImage$WriteCallback#free` | missing method | 1 |
| `com.mojang.blaze3d.platform.NativeImage$WriteCallback#getData` | missing method | 1 |
| `org.lwjgl.stb.STBIWriteCallback` | missing supertype | 1 |
| `org.lwjgl.stb.STBIWriteCallback#<init>` | missing class | 1 |
| `org.lwjgl.stb.STBImage#nstbi_image_free` | missing class | 1 |
| `org.lwjgl.stb.STBImage#stbi_load_from_memory` | missing class | 1 |
| `org.lwjgl.stb.STBImageResize#nstbir_resize_uint8_linear` | missing class | 1 |
| `org.lwjgl.stb.STBImageWrite#nstbi_write_png_to_func` | missing class | 1 |
### Netty's own thread class (a ThreadGroup constructor TeaVM lacks): event loops get their threads from the game's factory
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.lang.Thread#<init>` | missing method | 1 |
## Delete
The feature is stripped from the browser build. 18 work items, 1145 APIs, 2227 call sites.
| Work item | APIs | Call sites | Where the calls are |
| --- | ---: | ---: | --- |
| Vulkan backend (the browser gets WebGL2, later WebGPU) | 710 | 1336 | `com.mojang.renderpearl.backend.vulkan` (1268), `com.mojang.renderpearl.backend.vulkan.init` (45), `com.mojang.renderpearl.backend.vulkan.checkpoints` (19), `com.mojang.blaze3d.platform` (2), +1 more |
| Java Flight Recorder profiling | 85 | 189 | `net.minecraft.util.profiling.jfr` (69), `net.minecraft.util.profiling.jfr.stats` (44), `net.minecraft.util.profiling.jfr.parse` (32), `net.minecraft.util.profiling.jfr.event` (28), +3 more |
| Realms (Mojang's hosting service and its HTTP client) | 84 | 185 | `com.mojang.realmsclient.client` (69), `com.mojang.realmsclient.gui.screens.configuration` (39), `com.mojang.realmsclient.gui.screens` (24), `com.mojang.realmsclient.client.worldupload` (10), +6 more |
| Tracy profiler hooks | 29 | 101 | `com.mojang.renderpearl.backend.opengl` (17), `com.mojang.renderpearl.frontend.shaders` (16), `net.minecraft` (11), `net.minecraft.util.profiling` (10), +11 more |
| Library support for optional runtimes (OSGi, Log4j 1, java.sql) | 25 | 95 | `netty-common` (70), `gson` (18), `log4j-api` (7) |
| Encryption and signing (Mojang auth, chat signing, key pairs); offline and Eagler modes don't use them | 55 | 84 | `net.minecraft.util` (43), `authlib` (12), `guava` (12), `net.minecraft.network` (4), +6 more |
| OSHI hardware info (crash reports, telemetry) | 32 | 47 | `net.minecraft` (31), `net.minecraft.util.profiling.metrics.profiling` (9), `net.minecraft.client.gui.components.debug` (7) |
| Native library loading and LWJGL setup | 21 | 39 | `com.mojang.blaze3d.platform` (36), `com.mojang.renderpearl.backend.opengl` (2), `com.mojang.blaze3d.systems` (1) |
| JNA Windows process inspection (crash reports) | 24 | 33 | `net.minecraft.util` (33) |
| LAN world discovery and hosting (UDP multicast, server sockets) | 22 | 31 | `net.minecraft.client.server` (19), `net.minecraft.util` (10), `netty-common` (1), `netty-transport` (1) |
| Debug tool that mirrors a player between servers | 18 | 25 | `net.minecraft.server.chase` (25) |
| JMX server monitoring (MBeans) | 17 | 20 | `net.minecraft.util.monitoring.jmx` (20) |
| Microsoft account services (login, server chat filter) | 12 | 13 | `net.minecraft.server.network` (13) |
| macOS window integration | 6 | 9 | `com.mojang.blaze3d.platform` (9) |
| Native socket transports (epoll, kqueue) | 8 | 8 | `net.minecraft.server.network` (8) |
| DNS SRV lookup of server addresses (JNDI) | 5 | 5 | `net.minecraft.client.multiplayer.resolver` (5) |
| Operating system queries in Netty (somaxconn through sysctl): a page runs no processes | 5 | 5 | `netty-common` (5) |
| Dedicated server code the client reaches (watchdog, properties) | 2 | 2 | `net.minecraft.server.dedicated` (2) |
### Vulkan backend (the browser gets WebGL2, later WebGPU)
| API | Kind | Call sites |
| --- | --- | ---: |
| `org.lwjgl.system.MemoryStack#close` | missing class | 138 |
| `org.lwjgl.system.MemoryStack#stackPush` | missing class | 63 |
| `org.lwjgl.system.MemoryStack#callocLong` | missing class | 22 |
| `org.lwjgl.PointerBuffer#get` | missing class | 13 |
| `org.lwjgl.system.MemoryStack#callocPointer` | missing class | 13 |
| `org.lwjgl.system.MemoryStack#callocInt` | missing class | 11 |
| `org.lwjgl.vulkan.VkDevice#getPhysicalDevice` | missing class | 10 |
| `org.lwjgl.PointerBuffer#limit` | missing class | 7 |
| `org.lwjgl.system.MemoryStack#UTF8` | missing class | 7 |
| `org.lwjgl.system.MemoryStack#longs` | missing class | 7 |
| `org.lwjgl.vulkan.VkPhysicalDeviceProperties2#properties` | missing class | 7 |
| `org.lwjgl.vulkan.VkQueueFamilyProperties#queueFlags` | missing class | 7 |
| ...and 698 more | | 1031 |
### Java Flight Recorder profiling
| API | Kind | Call sites |
| --- | --- | ---: |
| `jdk.jfr.EventType#isEnabled` | JDK class TeaVM lacks | 11 |
| `jdk.jfr.consumer.RecordedEvent#getString` | JDK class TeaVM lacks | 11 |
| `jdk.jfr.EventType#getEventType` | JDK class TeaVM lacks | 10 |
| `jdk.jfr.consumer.RecordedEvent#getInt` | JDK class TeaVM lacks | 10 |
| `java.time.Duration#toNanos` | JDK class TeaVM lacks | 9 |
| `jdk.jfr.Event` | JDK class TeaVM lacks | 9 |
| `jdk.jfr.Event#<init>` | JDK class TeaVM lacks | 9 |
| `java.time.Duration#getSeconds` | JDK class TeaVM lacks | 6 |
| `jdk.jfr.consumer.RecordedEvent#getDuration` | JDK class TeaVM lacks | 6 |
| `jdk.jfr.consumer.RecordedEvent#getStartTime` | JDK class TeaVM lacks | 5 |
| `java.time.Duration#toMillis` | JDK class TeaVM lacks | 4 |
| `java.time.Instant#EPOCH` | JDK class TeaVM lacks | 4 |
| ...and 73 more | | 95 |
### Realms (Mojang's hosting service and its HTTP client)
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.util.concurrent.CompletableFuture#thenAcceptAsync` | JDK class TeaVM lacks | 14 |
| `java.util.concurrent.CompletableFuture#supplyAsync` | JDK class TeaVM lacks | 9 |
| `java.time.Duration#ofSeconds` | JDK class TeaVM lacks | 7 |
| `java.time.Duration#ofMinutes` | JDK class TeaVM lacks | 6 |
| `java.util.concurrent.CompletableFuture#thenRunAsync` | JDK class TeaVM lacks | 6 |
| `java.net.http.HttpClient#close` | JDK class TeaVM lacks | 5 |
| `java.net.http.HttpResponse#headers` | JDK class TeaVM lacks | 4 |
| `java.time.format.DateTimeFormatter#format` | JDK class TeaVM lacks | 4 |
| `java.util.concurrent.CompletableFuture#cancel` | JDK class TeaVM lacks | 4 |
| `java.util.concurrent.CompletableFuture#getNow` | JDK class TeaVM lacks | 4 |
| `java.util.concurrent.CompletableFuture#join` | JDK class TeaVM lacks | 4 |
| `java.util.concurrent.CompletionException` | JDK class TeaVM lacks | 4 |
| ...and 72 more | | 114 |
### Tracy profiler hooks
| API | Kind | Call sites |
| --- | --- | ---: |
| `com.mojang.jtracy.Zone#close` | missing class | 25 |
| `com.mojang.jtracy.TracyClient#beginZone` | missing class | 13 |
| `com.mojang.jtracy.TracyClient#isAvailable` | missing class | 7 |
| `com.mojang.jtracy.Zone#addText` | missing class | 7 |
| `com.mojang.jtracy.MemoryPool#malloc` | missing class | 5 |
| `com.mojang.jtracy.Plot#setValue` | missing class | 5 |
| `com.mojang.jtracy.MemoryPool#free` | missing class | 4 |
| `com.mojang.jtracy.TracyClient#createMemoryPool` | missing class | 3 |
| `com.mojang.jtracy.TracyClient#createPlot` | missing class | 3 |
| `com.mojang.jtracy.DiscontinuousFrame#end` | missing class | 2 |
| `com.mojang.jtracy.DiscontinuousFrame#start` | missing class | 2 |
| `com.mojang.jtracy.GpuContext#submitQueryTimestamp` | missing class | 2 |
| ...and 17 more | | 23 |
### Library support for optional runtimes (OSGi, Log4j 1, java.sql)
| API | Kind | Call sites |
| --- | --- | ---: |
| `org.apache.log4j.Logger#log` | missing class | 20 |
| `org.apache.log4j.Level#ERROR` | missing class | 9 |
| `org.apache.log4j.Level#WARN` | missing class | 9 |
| `org.apache.log4j.Level#DEBUG` | missing class | 8 |
| `org.apache.log4j.Logger#isEnabledFor` | missing class | 8 |
| `java.sql.Date` | JDK class TeaVM lacks | 5 |
| `java.sql.Timestamp` | JDK class TeaVM lacks | 5 |
| `org.apache.log4j.Logger#isDebugEnabled` | missing class | 5 |
| `java.sql.Time` | JDK class TeaVM lacks | 3 |
| `org.apache.log4j.Level#TRACE` | missing class | 3 |
| `java.sql.Date#<init>` | JDK class TeaVM lacks | 2 |
| `java.sql.Timestamp#<init>` | JDK class TeaVM lacks | 2 |
| ...and 13 more | | 16 |
### Encryption and signing (Mojang auth, chat signing, key pairs); offline and Eagler modes don't use them
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.security.MessageDigest#update` | JDK class TeaVM lacks | 4 |
| `java.security.PublicKey#getEncoded` | JDK class TeaVM lacks | 4 |
| `java.security.KeyFactory#getInstance` | JDK class TeaVM lacks | 3 |
| `java.security.MessageDigest#digest` | JDK class TeaVM lacks | 3 |
| `java.security.Signature#getInstance` | JDK class TeaVM lacks | 3 |
| `java.security.AccessController#checkPermission` | missing method | 2 |
| `java.security.KeyFactory#generatePublic` | JDK class TeaVM lacks | 2 |
| `java.security.KeyPair#getPublic` | JDK class TeaVM lacks | 2 |
| `java.security.MessageDigest#clone` | JDK class TeaVM lacks | 2 |
| `java.security.MessageDigest#getDigestLength` | JDK class TeaVM lacks | 2 |
| `java.security.MessageDigest#getInstance` | JDK class TeaVM lacks | 2 |
| `java.security.PublicKey#getAlgorithm` | JDK class TeaVM lacks | 2 |
| ...and 43 more | | 53 |
### OSHI hardware info (crash reports, telemetry)
| API | Kind | Call sites |
| --- | --- | ---: |
| `oshi.SystemInfo` | missing class | 4 |
| `oshi.SystemInfo#<init>` | missing class | 4 |
| `oshi.SystemInfo#getHardware` | missing class | 3 |
| `oshi.hardware.CentralProcessor#getLogicalProcessorCount` | missing class | 3 |
| `oshi.hardware.HardwareAbstractionLayer#getProcessor` | missing class | 3 |
| `oshi.hardware.CentralProcessor#getProcessorCpuLoadBetweenTicks` | missing class | 2 |
| `oshi.hardware.CentralProcessor#getProcessorCpuLoadTicks` | missing class | 2 |
| `oshi.hardware.CentralProcessor#getProcessorIdentifier` | missing class | 2 |
| `oshi.SystemInfo#getOperatingSystem` | missing class | 1 |
| `oshi.hardware.CentralProcessor#getPhysicalPackageCount` | missing class | 1 |
| `oshi.hardware.CentralProcessor#getPhysicalProcessorCount` | missing class | 1 |
| `oshi.hardware.CentralProcessor$ProcessorIdentifier#getName` | missing class | 1 |
| ...and 20 more | | 20 |
### Native library loading and LWJGL setup
| API | Kind | Call sites |
| --- | --- | ---: |
| `org.lwjgl.system.Configuration#get` | missing class | 7 |
| `org.lwjgl.system.Configuration#set` | missing class | 5 |
| `org.lwjgl.system.Configuration#DEBUG_LOADER` | missing class | 3 |
| `org.lwjgl.system.Configuration#SHARED_LIBRARY_EXTRACT_PATH` | missing class | 3 |
| `org.lwjgl.Version#getVersion` | missing class | 2 |
| `org.lwjgl.system.Configuration#DEBUG_STREAM` | missing class | 2 |
| `org.lwjgl.system.Configuration#VULKAN_EXPLICIT_INIT` | missing class | 2 |
| `org.lwjgl.system.Platform#getArchitecture` | missing class | 2 |
| `java.lang.UnsatisfiedLinkError` | JDK class TeaVM lacks | 1 |
| `java.lang.UnsatisfiedLinkError#<init>` | JDK class TeaVM lacks | 1 |
| `org.lwjgl.system.Configuration#DEBUG` | missing class | 1 |
| `org.lwjgl.system.Configuration#LIBRARY_PATH` | missing class | 1 |
| ...and 9 more | | 9 |
### JNA Windows process inspection (crash reports)
| API | Kind | Call sites |
| --- | --- | ---: |
| `com.sun.jna.platform.win32.Version#INSTANCE` | missing class | 3 |
| `com.sun.jna.Native#getLastError` | missing class | 2 |
| `com.sun.jna.Platform#isWindows` | missing class | 2 |
| `com.sun.jna.platform.win32.Win32Exception` | missing class | 2 |
| `com.sun.jna.platform.win32.Win32Exception#<init>` | missing class | 2 |
| `com.sun.jna.ptr.IntByReference` | missing class | 2 |
| `com.sun.jna.ptr.IntByReference#<init>` | missing class | 2 |
| `com.sun.jna.ptr.IntByReference#getValue` | missing class | 2 |
| `com.sun.jna.Memory` | missing class | 1 |
| `com.sun.jna.Memory#<init>` | missing class | 1 |
| `com.sun.jna.Pointer#getByteArray` | missing class | 1 |
| `com.sun.jna.Pointer#getIntArray` | missing class | 1 |
| ...and 12 more | | 12 |
### LAN world discovery and hosting (UDP multicast, server sockets)
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.net.ServerSocket#close` | JDK class TeaVM lacks | 4 |
| `java.net.DatagramPacket` | JDK class TeaVM lacks | 2 |
| `java.net.DatagramPacket#<init>` | JDK class TeaVM lacks | 2 |
| `java.net.DatagramPacket#getAddress` | JDK class TeaVM lacks | 2 |
| `java.net.ServerSocket` | JDK class TeaVM lacks | 2 |
| `java.net.ServerSocket#<init>` | JDK class TeaVM lacks | 2 |
| `java.net.ServerSocket#getLocalPort` | JDK class TeaVM lacks | 2 |
| `java.net.DatagramPacket#getData` | JDK class TeaVM lacks | 1 |
| `java.net.DatagramPacket#getLength` | JDK class TeaVM lacks | 1 |
| `java.net.DatagramPacket#getOffset` | JDK class TeaVM lacks | 1 |
| `java.net.DatagramSocket` | JDK class TeaVM lacks | 1 |
| `java.net.DatagramSocket#<init>` | JDK class TeaVM lacks | 1 |
| ...and 10 more | | 10 |
### Debug tool that mirrors a player between servers
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.util.Scanner#nextFloat` | JDK class TeaVM lacks | 5 |
| `java.net.Socket` | JDK class TeaVM lacks | 2 |
| `java.util.Scanner#close` | JDK class TeaVM lacks | 2 |
| `java.util.Scanner#next` | JDK class TeaVM lacks | 2 |
| `java.net.InetAddress#getByName` | JDK class TeaVM lacks | 1 |
| `java.net.ServerSocket` | JDK class TeaVM lacks | 1 |
| `java.net.ServerSocket#<init>` | JDK class TeaVM lacks | 1 |
| `java.net.ServerSocket#accept` | JDK class TeaVM lacks | 1 |
| `java.net.ServerSocket#isClosed` | JDK class TeaVM lacks | 1 |
| `java.net.Socket#<init>` | JDK class TeaVM lacks | 1 |
| `java.net.Socket#getInputStream` | JDK class TeaVM lacks | 1 |
| `java.net.Socket#getOutputStream` | JDK class TeaVM lacks | 1 |
| ...and 6 more | | 6 |
### JMX server monitoring (MBeans)
| API | Kind | Call sites |
| --- | --- | ---: |
| `javax.management.AttributeList` | JDK class TeaVM lacks | 2 |
| `javax.management.AttributeList#<init>` | JDK class TeaVM lacks | 2 |
| `javax.management.MBeanAttributeInfo` | JDK class TeaVM lacks | 2 |
| `javax.management.Attribute` | JDK class TeaVM lacks | 1 |
| `javax.management.Attribute#<init>` | JDK class TeaVM lacks | 1 |
| `javax.management.DynamicMBean` | JDK class TeaVM lacks | 1 |
| `javax.management.InstanceAlreadyExistsException` | JDK class TeaVM lacks | 1 |
| `javax.management.MBeanAttributeInfo#<init>` | JDK class TeaVM lacks | 1 |
| `javax.management.MBeanInfo` | JDK class TeaVM lacks | 1 |
| `javax.management.MBeanInfo#<init>` | JDK class TeaVM lacks | 1 |
| `javax.management.MBeanNotificationInfo` | JDK class TeaVM lacks | 1 |
| `javax.management.MBeanRegistrationException` | JDK class TeaVM lacks | 1 |
| ...and 5 more | | 5 |
### Microsoft account services (login, server chat filter)
| API | Kind | Call sites |
| --- | --- | ---: |
| `com.microsoft.aad.msal4j.ConfidentialClientApplication$Builder` | missing class | 2 |
| `com.microsoft.aad.msal4j.ClientCredentialFactory#createFromCertificate` | missing class | 1 |
| `com.microsoft.aad.msal4j.ClientCredentialParameters#builder` | missing class | 1 |
| `com.microsoft.aad.msal4j.ClientCredentialParameters$ClientCredentialParametersBuilder#build` | missing class | 1 |
| `com.microsoft.aad.msal4j.ConfidentialClientApplication#acquireToken` | missing class | 1 |
| `com.microsoft.aad.msal4j.ConfidentialClientApplication#builder` | missing class | 1 |
| `com.microsoft.aad.msal4j.ConfidentialClientApplication$Builder#authority` | missing class | 1 |
| `com.microsoft.aad.msal4j.ConfidentialClientApplication$Builder#build` | missing class | 1 |
| `com.microsoft.aad.msal4j.ConfidentialClientApplication$Builder#executorService` | missing class | 1 |
| `com.microsoft.aad.msal4j.ConfidentialClientApplication$Builder#sendX5c` | missing class | 1 |
| `com.microsoft.aad.msal4j.IAuthenticationResult` | missing class | 1 |
| `com.microsoft.aad.msal4j.IAuthenticationResult#accessToken` | missing class | 1 |
### macOS window integration
| API | Kind | Call sites |
| --- | --- | ---: |
| `ca.weblite.objc.Proxy#send` | missing class | 3 |
| `ca.weblite.objc.Proxy#sendProxy` | missing class | 2 |
| `ca.weblite.objc.Client#getInstance` | missing class | 1 |
| `ca.weblite.objc.Client#sendProxy` | missing class | 1 |
| `ca.weblite.objc.Proxy#sendInt` | missing class | 1 |
| `ca.weblite.objc.Proxy#sendRaw` | missing class | 1 |
### Native socket transports (epoll, kqueue)
| API | Kind | Call sites |
| --- | --- | ---: |
| `io.netty.channel.epoll.Epoll#isAvailable` | missing class | 1 |
| `io.netty.channel.epoll.EpollIoHandler#newFactory` | missing class | 1 |
| `io.netty.channel.epoll.EpollServerSocketChannel` | missing class | 1 |
| `io.netty.channel.epoll.EpollSocketChannel` | missing class | 1 |
| `io.netty.channel.kqueue.KQueue#isAvailable` | missing class | 1 |
| `io.netty.channel.kqueue.KQueueIoHandler#newFactory` | missing class | 1 |
| `io.netty.channel.kqueue.KQueueServerSocketChannel` | missing class | 1 |
| `io.netty.channel.kqueue.KQueueSocketChannel` | missing class | 1 |
### DNS SRV lookup of server addresses (JNDI)
| API | Kind | Call sites |
| --- | --- | ---: |
| `javax.naming.directory.Attribute#get` | JDK class TeaVM lacks | 1 |
| `javax.naming.directory.Attributes#get` | JDK class TeaVM lacks | 1 |
| `javax.naming.directory.DirContext#getAttributes` | JDK class TeaVM lacks | 1 |
| `javax.naming.directory.InitialDirContext` | JDK class TeaVM lacks | 1 |
| `javax.naming.directory.InitialDirContext#<init>` | JDK class TeaVM lacks | 1 |
### Operating system queries in Netty (somaxconn through sysctl): a page runs no processes
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.lang.Process#destroy` | JDK class TeaVM lacks | 1 |
| `java.lang.Process#getInputStream` | JDK class TeaVM lacks | 1 |
| `java.lang.ProcessBuilder` | JDK class TeaVM lacks | 1 |
| `java.lang.ProcessBuilder#<init>` | JDK class TeaVM lacks | 1 |
| `java.lang.ProcessBuilder#start` | JDK class TeaVM lacks | 1 |
### Dedicated server code the client reaches (watchdog, properties)
| API | Kind | Call sites |
| --- | --- | ---: |
| `java.lang.management.ThreadInfo#getStackTrace` | JDK class TeaVM lacks | 1 |
| `java.lang.management.ThreadInfo#getThreadId` | JDK class TeaVM lacks | 1 |
## Inputs
- Minecraft 26.3, entry point `net.minecraft.client.main.Main` plus every client class except the `no-root` packages
- TeaVM 0.15.0, WebAssembly GC target, run on JDK 25
- Reachable classes by origin: generated lambda classes 24,480, Minecraft 10,598, libraries 4,384, TeaVM class library 1,253, stubbed library classes 430, stubbed JDK classes 303, survey roots 71
Libraries, as decided in `tools/survey/rules.txt`. Only `keep` libraries are compiled; calls into the others show up above as missing classes at their call sites.
| Library | Decision | Why |
| --- | --- | --- |
| `at.yawk.lz4:lz4-java:1.10.1` | keep | Has a pure-Java implementation |
| `com.google.code.gson:gson:2.14.0` | keep | Guava, Gson, failureaccess: pure Java |
| `com.google.guava:failureaccess:1.0.3` | keep | Guava, Gson, failureaccess: pure Java |
| `com.google.guava:guava:33.6.0-jre` | keep | Guava, Gson, failureaccess: pure Java |
| `com.mojang:authlib:10.0.77` | keep | GameProfile and properties are used everywhere; its HTTP parts get cut |
| `com.mojang:blocklist:1.0.10` | keep | Brigadier, DataFixerUpper codecs, logging, blocklist, patchy |
| `com.mojang:brigadier:1.3.11` | keep | Brigadier, DataFixerUpper codecs, logging, blocklist, patchy |
| `com.mojang:datafixerupper:10.0.21` | keep | Brigadier, DataFixerUpper codecs, logging, blocklist, patchy |
| `com.mojang:logging:1.7.12` | keep | Brigadier, DataFixerUpper codecs, logging, blocklist, patchy |
| `com.mojang:patchy:2.2.10` | keep | Brigadier, DataFixerUpper codecs, logging, blocklist, patchy |
| `commons-codec:commons-codec:1.22.0` | keep | Pure Java |
| `commons-io:commons-io:2.20.0` | keep | Pure Java |
| `io.netty:netty-buffer:4.2.16.Final` | keep | FriendlyByteBuf extends ByteBuf; pure Java in heap mode |
| `io.netty:netty-codec-base:4.2.16.Final` | keep | The game's packet codecs extend its encoders and decoders |
| `io.netty:netty-common:4.2.16.Final` | keep | Needed by netty-buffer |
| `io.netty:netty-handler:4.2.16.Final` | keep | The read timeout and flow control in the game's pipeline |
| `io.netty:netty-resolver:4.2.16.Final` | keep | Bootstrap's address resolution; WebSocket addresses need none |
| `io.netty:netty-transport:4.2.16.Final` | keep | The game's Connection is a Netty pipeline; it runs over the WebSocket transport (ADR 0008) |
| `it.unimi.dsi:fastutil:8.5.18` | keep | Pure Java collections |
| `net.sf.jopt-simple:jopt-simple:5.0.4` | keep | Command-line parsing for Main |
| `org.apache.commons:commons-compress:1.28.0` | keep | commons-lang3, commons-compress: pure Java |
| `org.apache.commons:commons-lang3:3.20.0` | keep | commons-lang3, commons-compress: pure Java |
| `org.apache.logging.log4j:log4j-api:2.26.0` | keep | API only; backed by the console shim |
| `org.jcraft:jorbis:0.0.17` | keep | Pure-Java Ogg Vorbis decoder, useful for Web Audio |
| `org.joml:joml:1.10.9` | keep | Pure Java math |
| `org.jspecify:jspecify:1.0.0` | keep | Annotations only |
| `org.slf4j:slf4j-api:2.0.17` | keep | API only; backed by the console shim |
| `com.ibm.icu:icu4j:78.3` | replace | Bidi text; the browser has Intl, or a minimal shim |
| `com.mojang:text2speech:1.19.12` | replace | Narrator; the browser has the Web Speech API |
| `io.netty:netty-codec-compression:4.2.16.Final` | replace | Native transports, compression and HTTP codecs: the browser has none of them |
| `io.netty:netty-codec-http:4.2.16.Final` | replace | Native transports, compression and HTTP codecs: the browser has none of them |
| `io.netty:netty-transport-classes-epoll:4.2.16.Final` | replace | Native transports, compression and HTTP codecs: the browser has none of them |
| `io.netty:netty-transport-classes-kqueue:4.2.16.Final` | replace | Native transports, compression and HTTP codecs: the browser has none of them |
| `io.netty:netty-transport-native-unix-common:4.2.16.Final` | replace | Native transports, compression and HTTP codecs: the browser has none of them |
| `org.apache.logging.log4j:log4j-core:2.26.0` | replace | Console logging shim |
| `org.apache.logging.log4j:log4j-slf4j2-impl:2.26.0` | replace | Console logging shim |
| `org.lwjgl:lwjgl-freetype:3.4.3` | replace | Platform layer: WebGL2, canvas input, Web Audio, fonts |
| `org.lwjgl:lwjgl-jemalloc:3.4.3` | replace | Platform layer: WebGL2, canvas input, Web Audio, fonts |
| `org.lwjgl:lwjgl-openal:3.4.3` | replace | Platform layer: WebGL2, canvas input, Web Audio, fonts |
| `org.lwjgl:lwjgl-opengl:3.4.3` | replace | Platform layer: WebGL2, canvas input, Web Audio, fonts |
| `org.lwjgl:lwjgl-sdl:3.4.3` | replace | Platform layer: WebGL2, canvas input, Web Audio, fonts |
| `org.lwjgl:lwjgl-shaderc:3.4.3` | replace | Platform layer: WebGL2, canvas input, Web Audio, fonts |
| `org.lwjgl:lwjgl-spvc:3.4.3` | replace | Platform layer: WebGL2, canvas input, Web Audio, fonts |
| `org.lwjgl:lwjgl-stb:3.4.3` | replace | Platform layer: WebGL2, canvas input, Web Audio, fonts |
| `org.lwjgl:lwjgl-vma:3.4.3` | replace | Platform layer: WebGL2, canvas input, Web Audio, fonts |
| `org.lwjgl:lwjgl-vulkan:3.4.3` | replace | Platform layer: WebGL2, canvas input, Web Audio, fonts |
| `org.lwjgl:lwjgl:3.4.3` | replace | Platform layer: WebGL2, canvas input, Web Audio, fonts |
| `ca.weblite:java-objc-bridge:1.1` | delete | macOS-only native bridge |
| `com.azure:azure-json:1.4.0` | delete | Only used by msal4j |
| `com.github.oshi:oshi-core:6.9.0` | delete | Hardware and OS telemetry |
| `com.microsoft.azure:msal4j:1.24.1` | delete | Microsoft login; the browser build uses offline or Eagler identity |
| `com.mojang:jtracy:1.14.38` | delete | Tracy profiler (native) |
| `net.java.dev.jna:jna-platform:5.17.0` | delete | Native interop; only OSHI and OS integration use it |
| `net.java.dev.jna:jna:5.17.0` | delete | Native interop; only OSHI and OS integration use it |
## Reading this backlog
- **It's the first layer.** TeaVM stops following calls at anything it can't resolve, so stubbing these items uncovers more. Rerun the survey after each round of porting work.
- **Call sites** are distinct (API, calling class, line) triples. Findings TeaVM reported inside JDK or class-library code are charged to the nearest game or library method that calls into it.
- **JDK classes TeaVM lacks.** Left alone, TeaVM would copy them from the JDK running the compile, dragging in JDK internals that can't work in a browser. The survey hides the host JDK, so each is listed where the game uses it.
- **Whole client, not one path.** Every class in the client jar is an analysis root, except the `no-root` packages in `tools/survey/rules.txt` (data generators, dedicated server). Code only the integrated server runs is included; singleplayer is deferred, but its code ships.
- **Stubs let the analysis continue.** TeaVM stops at anything missing, so the survey compiles in rounds, stubbing what each round reports, until nothing new appears. Stubbed items are still findings.
- **Full detail** (every call site with its method and line) is in `work/survey/26.3/findings.json` after a local run. It stays out of git because it names Mojang methods.
+107
View File
@@ -0,0 +1,107 @@
# Building Incari for a web server
`./incari build` turns a set-up checkout into one folder any static web server can serve, or one
HTML file that plays from disk.
## Don't share builds
**Never share, upload, mirror or publish a build**, any part of one, or a link to a page serving one.
Every build contains Minecraft's code and files, which Mojang doesn't allow redistributing. So the
project publishes no builds anywhere, gives nobody permission to distribute one, and isn't
responsible for builds others make or pass around. A build also bundles ViaVersion and
ViaBackwards, whose GPL raises its own question when combined with Minecraft (ADR 0002).
If you put a build on a server, keep it to yourself or people you know (behind a login or on a
private network), never a public address, and take it down when done. The folder's `README.txt`
repeats this.
Incari isn't affiliated with Mojang or Microsoft. Everyone who plays needs to own Minecraft: Java Edition.
## Making the folder
Needs `./incari setup` (JDK 25, git, Node 24) and about 20 GB of free memory.
```sh
./incari build # Fast and Compatible into dist/web/ (git-ignored)
./incari build --out ~/incari-web # anywhere outside the checkout
./incari build --only fast # one compile; Safari and older browsers can't play
./incari build --no-sounds # no asset index (~460 MB less): silent, English only
```
| Build | Needs | Notes |
| --- | --- | --- |
| **Fast** (recommended) | JSPI: Chrome/Edge 137+, Firefox 153+ | Quicker, smaller download |
| **Compatible** | WebAssembly GC: Chrome 119+, Firefox 120+, Safari 18.2+ | Noticeably slower |
Where both run, the loading screen offers a choice and remembers it; `?build=fast|compatible` picks
directly.
It fetches the sounds if missing, compiles both release builds (~10 minutes each when code
changed), and copies everything into the folder. It refuses a folder git would track inside the
checkout, and only replaces a folder it wrote (marked `.incari-web-folder`). The release builds
replace the development ones in `app-web/build/`.
## What's in it
| File | What |
| --- | --- |
| `index.html`, `boot.js`, `loader.js`, `features.js`, `jspi.js`, `cache-policy.js`, `sw.js` | Loader page and service worker (ADR 0014) |
| `build.json` | Every file with size and hash |
| `incari.wasm`, `incari-fast.wasm`, `incari.wasm-runtime.js` | Compatible and Fast builds, TeaVM's loader |
| `mesher.wasm`, `mesher.wasm-runtime.js` | The terrain mesher's workers |
| `incari.pack` | Translated shaders, decoded sprites, Via's mappings |
| `client.jar` | Mojang's jar, resources only (12 MB) |
| `asset-index.json`, `assets/objects/` | Sounds, the Unicode font and languages, fetched as needed |
| `.htaccess`, `README.txt` | Apache settings; the notice and server configs |
## Defaults to check
A build talks to a few services by default. Change them in `incari.properties` (or with the Gradle
property named) before `./incari build` if they aren't what you want:
| Default | Setting | What it does |
| --- | --- | --- |
| Incari's online service, `wss://backend.incariclient.org/v1/ws` | `incari.online.url` (`-Pincari.online.url=`) | Accounts, friends, chat, cosmetics, the update notice and usage counts (ADR 0058 to 0062). Empty turns all of them off |
| Carrotcraft, a sponsored server pinned atop the server list | `incari.featured` | `name\|address` entries joined by `;`. Empty for none. The online service can replace the list |
| Eaglercraft's public relays (`relay.deev.is`, `relay.lax1dude.net`, `relay.shhnowisnottheti.me`) | Built into `WorldSharing` and `RelayScreen`; each player's list is `relays` in `incari/settings.txt` | Where shared worlds meet (ADR 0019, 0062) |
Usage counts are anonymous: a random install id, the version and the build kind, once a day. The
service keeps a keyed hash of the id for 35 days and totals by version and build. Players can turn
them off in Incari Settings, and nothing is sent when the online service is off.
## Serving it
Serve the folder as static files; every URL is relative, so a sub-path works. `README.txt` has nginx
and Caddy configs; `.htaccess` covers Apache.
- **HTTPS** or `localhost`. Over plain HTTP from another machine it still runs, but without the
service worker or OPFS (saves go to IndexedDB).
- **`.wasm` as `application/wasm`**, so it compiles while downloading.
- **Compression** for `.wasm`, `.js` and `.json`.
- **Optional:** `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy:
require-corp` let workers share memory instead of copying (a little faster).
- **An origin of its own.** Players who sign in with Microsoft keep their tokens in the page's
storage, which every page on the same origin can read. Don't serve Incari beside other people's
pages (a shared `user.github.io`, say): give it its own host or subdomain (ADR 0070).
Players join over WebSocket: EaglerXServer, or a vanilla server behind a bridge. A page on HTTPS
can only open `wss://` addresses.
## One HTML file
```sh
./incari build --html # both builds: dist/incari.html, 133 MB
./incari build --html --only fast # Fast only, smaller
./incari build --html --out ~/incari.html
```
Plays when opened from disk, no server needed (ADR 0057). Same rules: never share it; the file says
so at the top.
- **Sounds:** every sound but music, re-encoded at 22 kHz (~40 MB; needs **ffmpeg** at build time).
Without ffmpeg, only common sounds (~10 MB). `--no-sounds` drops them and the languages.
- **Storage:** IndexedDB (Chrome gives `file://` pages no OPFS), shared by every file opened from
disk and kept in the browser profile.
- **No service worker**; nothing is fetched.
- Runs in Chrome, Edge and Firefox. It also works from a web server, but the folder is better there.
+77
View File
@@ -0,0 +1,77 @@
# Threading in the browser build
In the page, Java threads take turns on one core (JSPI fibers in Fast, coroutines in Compatible).
A blocking call suspends its thread and lets others run; nothing runs in parallel. So a wait is
harmless on a background thread, but on the render thread the frame waits as long as the call
does, and forever if what it waits for can only run on the render thread.
This is the audit of every blocking call (ADR 0015 has the decisions). Each build writes the list to
`app-web/build/teavm/blocking.txt` (`tools/webbuild`'s `BlockingCalls`).
## How the render thread is kept from waiting
| Rule | How |
| --- | --- |
| **The background pool runs between frames** | `IdleTimeExecutor` queues the game's pool tasks (meshes, occlusion graph, reloads) and runs them after each frame, until shortly before the next is due |
| **A task waiting for a worker steps aside** | Another pool runner (up to 16) takes the slot, so several meshes are in workers at once (ADR 0023) |
| **Long tasks pause at the slot's end** | `PlatformThreads.pauseIfLate()` between parts; section snapshots call it per layer |
| **Slots end before the next frame** | The deadline comes from the display's measured interval |
| **Slots get at least 4 ms** | Even after a late frame, while there's work (`?poolfloor=<ms>`, ADR 0035) |
| **A waiting render thread gets the pool at once** | Slots run immediately, 4 ms at a time, until the frame ends |
| **Woken threads skip the 4 ms timer clamp** | The server worker schedules through a `MessageChannel` (`wakeups.ts`, ADR 0040) |
| **The page paces frames, not sleeps** | The frame limiter's sleep is replaced by waiting for animation frames (`Platform.limitFrameRate`) |
| **A hidden page keeps time in a worker** | Hidden, its threads wake and its frames come from a worker's timer, not the page's throttled ones (`wakeups.ts`, ADR 0072) |
| **Stalls are counted** | The frame monitor (`window.__incariFrames`) counts frames where the render thread waited; `Waits` prints the stack of any wait of 50 ms or more |
| **The gate** | `browser-checks/soak.steps`: 30 minutes over fresh terrain with no render-thread wait of 50 ms |
## On the render thread
| Call | Waits for | In the browser |
| --- | --- | --- |
| `FramerateLimiter.limitDisplayFPS` | the rest of a limited frame | **Fixed:** the platform paces frames |
| `SectionOcclusionGraph.waitAndReset` | the occlusion graph, a pool task | On level or render-distance change; the pool runs at once |
| `RegistryDataCollector.loadNewElementsAndTags` | server registries on the pool | While joining, behind the loading screen |
| `SessionSearchTrees.*` | search trees built on world load | Recipe book or creative search opened early; the pool runs at once |
| `SoundEngine.play` | the sound thread to hand out a channel | Every sound; costs a thread switch, well under a frame |
| `SoundEngineExecutor.shutDown` | the sound thread to stop | On a resource reload |
| `Minecraft.getGameProfile` and friends | profile lookups from launch | Mojang's services are out of the build, so they fail at once |
| `Main.main` (DataFixer) | rule building on the pool | At start, before the first frame |
| Resource reload steps (`AtlasManager`, `ModelManager`, `TextureManager`, `FontManager`…) | earlier reload steps | Run as later steps, when the earlier ones are done |
| `ClientPacketListener.tick`, `ClientMannequin.tick`, `CommandSuggestions` | key pair, skin, suggestions | Only after `isDone()`: never waits |
| `PipelineCache.get` | a pipeline compile | WebGL2 compiles synchronously: never waits |
| `PlayerSocialManager.isBlocked` | block list refresh | Fails at once (no Mojang services) |
| `BlockTintCache`, `SectionRenderDispatcher` locks | a lock also taken on a worker | Holders never suspend while holding; `MonitorElision` makes these fail loudly otherwise |
| `ThreadingDetector.checkAndLock` | concurrent container use | A debug guard; contention would be a game bug |
| World loading (`doWorldLoad`, `loadWorldDataBlocking`…) | the integrated server | Singleplayer only (below) |
| `Minecraft.grabPanoramixScreenshot` | a debug command | Not reachable in play |
## On background threads (fine)
| Call | Thread |
| --- | --- |
| `SectionRenderDispatcher` compile and resort (`onSpinWait`) | pool; yields so the render thread can upload |
| `SoundEngineExecutor`, `SoundLoader` | sound thread, Incari's sound loader |
| Netty event loops, timers and promises | the connection's own threads |
| Guava futures | whoever calls them |
| The integrated server (`MinecraftServer`, `ChunkMap`, `IOWorker`, …) | its own thread (below) |
| `TracingExecutor.shutdownAndAwait`, `ClientShutdownWatchdog` | shutdown only |
| `Util$9.run` | sleeps forever by design (a Windows timer fix) |
| `LanServerPinger.run` | Open to LAN |
| `WebFetch.get` (skins, player heads, server packs) | the game's download pool, the pack download queue |
**Not in the browser's paths:** Realms, Mojang's services, online skin registration, the Chase
debug feature, Netty's NIO transport, and joins of already-finished futures in DataFixerUpper and
Brigadier.
## Singleplayer
The server runs in a Web Worker with its own threads, pool and files (ADR 0039).
`?singleplayer=page` runs it on the page instead (ADR 0038), which needed two more rules:
- **The game's own wait loops end their frame.** World load and save pump events from inside a
loop; `SDLEventHandler.pumpEvents` ends the frame there, or the pool would never run.
- **A pool task that blocks gives up the pool** (`IdleTimeExecutor.beforeWait`), since world
generation joins work it queued on the same pool.
Optimize World runs and waits on its own thread. `LevelStorageSource.deleteLevel` sleeps on the
render thread only between retries of a failed delete.
+67
View File
@@ -0,0 +1,67 @@
# Updating Minecraft
How to move the tree to a new release (26.3 → 26.4). Do the steps in order on their own branch.
Each has a check that fails loudly when it's missed.
## 1. Before you start
Read the new version's JSON from Mojang's manifest, without changing anything:
| Look at | Why it matters |
| --- | --- |
| `javaVersion.majorVersion` | TeaVM 0.16 can't read Java 26 class files. A jump stops the browser build until TeaVM catches up |
| `libraries` | New libraries need a `tools/survey/rules.txt` rule; LWJGL, Guava and Gson pins must move (step 4) |
| Netty's version | The browser build links its own Netty (`gradle/libs.versions.toml`). Run the `EventLoopProbe` after any bump |
| ViaVersion and ViaBackwards | A release that knows the new protocol has to exist before servers on it can be joined |
| Horizon (`incari.properties`) | The Rust build uses the same `minecraft.version`. Its pinned commit must support the new release |
## 2. Pin the new version
Change all three lines in `incari.properties` together: `minecraft.version`, `minecraft.versionJson.sha1`
and `minecraft.client.sha1` (from Mojang's version manifest). Nothing else names the version:
code reads `IncariBuild.MINECRAFT_VERSION` or the game's `SharedConstants`, and
`tools/ci/check-version-literals.sh` fails on a `"26.3"` literal in shipped code.
## 3. Rebuild the vendor tree
```sh
./incari setup # fetch, decompile, apply: stops at the first conflicting patch
```
- **Patch conflicts:** resolve in `work/client`, `git -C work/client am --continue`, repeat. The new
tree has no old blobs, so `--3way` can't merge: expect plain conflicts.
- **Replaced classes:** `apply` warns for each class in `patches/classes.txt` whose Mojang original
changed, and prints the `git diff --no-index` between the two decompiled versions. Bring each
replacement in line, then `./incari classes --stamp`. `./incari rebuild --check` fails until you do.
- **Gone classes:** a `classes.txt` line for a class that no longer exists stops `apply` with its name.
- **Decompile fixes** (`patches/decompile/`) are the most likely to break. They change no behaviour, so
redo them from the compile errors rather than merging old hunks.
Then `./incari rebuild` and check `tools/ci/check-patch-budget.sh`.
## 4. Build and gate
| Step | Command |
| --- | --- |
| Library pins | `tools/ci/check-mojang-pins.sh` |
| Java, tests, client compile | `./gradlew check` |
| Shaders | `./gradlew :app-web:shaders`, `tools/ci/check-glsl.sh` |
| TeaVM survey | `./incari survey` (exactly JDK 25), then diff `docs/port-backlog.md` |
| Browser build | `./gradlew :app-web:teavm`, then `:app-web:browserCheck` |
| Nothing copied | `./incari copycheck` |
| Rust build | `./incari build --only rust`, `cargo test --manifest-path rust/Cargo.toml` |
`render-webgl2` breaks first if Mojang changes the `GpuDevice` API. The mesher's parity test catches
a changed section format. Both show up in `./gradlew check`.
## 5. Things that name the version on purpose
Update these by hand; they're data or docs, not code:
- Test fixtures (`"26.3"` in `src/test/`, `tests.rs`, `*.test.ts`).
- Browser checks that join a vanilla server (`app-web/browser-checks/*.steps`, and the Faithful pack
URL in its README).
- Docs: `AGENTS.md`, `ARCHITECTURE.md`, `README.md`, `CONTRIBUTING.md`, `client/README.md`. A new
ADR if the update changed a decision.
`git grep -n '26\.3' -- ':!patches' ':!docs/adr'` lists what's left.
+117
View File
@@ -0,0 +1,117 @@
# An experimental WebGPU backend
Research from 2026-10-08. Not a decision: the spike below would end in an ADR either way.
## Status: shelved (2026-10-09)
The floor device has little for WebGPU to win. A frame already makes few draws, a WebGPU call from
Java costs about what a WebGL2 call does, and WebGL2 would have to stay in full beside it. A High
tier would serve players who already reach 60 FPS, and the client's features come first.
Revisit when both hold:
1. The reference Chromebook's `chrome://gpu` shows WebGPU on for its GPU class.
2. A floor-device profile shows a cost only WebGPU can remove (such as CPU occlusion culling), or
M4 and M5 are far enough along that a High tier is next.
If the spike runs, its gate must show a win, not parity.
## In short
- **Little to win on the floor device.** After ADRs 0022, 0024 and 0030 a frame makes ~18 draws
(fly-through) to ~31 (lobby). The lobby's 15 ms of render submit on `laptop-floor` is the game
building models, text and particles, not API calls.
- **Uncertain reach.** ChromeOS has had WebGPU since Chrome 113, but which Chromebook GPUs get it is
unpublished. On Linux, Chrome enables it only on Vulkan (off by default outside an allowlist).
- **Real wins elsewhere:** compute shaders, storage and indirect buffers, native base vertex and
instance, timestamp queries. These open GPU culling and a High tier on stronger hardware.
- **Moderate cost:** renderpearl's Vulkan backend (~5,100 lines) maps almost one to one onto
WebGPU, and the build already produces SPIR-V.
- **Java calls are cheap enough:** ~0.17 µs per call on `laptop-floor`, so the backend can stay in
Java with no JavaScript replay layer.
## How renderpearl maps onto WebGPU
A WebGPU backend would be a third implementation of the backend interfaces under the game's
validating `FrontendGpuDevice`, modelled on the Vulkan backend.
| renderpearl call | WebGPU | Gap |
| --- | --- | --- |
| Buffers and mapped writes | `createBuffer`, `queue.writeBuffer` | No persistent mapping on the main thread; keep the copy in linear memory, as WebGL2 does |
| Textures, views, samplers | `createTexture`, `createView`, `createSampler` | ~1:1 |
| `compilePipeline` | `createRenderPipelineAsync` | State is baked in, as in Vulkan |
| Render passes | `beginRenderPass` | Same shape |
| `setUniform` (Vulkan push descriptors) | Bind groups, cached by contents | No push descriptors; uncached changes allocate |
| `pushConstants` | `setImmediates` (Chrome 149+) | Fallback: a uniform ring with dynamic offsets |
| Base vertex/instance draws | Native | WebGL2's rebasing goes away |
| `multiDrawIndexed` | A loop of `drawIndexed`, or render bundles | Multi-draw indirect is experimental only |
| Timestamps | `timestamp-query` | — |
**Shaders** are the cheap part: add SPIR-V → WGSL (Tint or Naga) beside `shaders.json`. Care is
needed for combined samplers (split in WGSL), texel buffers (become storage buffers),
dynamically indexed outputs (ADR 0012's rewrite carries over), `gl_DrawID` (use `instance_index`),
and the GLSL shader rewrites (move them before SPIR-V so both backends share them).
## Measured (2026-10-09)
**Reach.** On Linux, no flags gives no adapter; `--enable-features=Vulkan` gives a real one on both
the RX 9060 XT and the UHD 620 (Gen9.5). The UHD 620 has `timestamp-query`,
`indirect-first-instance`, immediates and `shader-f16`, but not multi-draw indirect. Headless
Chromium also needs `--enable-unsafe-webgpu` (`-Pbrowser.gpu=webgpu` sets both).
**Call cost** (`app-web/probes/WebGpuCallProbe`: 2000 draws a frame, µs per draw, release builds):
| Route | Desktop Compatible | Desktop Fast | `laptop-floor` Compatible | `laptop-floor` Fast |
| --- | ---: | ---: | ---: | ---: |
| JSO, a call per command | 0.14 | 0.23 | 0.49 | 0.58 |
| One JavaScript loop | 0.06 | 0.07 | 0.16 | 0.16 |
| Replay from linear memory | 0.08 | 0.09 | 0.19 | 0.21 |
| Render bundle | 0.01 | 0.01 | 0.03 | 0.03 |
| WebGL2 via JSO | 0.13 | 0.22 | 0.33 | 0.52 |
- A JSO crossing costs ~0.17 µs. At our draw counts that's tens of µs a frame.
- A replay layer saves ~0.3 µs a draw: not worth a second language in the renderer.
- WebGPU calls cost about what WebGL2 calls do, so CPU wins must come from fewer calls (bundles,
storage buffers, compute).
- Render bundles replay 15–20x cheaper than encoding: the terrain path.
- Fast's JSO calls cost 1.1–1.7x more (each call out of a JSPI stack pays a toll).
`JsoIntrinsics` now passes `int`s as i31, cutting calls out by about a third.
The probe times CPU only, with a single-triangle pipeline.
## Risks
- **Reach:** the floor GPU class may get no WebGPU, so WebGL2 stays in full and renderer review doubles.
- **Bind group churn** can make WebGPU frames dearer than WebGL's.
- **Pipeline creation** stalls first use unless made ahead (219 pipelines).
- **Memory:** WebGPU adds GPU-process allocations on a 4 GB device.
- **Compatible build:** async WebGPU calls need coroutines there.
## Plan
A new module, `render-webgpu`, chosen with `?gpu=webgpu`, never the default. Each phase starts
only after the previous gate.
| Phase | Effort | Work | Gate |
| --- | --- | --- | --- |
| W0 Spike | ~2 weeks | Terrain on WebGPU in a probe page; CPU per frame vs WebGL2 on `laptop-igpu` and a Gen12 Chromebook | A clear CPU win on target GPUs |
| W1 Shaders | ~1 week | SPIR-V → WGSL; shared rewrites before SPIR-V | All 219 pipelines validate |
| W2 Backend | 4–6 weeks | `render-webgpu`, title screen then world | `screenshotDiff` SSIM ≥ 0.996 |
| W3 Parity | ~2 weeks | Cached bind groups, terrain bundles, benchmark on both | No figure worse than WebGL2 |
| W4 High tier | open | Compute culling, storage-buffer instancing, longer render distance | — |
A failed W0 ends the work with an ADR saying why.
## Open questions
- Does ChromeOS enable WebGPU on Jasper Lake (Celeron N4500, Gen11), the reference Chromebook's class?
- When does compatibility mode (GLES 3.1) reach ChromeOS?
- What do the remaining calls out (~1,500 a frame on the desktop) cost on `laptop-floor`?
- Can the shader rewrites move before SPIR-V without changing `screenshotDiff` results?
## Sources
- [WebGPU is now supported in major browsers](https://web.dev/blog/webgpu-supported-major-browsers) (web.dev, Nov 2025)
- What's new in WebGPU: [Chrome 144](https://developer.chrome.com/blog/new-in-webgpu-144), [145](https://developer.chrome.com/blog/new-in-webgpu-145), [146](https://developer.chrome.com/blog/new-in-webgpu-146), [149–150](https://developer.chrome.com/blog/new-in-webgpu-149-150)
- [web3dsurvey: multi-draw indirect on ChromeOS](https://web3dsurvey.com/webgpu/features/chromium-experimental-multi-draw-indirect/platform/Chromium%20OS)
- [Tint's SPIR-V reader](https://dawn.googlesource.com/dawn/+/HEAD/docs/tint/spirv-reader-overview.md)