Skip to content

fix(forge): OptiFine runs on Forge; processors run as Forge's installer runs them - #519

Merged
AntonBabchenko merged 10 commits into
mainfrom
fix/forge-classpath-and-processors
Oct 18, 2026
Merged

AntonBabchenko merged 10 commits into
mainfrom
fix/forge-classpath-and-processors

Conversation

@AntonBabchenko

@AntonBabchenko AntonBabchenko commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

OptiFine on Forge 1.20.1 loaded but stayed inactive. Two things in Lucerna's launch classpath caused it, and both were proven by isolation runs:

  • the version jar was missing;
  • Forge's patched client jar (forge-<v>-client.jar) was on -cp.

Library order was irrelevant.

This PR launches Forge the way the official Minecraft launcher does, and builds Forge installs the way Forge's own installer does.

A. Launch classpath (launch/classpath.rs, launch/version_jar.rs)

  • The version jar goes last on -cp, as the official launcher puts it for inheritsFrom profiles.
  • Its name.
    • The jar gets the name versions/<synth>/<id>.jar only where the profile's JVM args name ${version_name}. That is the BootstrapLauncher -DignoreList eras: Forge 1.17–1.20.x and NeoForge.
    • Lucerna materialises that jar from the vanilla jar: a hardlink, or a copy as fallback, through mods::store::materialize. The source is checked against the JSON's sha1 first.
    • Every other era uses the vanilla path itself.
  • The injected net.minecraftforge:forge:<v>:client entry that Lucerna ≤ 0.27 added to merged JSONs is dropped from the classpath and from Verify.
  • New error ClientJarInvalid { mc_version, missing }, with EN/RU copy pointing to Integrity → Verify/Repair.

B. ${clientid} / ${auth_xuid}

They are substituted as empty strings instead of reaching the game as literal text.

C. Forge processors run as Forge's installer runs them (forge/installer/processors.rs)

  • Each processor jar's Main-Class runs on Lucerna's Java, with the installer's own arguments and classpath. DOWNLOAD_MOJMAPS --sanitize is the exception: it is a byte-exact Rust port of srgutils 0.5.10 that downloads through network::.
  • Declared outputs are checked against install_profile.json's *_SHA the way the official installer checks them:
    • an output that matches is a cache hit;
    • a stale output is deleted;
    • an output still mismatched after the run is refused with ForgeProcessorOutputMismatch.
  • The Rust jarsplitter, binarypatcher, specialsource and fart were removed, and so was the xz2 dependency.
  • ensure_processor_outputs rebuilds an existing install whose outputs differ, from install_version, so Install and Repair. Launch never runs it. The rebuild is refused while a game runs.
  • Verify plans Forge's declared outputs and the patched jar. A Forge processor output whose bytes differ gets a new status, BuiltDifferently, not Corrupt. Integrity says the files were built differently from Forge's own installer, that the game still launches with them, and that Repair rebuilds them the way Forge's installer does. EN and RU; spec 2026-10-16 §5.5.

Docs

  • docs/PRINCIPLES.md Appendix A has one bounded processor row in place of five, and its "Selective Java subprocess" paragraphs are rewritten.
  • docs/TESTING.md fixture and ignored-test rows are updated.
  • CHANGELOG has three Fixed bullets, mirrored in ru.md.

Dependencies

xz2 (and transitively lzma-sys) is removed. No crate is added.

