RemapCache

object RemapCache

First-launch remap-bundle provisioning for a NON-mojmap production runtime. The mod jar carries no per-version mapping data. On a Fabric intermediary runtime with no mcp.remap.* flags set, this downloads the two per-version artifacts that ARE published (Mojang client mappings + fabric intermediary), assembles named<->intermediary, and reverse-remaps the runtime jar into a mojmap symbol jar — caching everything under the mod's cache dir, one subdirectory per MC version. On later launches it's a cache hit.

Runs on the game loader (network + JSON via MC's bundled Gson live here). The two library operations that need mapping-io + tiny-remapper (assemble + reverse-remap) are done on the masking loader via ReplBridge.buildRemapArtifacts / ReplBridge.buildForgeArtifacts.

Properties

Link copied to clipboard
private val FETCH: ExecutorService?

Where the concurrent halves of a build run. Named, so supplyAsync cannot fall back to the common ForkJoinPool: that one is sized for short CPU work — a download holds a worker for up to Downloads' two-minute body timeout — and its threads carry the system class loader instead of Constants.GAME_LOADER, which every thread this mod starts sets for the reason that field documents.

Link copied to clipboard
private val loaderStamp: String

What the symbol jar's bytes depend on: the loader's binpatches are baked into it, so its identity is part of the cache key. Bukkit's brand AND build ride along because a hybrid (Youer, Silkard) patches a four-figure number of MC classes on top of its base loader while reporting only the base loader's version — and its brand is a constant across its own builds, so the build half is the load-bearing one.

Functions

Link copied to clipboard
private fun build(mcUri: String, version: String, cacheDir: Path, mappings: Path, symbolsDir: Path)

Download the per-version sources, then hop to the masking loader to assemble + reverse-remap.

Link copied to clipboard
private fun buildForge(mcUri: String, version: String, cacheDir: Path, mappings: Path, symbolsDir: Path)

Forge Mixed-SRG variant: download MCPConfig (obf->srg) + Mojang (named<->obf), then hop to the masking loader to assemble srg_to_official.tsrg + reverse-remap the Mixed-SRG runtime jar into a mojmap symbol jar.

Link copied to clipboard
private fun buildSpigot(mcUri: String, version: String, cacheDir: Path, mappings: Path, symbolsDir: Path)

Spigot variant: Mojang's client_mappings (named<->obf) + BuildData's class csrg (obf->spigot), pivoted on obf. Two sources for the same reason fabric needs two — BOTH axes move on a spigot runtime. Members are the obf names, so proguard carries them; classes are spigot's OWN names (BlockPos is BlockPosition), which no Mojang artifact can express, so they take the second source.

Link copied to clipboard
private fun checkArtifacts(label: String, mappings: Path, symbolsDir: Path)

The builders hop to the masking loader and return void, so the artifacts landing on disk is their only success signal. label names the variant in the failure.

Link copied to clipboard
fun provision(mcAnchor: Class<*>): RemapBundle?

The remap bundle for a non-mojmap runtime, building the cache on first launch. Null on mojmap (dev / NeoForge production / Fabric dev), on an unsupported namespace, and on failure — which degrades this process to no-remap; the next relaunch rebuilds (an incomplete cache re-downloads).