Player sync and the installer
The sync jar (clients/sync) brings a player's game folder up to date with the server's published client files before Minecraft starts, and can also run an opt-in sculkworm tunnel agent. The installer jar adds the server to the player's launcher and picks the right launch mode for that launcher.
Build#
node clients/sync/build.mjsThe build runs in eclipse-temurin:17-jdk, targets Java 8 and writes two files:
| File | What it is |
|---|---|
clients/sync/out/sculk-sync.jar |
The sync jar. Its manifest has both Main-Class and Premain-Class. |
clients/sync/out/sculk-installer.jar |
The installer. It holds sculk-sync.jar and sculk-installer.json at its root. The server adds server-icon.png next to them when it serves the download. |
clients/sync/build.sh does the work, and the Dockerfile runs the same script. The image ships both jars in /app/clients/sync/.
Two ways to run the sync jar#
Both read sculk.json in the instance folder and share the same rules: a 30 second budget (timeoutSeconds), the same log lines, channel tokens and swa_ agent tokens masked in the output, three-way merging of merge-flagged configs (keeping a base copy in sculk-base/), a confirmation prompt for mods uploaded by hand (sculk-accepted-mods.txt), and a failure never stops the launch (only cancelling the hand-added mods prompt exits with code 1).
| Mode | Command | Game folder | Who uses it |
|---|---|---|---|
| Pre-launch | java -jar sculk-sync.jar [instance dir] [game dir] (or INST_DIR, INST_MC_DIR) |
INST_MC_DIR, else 2nd arg, else gameDir in sculk.json, else <instance>/minecraft |
Prism, PolyMC, MultiMC (PreLaunchCommand) |
| Agent | java -javaagent:sculk-sync.jar=<instance dir> ... |
INST_MC_DIR, else gameDir in sculk.json (absolute, or relative to the instance dir), else <instance>/minecraft |
Every other launcher, through the Java arguments |
| Tunnel agent | java -jar sculk-sync.jar --tunnel-agent [instance dir] (or INST_DIR) |
Not used (reads tunnel in sculk.json) |
Opt-in closed-route tunnel agent (see Tunnel agent mode) |
In agent mode the JVM runs premain before the game's main, in the same process, so the mods folder is up to date before Fabric or Forge scans it. The agent returns when the sync ends or the budget runs out (and, if sculk.json has an enabled tunnel block, starts the tunnel agent on a daemon thread). It only halts the JVM (exit code 1) if the player cancels the hand-added mods prompt; otherwise the game starts with its own exit code. After a timeout the worker stops before it writes again.
ATLauncher and the Modrinth App start Java in the game folder, so their agent argument is relative and a space in the user's folder name cannot split it:
-javaagent:sculk/sculk-sync.jar=sculkThe Minecraft Launcher gets an absolute agent argument, because nobody has checked which folder it starts Java in. It splits the Java arguments on spaces and a missing agent jar stops the JVM before the game starts, so the installer never writes a profile whose sync folder has a space in its path. It refuses and writes nothing. The player then runs it again with --sync-dir and a folder whose path has no spaces (C:\sculk, /Users/Shared/sculk, /opt/sculk). The jar and sculk.json go to <sync dir>/<slug>, and gameDir in that sculk.json is the profile's absolute game folder:
$ java -jar sculk-installer.jar --cli --launcher mojang
Installing Aileen SMP for Minecraft Launcher in C:\Users\Jane Doe\AppData\Roaming\.minecraft
The Minecraft Launcher splits Java arguments on spaces, and the sync folder C:\Users\Jane Doe\AppData\Roaming\.minecraft\sculk\aileen-smp\sculk has one. Run this installer again with a folder whose path has no spaces:
java -jar sculk-installer.jar --cli --launcher mojang --sync-dir C:\sculk
Or choose "Another launcher (manual)" and set up the profile by hand.
$ java -jar sculk-installer.jar --cli --launcher mojang --sync-dir C:\sculk
Installing Aileen SMP for Minecraft Launcher in C:\Users\Jane Doe\AppData\Roaming\.minecraft
Downloading Fabric 0.16.9 for Minecraft 1.21.1 from https://meta.fabricmc.net/v2/versions/loader/1.21.1/0.16.9/profile/json
Wrote C:\Users\Jane Doe\AppData\Roaming\.minecraft\versions\fabric-loader-0.16.9-1.21.1\fabric-loader-0.16.9-1.21.1.json
Wrote C:\sculk\aileen-smp\sculk.json
Wrote C:\sculk\aileen-smp\sculk-sync.jar
Wrote C:\Users\Jane Doe\AppData\Roaming\.minecraft\launcher_profiles.json.sculk-backup
Wrote C:\Users\Jane Doe\AppData\Roaming\.minecraft\launcher_profiles.json
Close the Minecraft Launcher if it is open, open it, choose the installation "Aileen SMP" and play.The installer window has no field for this folder. A player whose path has a space sees the same message there and runs the command line.
sculk-installer.json#
The installer reads this entry from its own jar. The server overwrites it per server when it serves the download, so its name and shape are a contract:
{
"serverName": "Aileen SMP",
"manifestUrl": "https://sculk.network/c/<token>/manifest.json",
"minecraft": "1.21.1",
"loader": { "kind": "fabric", "version": "0.16.9" },
"iconKey": "aileen"
}loader.kind is one of fabric, quilt, forge, neoforge or vanilla. version is required except for vanilla. minecraft and version are plain version names (letters, digits, ., _, +, -), because they become folder names and URL paths. iconKey is optional. The installer rejects any other kind, any missing field and any other version before it writes a file. The build puts a placeholder in the jar (clients/sync/installer.placeholder.json).
When the live modpack has a server-icon.png, the server writes the same 64x64 PNG as the Prism export into the jar as the root entry server-icon.png and sets iconKey to sculk-<server id>. Without an icon there is neither. The jar's other entries keep their bytes and order, so every download of the same commit has the same bytes.
Installer#
java -jar sculk-installer.jar # a window, or the CLI when there is no display
java -jar sculk-installer.jar --cli --list # the launchers it found
java -jar sculk-installer.jar --cli --launcher prism
java -jar sculk-installer.jar --cli --launcher manual --dir "/path/to/game folder"
java -jar sculk-installer.jar --cli --launcher mojang --sync-dir /opt/sculkThe window shows the server's icon and name, the launchers it found and a log. Download progress lines are grey, the result is green and a failure is red. When an install ends it opens a dialog with the result: a green Done with what to do next, or a red Not installed with the reason. The command line prints the same lines and exits 0 when the install is done, 1 when it failed and 2 for a usage error. It colours the result green or red only on a terminal and never when NO_COLOR is set, so a pipe or a log file gets plain text. On Windows it colours only in Windows Terminal or a terminal that sets TERM, because the classic console prints the codes as text.
--list prints one launcher per line, with the folder it found or --dir <folder> when the player picks one:
Aileen SMP: Minecraft 1.21.1, Fabric 0.16.9
prism Prism Launcher /home/ana/.local/share/PrismLauncher
mojang Minecraft Launcher /home/ana/.minecraft
modrinth Modrinth App --dir <folder>
manual Another launcher (manual) --dir <folder>Launchers.ALL in clients/sync/src/Launchers.java is the only place that knows launchers. Each entry has an id, a name, the data folders to look in on each system (%APPDATA%, ~/Library/Application Support, $XDG_DATA_HOME or ~/.local/share, and Flatpak folders), the file that proves the folder is that launcher's, and its install step. Detection only reads. Every install can run again: it rewrites the jar and the config in place, writes only the files that changed and never adds a second profile.
| Id | What the install does |
|---|---|
prism, polymc, multimc |
Writes instances/<slug>/ with the same instance.cfg, mmc-pack.json and sculk.json as the server's Prism export, and keeps the pre-launch hook. With an icon it writes <iconKey>.png into the launcher's icons folder (IconsDir in its config, icons by default) and iconKey into instance.cfg: the launcher reads a .png beside an instance only when it imports a zip. A rerun keeps the keys the launcher added to instance.cfg. The launcher downloads the loader itself. |
atlauncher |
Needs an instance with the server's name, Minecraft version and loader, which the player creates in ATLauncher. Writes sculk/ in it and adds the agent to launcher.javaArguments in instance.json, after a copy in instance.json.sculk-backup. |
mojang |
Installs the loader into versions/ when it is not there yet (see Loaders in the Minecraft Launcher). Adds the profile sculk-<slug> to launcher_profiles.json, named after the server, with its own game folder under .minecraft/sculk/<slug>, the server's icon as a data:image/png;base64, URL (Grass without one) and the launcher's default Java arguments plus the absolute agent, after a copy in launcher_profiles.json.sculk-backup. The sync folder is sculk/ inside that game folder, or <sync dir>/<slug> with --sync-dir. When its path has a space it refuses and writes nothing. |
modrinth |
Manual. Never writes the app's database. Writes sculk/ in the profile folder the player picks and prints the argument to paste in the profile's Java arguments. |
manual |
Writes sculk/ in the folder the player picks and prints the absolute agent argument, quoted when the path has a space. |
GDLauncher is not supported yet.
Loaders in the Minecraft Launcher#
The Minecraft Launcher starts a profile from versions/<id>/<id>.json. A loader's JSON names the vanilla version it builds on in inheritsFrom, and the launcher downloads that version and every library on the first Play. InstallerConfig.LoaderKind holds what differs per loader: the version id, where to download it and how.
| Loader | Version id | What the installer does |
|---|---|---|
| Fabric | fabric-loader-<loader>-<mc> |
Downloads https://meta.fabricmc.net/v2/versions/loader/<mc>/<loader>/profile/json, checks that its id is the version id and writes it. That is all Fabric's own installer writes. |
| Quilt | quilt-loader-<loader>-<mc> |
The same with https://meta.quiltmc.org/v3/versions/loader/<mc>/<loader>/profile/json. |
| NeoForge | neoforge-<loader> |
Downloads https://maven.neoforged.net/releases/net/neoforged/neoforge/<loader>/neoforge-<loader>-installer.jar, checks it against the .sha1 the Maven publishes (.sha256 or .md5 when there is no .sha1) and runs <java.home>/bin/java -jar <installer> --installClient <.minecraft> in a temporary folder. |
| Forge | <mc>-forge-<loader> |
The same with https://maven.minecraftforge.net/net/minecraftforge/forge/<mc>-<loader>/forge-<mc>-<loader>-installer.jar. |
| Vanilla | <mc> |
Nothing: the launcher has every vanilla version. |
When the version JSON is already there it prints <loader> for Minecraft <mc> is already installed. and downloads nothing. Downloads follow redirects, never from https to http, time out after 10 seconds to connect and 30 to read, and go to a temporary file first, so a failure leaves no partial file. The Forge and NeoForge installers download the vanilla version (versions/<mc>/<mc>.json and its jar) and the libraries they patch themselves; their output goes to the log without the thousands of lines that list patched classes. They also add a profile named after themselves (NeoForge, forge), so the installer removes every profile that was not in launcher_profiles.json before the run, except sculk-<slug>, also when they fail. Their installers need launcher_profiles.json, which the launcher writes on its first start.
A failure says why and what to do next:
$ java -jar sculk-installer.jar --cli --launcher mojang
Installing Sculk Testing for Minecraft Launcher in C:\Users\Ana\AppData\Roaming\.minecraft
Could not download https://maven.neoforged.net/releases/net/neoforged/neoforge/21.1.266/neoforge-21.1.266-installer.jar (java.net.UnknownHostException: maven.neoforged.net). Check your internet connection and run the installer again.Tests point every loader download at a stand-in server with the SCULK_LOADER_BASE environment variable or the sculk.loaderBase system property: the loader's path is appended to it instead of its own server.
Tunnel agent mode (opt-in)#
sculk-sync.jar can also act as a sculkworm tunnel agent for a closed route (see crates/sculkworm/docs/tunnel.md): it dials out to the relay's TLS tunnel listener (ALPN sculkworm), authenticates with a per-route swa_ agent token, serves incoming player streams to a local TCP target (host:port), sends PING/PONG keepalives, reconnects with full-jitter exponential backoff, and honors GOAWAY (including GOAWAY replaced, where it drains open streams and exits with code 3 without reconnecting).
The agent is opt-in: if sculk.json has no tunnel block (or "enabled": false), sculk-sync.jar makes zero tunnel network connections and behaves identically to standard sync mode.
Configuration in sculk.json#
Add an optional tunnel object to sculk.json:
{
"manifestUrl": "https://sculk.network/c/<token>/manifest.json",
"tunnel": {
"relay": "https://relay.example:8443",
"route": "friends.play.example",
"token": "swa_<token-id>_<token-secret>",
"target": "127.0.0.1:25565",
"caFile": "relay-ca.pem",
"pin": "sha256/<base64-spki-sha256>"
}
}| Field | Required | Default | Meaning |
|---|---|---|---|
enabled |
No | true |
Set to false to disable the tunnel agent without removing the block. |
relay |
Yes | — | Relay tunnel URL (https://host[:port]) or host[:port] (default port 443). |
route |
Yes | — | Closed route hostname registered on the relay. |
token |
Yes* | — | Per-route agent token (swa_<id>_<secret>). Masked in log output. |
tokenFile |
Yes* | — | Path to a file containing the agent token (relative to the instance folder, or absolute). Used when token is omitted. |
target |
No | 127.0.0.1:25565 |
Local Minecraft server host:port to bridge incoming OPEN streams to (5 s connect timeout). |
caFile |
No | OS/JDK roots | PEM certificate/CA file replacing the default trust store (useful for self-signed or private relay CAs). Relative to the instance folder, or absolute. |
pin / pins |
No | — | Optional SPKI SHA-256 certificate pin (sha256/<base64>) or array of pins checked in addition to normal certificate chain and hostname verification. |
software |
No | sculk-sync/1 |
Software string sent in HELLO (at most 64 UTF-8 bytes). |
*Either token or tokenFile must be set.
Running the tunnel agent#
- Standalone foreground mode: run
java -jar sculk-sync.jar --tunnel-agent [instance-dir](or setINST_DIR). The process runs the reconnect loop in the foreground, shuts down cleanly withGOAWAY normalonSIGTERM/SIGINT, and returns the spec exit codes (0on clean shutdown,2on config error /unsupported_version/unknown_route,3onGOAWAY replaced). - In-JVM
-javaagentmode: when launched with-javaagent:sculk-sync.jar=<instance dir>andsculk.jsoncontains an enabledtunnelblock,premainstarts the tunnel agent on a daemon thread right after sync completes so it runs alongside the JVM process and sendsGOAWAY normalvia a shutdown hook when the JVM exits.
Java 8u251+ or Java 9+ is required for TLS ALPN (sculkworm).
Tests#
pnpm --filter @sculk/sync test runs every case on Java 8 and Java 21 in Docker. test/sync.test.ts covers both modes of the sync jar. test/tunnel.test.ts runs test/java/TunnelProtocolTest.java and test/java/TunnelAgentTest.java on Java 8 and Java 21 to verify every hex vector in crates/sculkworm/docs/tunnel.md, the session multiplexer over in-memory pipes, the reconnect backoff policy, TLS/ALPN/SPKI pinning, stream bridging, and GOAWAY handling; when SCULKWORM_BIN points to a built sculkworm binary, it also runs an end-to-end interoperability test against the real relay (registering a closed route and agent token via the admin API, connecting sculk-sync.jar --tunnel-agent, pushing a real Minecraft status ping over TCP, and verifying GOAWAY replaced exit code 3). test/installer.test.ts writes a sculk-installer.json and an icon into the built installer, runs it against a temporary home for each launcher, reruns it and compares the files, then starts a stand-in game with the Java arguments the installer wrote and checks that the mods folder was synced first. A local HTTP server stands in for the loaders' meta servers and Mavens, and test/fixtures/FakeInstaller.java for the Forge and NeoForge installers: it adds its own profile like they do.