Test plan

  • TDD units, each seen red on a stub or mutation first:

    • classpath per era;
    • version-jar plan and ensure (10);
    • args substitution: every era fixture leaves no ${…};
    • processors stage with a fake StageIo (14);
    • manifest Main-Class parser (6);
    • mojmaps port (7, including a byte-exact srgutils fixture);
    • maven coordinate @ext after a classifier;
    • verify plan, scan and aggregate, including BuiltDifferently;
    • library downloads skip the injected entry.
  • cargo test --lib -- forge:: verify:: versions::libraries launch:: on the merged base (feat: share the server list, command history and hotbars between instances (Shared data, step 2) #517): 310 passed

  • All 25 structural_* guards pass. --export-bindings --check reports bindings up to date

  • mojmaps_network (#[ignore]): the port reproduces MOJMAPS_SHA for 1.20.6, 1.21.1, 1.21.11

  • vitest integrity-section (10), changelog-parity (6), format-error

  • Era matrix loader_matrix_e2e on the final code. All 42 combos reached the menu:

    • MC 1.12.2, 1.16.5, 1.18.2, 1.20.1, 1.20.4, 1.20.6, 1.21.1, 1.21.11, 26.2 and 26.3;
    • vanilla, Fabric, Quilt, Forge and NeoForge;
    • every Forge and NeoForge processor era installed with its declared SHAs checked.

    Runs:

    • Run 1 (pre-review binary) stopped at 1.20.4-49.2.0. It found the @ext bug: […:mappings@tsrg] outputs were looked for as .jar.
    • Run 2: 1.20.4 → 26.3, 25/28.
    • Run 3: 26.x with a short data root, 8/8.
    • Run 4: 1.12.2 → 1.20.1 with the final binary, 14/14.

    The three run-2 failures were the scratch data root's 172-character path, not this change:

    • LWJGL DLL paths of 254+ characters on 26.x Fabric;
    • a 26.2 Forge command line over Windows' 32 767-character limit (26.3 Forge needed 30 667).

    They passed with a short root. Both limits pre-date this PR (no Java @argfile, per-synth natives paths) and are noted for the roadmap.

  • Upgrade path in a throwaway data root (com.lucerna.forgecp):

    • Install with an origin/main build: Forge 1.20.1-47.4.10 (110 s) and Forge 1.21.1-52.1.14 (88 s).
    • Verify with the PR build:
      • 1.20.1: 2 files built differently (MC_SLIM, MC_EXTRA);
      • 1.21.1: 3 (MOJMAPS .tsrg, MC_OFF, PATCHED);
      • none reported corrupt.
    • Both old-built installs launch to the menu before Repair: 29 s each.
    • Repair: 63 s and 74 s. Every rebuilt file equals the declared *_SHA, and the 1.20.1 patched jar also equals the PATCHED_SHA Forge does not declare. Verify is healthy and both launch to the menu.
  • OptiFine I6 (sha1 227914ab…) on the repaired Forge 1.20.1, installed through mods_install_local (the UI's local-jar path) and launched to the menu in 37 s. Log markers:

    • [OptiFine] OptiFine_1.20.1_HD_U_I6 from net.optifine.Config on the Render thread;
    • shaderpacks/ created;
    • 0 × MD5 not matching;
    • 0 × Base resource not found.

    No computer-use, and nobody clicked in a game window.

  • Re-check on the final head 6eea5dbf (origin/main a4664719 merged in, with feat: share the server list, command history and hotbars between instances (Shared data, step 2) #517 and feat: share game options between instances (Shared data, step 3) #523 changing launch code):

    • cargo test --lib -- forge:: verify:: versions::libraries launch::: 310 passed;
    • all 25 structural guards pass, and the bindings are up to date;
    • vitest (integrity-section, changelog-parity, changelog-locales, format-error, i18n-parity): 324 passed;
    • live, in the same throwaway root:
      • Verify is healthy for both repaired profiles;
      • OptiFine I6 on Forge 1.20.1: all four log markers, with shaderpacks/ deleted beforehand and recreated by OptiFine; menu in 41.5 s;
      • Forge 1.21.1 reaches the menu in 32.9 s;
      • a fresh Forge 1.20.6-50.2.0 install through the app takes 84 s, Verify is healthy (declared SHAs including mappings@tsrg), and it reaches the menu in 33.3 s.
  • CI green

Review

  • One code reviewer and one skeptic on 90ffc353..50943228.
  • Fixed in this PR:
    • one global stage lock;
    • a two-sided rebuild/launch guard (rebuild_in_progress, is_any_starting);
    • preflight of every processor before any stale output is deleted;
    • no unpinned processor-classpath download (classpath_coords_to_libraries removed);
    • a missing patched jar triggers a rebuild;
    • the injected :client entry is skipped in downloads;
    • Forge 1.20.6+'s own :client row reads as built differently;
    • mojmaps scratch files are cleaned up;
    • claims in docs and copy are scoped to what was measured.
  • Found by the era matrix: maven_coord_to_relative_path dropped @ext after a classifier. Forge 1.20.4+ declares …:mappings@tsrg outputs, so they were looked for as .jar.
  • Left to the roadmap: launch::start does not re-check verify::repair_in_progress() after its claim. This is pre-existing.

Live checks: disk and time

  • Era matrix: 1523 s (run 1, stopped), 2070 s (run 2), 706 s (run 3) and 887 s (run 4), about 87 min of wall clock. Peak disk was about 7.2 GB: a 2.9 GB data root plus 4.3 GB of temp files that the JVMs and processors wrote under the scratch TMP. Removed.
  • Upgrade path and OptiFine: throwaway data root %APPDATA%com.lucerna.forgecp, 1.4G, about 15 min. It was kept for the final-head re-check and has now been removed.
  • Builds: an isolated CARGO_TARGET_DIR (lib tests, test binaries, two dev exes: this branch and origin/main).

🤖 Generated with Claude Code

AntonBabchenko and others added 10 commits October 17, 2026 19:51
…er does

Launch classpath (spec 2026-10-16 §3):
- every era ends -cp with a version jar, as the official launcher does;
  a profile whose JVM args name ${version_name} (BootstrapLauncher-era
  Forge 1.17-1.20.x, NeoForge 20.x-21.x) gets a link/copy of the vanilla
  jar under exactly that name (launch::version_jar), sha1-checked at
  every launch; other profiles get the vanilla jar itself
- the patched-client entry Lucerna injected ("ADDENDUM D") is gone, and
  old caches' copy of it is kept off -cp and out of verify's library plan
- one pure composition rule (launch::classpath) shared by spawn and the
  loader matrix harness

clientId/xuid (§4): both substitute to "", which MC reads as "not given".

Processors (§5):
- every Forge/NeoForge processor runs its jar's Main-Class on Java, with
  declared outputs checked against install_profile SHAs (cache hit,
  delete-on-mismatch, post-run check), in one stage shared by the
  transitional and modern installers, under a per-version lock
- DOWNLOAD_MOJMAPS stays in Rust through network::; --sanitize reproduces
  srgutils 0.5.10's TSRG byte for byte (fixture generated by srgutils;
  MOJMAPS_SHA reproduced for 1.20.6, 1.21.1, 1.21.11)
- install_version rebuilds stale declared outputs (refused while a game
  runs); verify plans them, plus the patched client jar
- the pure-Rust jarsplitter, binarypatcher, installertools, SpecialSource,
  FART and ART reimplementations are deleted, with xz2/lzma-sys
- processors run on the console java.exe with no window

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tput checksum mismatch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e Forge fixes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd-processors

# Conflicts:
#	src-tauri/src/forge/patcher/binarypatcher.rs
#	src-tauri/src/forge/patcher/jarsplitter.rs
…ently, not corrupt

A Forge processor output whose bytes differ from what the installer
declares gets its own status, BuiltDifferently, counted apart from
corrupt and missing. Older Lucerna versions built these files with their
own code; the game launches with them, and one Repair rebuilds them with
Forge's own processors. Integrity says so in EN and RU instead of calling
them corrupt. An instance.json saved before the count existed reads it
as 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd-processors

# Conflicts:
#	src-tauri/src/launch/spawn.rs
… network test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oordinates

- One stage lock for every Forge/NeoForge version: outputs are shared
  across Forge builds of one Minecraft version.
- A rebuild and a launch exclude each other on both sides: the rebuild
  refuses while a game runs or starts and marks itself; launch::start
  checks the mark after claiming its slot.
- Every processor's jar, classpath and arguments are checked before any
  stale output is deleted.
- No processor classpath is fetched by a guessed URL without a checksum;
  a missing entry stops the install, as in Forge's installer.
- A missing patched client jar makes Repair rebuild it.
- Downloads skip the patched-client entry Lucerna <= 0.27 injected; Forge
  1.20.6+'s own :client library reads as built differently, not corrupt.
- maven_coord_to_relative_path keeps the @ext after a classifier: Forge
  1.20.4+ declares outputs such as mappings@tsrg (found by the era matrix).
- mojmaps scratch files are named after the whole output name and removed
  on failure.
- Copy and docs scoped to what is measured; RU row uses plural forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AntonBabchenko
AntonBabchenko enabled auto-merge (squash) October 18, 2026 01:33
@AntonBabchenko
AntonBabchenko merged commit f16c280 into main Oct 18, 2026
12 checks passed
@AntonBabchenko
AntonBabchenko deleted the fix/forge-classpath-and-processors branch October 18, 2026 01:48
AntonBabchenko added a commit that referenced this pull request Oct 18, 2026
* docs(changelog): audit [Unreleased] for v0.28.0

Every bullet was checked against the code at f16c280 and, for Fixed, against
the v0.27.0 tree, by three read-only audits and a skeptic pass; each finding
was re-checked by hand.

Moved or dropped:
- Link marking moves from Fixed to Changed: v0.27.0 already followed a linked
  content root on import, clone and export; only the label is new.
- The data pack library note joins the folder-button bullet: the library had
  no way in from the UI before that button.
- The language-picker bullet is dropped: only en and ru ship, ru is 100%
  translated, and System still resolves ru* to Russian and the rest to English.
- New Fixed: a clone copied the pack files but not their list, so packs
  installed from Add-ons were missing from its Installed tab.

Tightened (claims the code does not make):
- Shared data lives on the instance's Settings tab; DH and Voxy copy
  multiplayer data; "other folders" are the game folder's.
- Settings sync: the new-instances checkbox is off by default and also covers
  clients made from a server; history needs 1.20.2+, hotbars a release from
  1.14, game options a release from 1.13 to 26.3; graphics mode syncs, so
  "how the game looks" rather than "graphics settings".
- The damaged-file repair replaces whichever file is damaged, not a choice.
- Pack removal: unpacked packs and zips not from Modrinth/CurseForge go to the
  recycle bin, the rest are deleted.
- Own Java refuses to start; the Java rescue fires whenever Lucerna can't get
  its Java, and "all instances" only for one that follows Settings.
- Java never sat in the Manage window; the sidebar menu items are named.
- OptiFine is proven on Forge 1.20.1 only, and "classpath" is jargon.
- ${clientid}/${auth_xuid} reached the game from 1.18 on.
- The old network message was "check your internet connection" in most places;
  Reload is offered for Minecraft, loader and server-core version lists.
- A Forge installer is "unverifiable" only when no checksum is published.
- Server/instance conversion refuses only a broken mods-folder link; a failed
  pack removal shows the error.

Fixed is ordered by theme: Forge and launch, network and lists, folders,
packs, macOS, shaders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(changelog): split the Forge build bullet into Fixed and Changed

Design review of #519 (F7): "built the way Forge's own installer builds them"
is a property, so it is Changed; what was broken at v0.27.0 is Verify
flagging a Forge 1.20.6+ file after every check that Repair never rebuilt.
The Changed bullet does not call built-differently files problems, and the
RU drops the calque «одно «Восстановить»».

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(changelog): apply the skeptic pass to the merged audit

- The Java rescue's "every instance" button sets the Settings default, which
  reaches only instances on that Java version that follow Settings.
- Export is offered only for modded instances, so the sidebar menu example
  names Clone instead.
- Reload is offered only when a version list couldn't be fetched, and the
  third list is the server core's.

Checked and kept: built-differently files are Forge-only (NeoForge declares
no processor outputs, spec table "NeoForge (any) | none declared").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
AntonBabchenko added a commit that referenced this pull request Oct 18, 2026
…ywhere (#526)

* fix: Forge files built differently, or not checked, are not damage anywhere

v0.28 design review of #519 (F1–F3); #519's spec §5.5 revisited
2026-10-18 by the orchestrator on the maintainer's delegation.
- F1: the note says the game still starts with these files AND that
  they can be left as they are: Repair is optional (it deletes before it
  rebuilds). With no damage found, Repair is a secondary button.
- F3: a Forge installer that is not saved, or not readable, was a
  Libraries problem «1 missing» (red). It is now ArtifactStatus::Unchecked,
  counted in no category and no total, with VerifyReport/IntegrityStatus
  .forge_installer (not_saved | unreadable) giving it a line of its own;
  Repair still runs the full install that downloads it.
- F2: summarizeIntegrity tells notes from damage for every surface: with
  only notes the sidebar draws no glyph, the Overview raises no
  «Needs attention» and its card says «No damage found», Verify's toast
  is a success; the Integrity section is the one place that explains.
  Any damage counts as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: notes stay notes only when they are; an unchecked Forge is said so

Review of #526:
- An unreadable manifest beside notes was classed «no damage found»;
  IntegrityStatus now keeps manifest_recoverable and the summary counts
  it as damage.
- A notes-only result never went stale and showed «No damage found»
  in every later session; it is now session-scoped like a healthy one.
- Forge's own files not checked: Verify's toast is a warning, «no damage
  found, but Forge's own files weren't checked», and the Overview card
  says the same, instead of a full pass.
- «can't be read» no longer promises a download Repair does not do (a
  corrupt cached installer is never re-fetched — ROADMAP); «isn't saved»
  says Repair also rebuilds the files that differ.
- The Rust test builds the installer problem with the real builder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
AntonBabchenko added a commit that referenced this pull request Nov 5, 2026
…ows (#543)

* fix: pass the profile's JVM arguments in a Java argument file on Windows

Windows caps a command line at 32 767 characters, and the classpath grows
with every library times the data folder path. A 26.x loader profile
crossed it from a data root of ~110 characters (os error 206); #519
measured Forge 26.2 failing at 172.

On Windows with Java 9+ the version profile's JVM arguments now go in
instances/<id>/jvm-args.txt, named as @<file> on the command line. The
user's own JVM arguments stay in front of it, the main class and game
arguments (with the access token) after it. Java 8, Linux and macOS
keep the command line.

- The Java major is measured: the probe for a chosen Java, the runtime's
  release file for Lucerna's own; unknown means the command line.
- The file holds no escape and no comment, quotes only space/TAB/FF/#/'
  runs (and " in single quotes), keeps backslashes unquoted, and ends
  every argument with LF: safe for DBCS trail bytes (0x5C) and for the
  JDK 9-11.0.1 and pre-JDK-8231863 readers. LF/CR, NUL, U+001A and a
  leading @ are refused.
- Bytes are the ANSI code page without best fit (UTF-8 when that is the
  code page), as java.exe converts its own command line; a character the
  code page lacks is refused and named.
- ${auth_access_token} and ${auth_session} are substituted in game
  arguments only, so the token never reaches the file.
- --disable-@files (instance args or JDK_JAVA_OPTIONS) keeps the command
  line. The file is kept after exit (restart mods re-run @<file>) and
  removed after a failed spawn or a command-line launch.

* fix: leave no stale argument file and compile the launch integration tests

Review follow-ups to the argument-file change:
- tests/launch_pipeline_integration.rs and tests/loader_matrix_e2e.rs
  still read build_argv's old flat Vec; they now compose the argv with
  launch::argfile::command_line, as launch::spawn does.
- A refused or failed write removes the file, so an earlier launch's
  file never passes for this one's.
- A quoted --disable-@files in JDK_JAVA_OPTIONS counts (the launcher
  unquotes it), and a non-Unicode value is read lossily, not as unset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant