[PR #440] [MERGED] Launcher: download Minecraft from Mojang for a signed-in owner #2567

Closed
opened 2026-11-02 15:57:15 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/440
Author: @ludovic111
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @ludovic111

Base: main ← Head: feat/launcher-owner-download


📝 Commits (2)

  • b2e9faf launcher: prepare from Prism, MultiMC, Modrinth App, ATLauncher or GDLauncher
  • d30df8c launcher: download Minecraft from Mojang for a signed-in owner

📊 Changes

13 files changed (+1415 additions, -90 deletions)

View changed files

📝 launcher/Cargo.lock (+1 -0)
📝 launcher/Cargo.toml (+2 -0)
📝 launcher/src/account.rs (+6 -0)
📝 launcher/src/account/tests.rs (+15 -0)
📝 launcher/src/backend.rs (+100 -84)
📝 launcher/src/cli.rs (+4 -2)
📝 launcher/src/lib.rs (+2 -0)
📝 launcher/src/main.rs (+2 -2)
📝 launcher/src/mcp.rs (+2 -2)
➕ launcher/src/mojang.rs (+194 -0)
➕ launcher/src/mojang_tests.rs (+232 -0)
➕ launcher/src/sources.rs (+449 -0)
➕ launcher/src/sources_tests.rs (+406 -0)

📄 Description

Fixes #434. Stacked on #438, which is stacked on #437. Merge in that order; each PR then retargets to main.

What

This is the last way out of #434, for players with no working launcher at all (rdbt's case if Prism isn't an option). It applies when no folder has Minecraft 26.3 and the account signed in to Horizon owns Minecraft: Java Edition.

Ownership is checked again each time: account::owns_minecraft sends the saved Minecraft token (refreshed by session_for_launch if needed) to the same mcstore entitlement endpoint that sign-in uses. There is no other path to the download, no offline path, and nothing of Mojang's is in the repo or in a Horizon build.

What is downloaded (launcher/src/mojang.rs), the way third-party launchers do it:

  • the version JSON, from piston-meta.mojang.com/v1/packages/<pinned sha1>/<v>.json;
  • the client jar, from the JSON's downloads.client, checked against the lock's client_sha1;
  • this system's libraries: downloads.artifact where the JSON's os.name rules allow linux / osx / windows, the last matching rule deciding;
  • the asset index and its objects from resources.download.minecraft.net, so the game has sound.

How it is stored:

  • In <data dir>/minecraft/, in the official layout. That folder is searched first on later preparations and used as is, so the download happens once.
  • Every file is checked against its sha1 and written whole (.partial, then renamed), 8 at a time, with a progress line every 5 s.
  • Files already there and whole are kept, so an interrupted download picks up where it stopped.
  • A failed asset is a line in the log (the game is then partly silent, as with any launcher missing sounds). Anything else is an error. Paths from the JSON that could leave the folder are refused.

When it can't download, the not-found error from #437/#438 gets one more line:

  • not signed in: • Or sign in with the Microsoft account that owns Minecraft: Horizon then downloads 26.3 from Mojang itself.
  • signed in without the game: • <name>, the signed-in account, doesn't own Minecraft: Java Edition, so Horizon can't download it.
  • account check failed (offline, keychain): the reason.
  • download failed: what failed, e.g. <url> is not the one Horizon pins (sha1 …).

sources.rs gives the version-file fetch, sha1 check and atomic write to the downloader, and resolve now returns Resolved::Folder or Resolved::NotFound(checked) so the backend can try the download before it reports.

How tested

Mocked HTTP only for the download itself. There is no signed-in Microsoft account on the Mac mini, and the download must not run without ownership, so I did not download from Mojang for real. The fake files are served by URL in mojang_tests.rs, and none of them are Mojang's:

  • Linux gets the official layout with only its libraries (a Windows-only one skipped, an allow-then-disallow-osx one kept).
  • A sound shared by two names is fetched once.
  • The download is found by resolve as an official folder, and a second download fetches nothing.
  • macOS skips what its rules disallow.
  • A client jar with the wrong sha1 stops the download and leaves no jar.
  • A missing sound object is a log line, not an error.
  • Unsafe paths are refused.

account/tests.rs: owns_minecraft against the existing mock of the Minecraft services, with the account owning the game and then not.

Real CLI run on the Mac mini (scratch home, v2026.10.15.20, no account signed in, empty folder):

error: Minecraft 26.3 was not found. Horizon looked in:
  /tmp/hz-sources/empty (no Minecraft 26.3 client jar)
To fix it:
  • Play 26.3 once in the official Minecraft launcher, or in Prism Launcher, MultiMC, the Modrinth App, ATLauncher or GDLauncher, then prepare again.
  • Or choose the folder where your launcher keeps Minecraft 26.3 (Minecraft folder › Choose… in the launcher, --minecraft on the command line).
  • Or sign in with the Microsoft account that owns Minecraft: Horizon then downloads 26.3 from Mojang itself.
cargo fmt --check                                                       ok
cargo clippy --features gpui/runtime_shaders --all-targets -D warnings  ok (launcher)
cargo test --features gpui/runtime_shaders                              ok (50 + 4 + 1 passed, 1 ignored)
tools/parity.py --changed origin/main --list                            0 harnesses depend on launcher/
workspace clippy                                                        not run: no file outside launcher/ (its own workspace) changes

Needs Ludovic

One real end-to-end run when convenient. Start the launcher with HORIZON_LAUNCHER_HOME=/tmp/hz-owner (a scratch folder; accounts.json lives there too, so sign in with your Microsoft account in that window), set the Minecraft folder to an empty one, and press Prepare. It should log <name> owns Minecraft: downloading 26.3 from Mojang, then the progress lines, then prepare (about 600 MB to download). I didn't sign in for you.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/440 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/launcher-owner-download` --- ### 📝 Commits (2) - [`b2e9faf`](https://github.com/horizon-rust/horizon/commit/b2e9fafbe0b918435a40af37410584854fe556b8) launcher: prepare from Prism, MultiMC, Modrinth App, ATLauncher or GDLauncher - [`d30df8c`](https://github.com/horizon-rust/horizon/commit/d30df8ce33b06f8da2c17fa226a4144abbb1c692) launcher: download Minecraft from Mojang for a signed-in owner ### 📊 Changes **13 files changed** (+1415 additions, -90 deletions) <details> <summary>View changed files</summary> 📝 `launcher/Cargo.lock` (+1 -0) 📝 `launcher/Cargo.toml` (+2 -0) 📝 `launcher/src/account.rs` (+6 -0) 📝 `launcher/src/account/tests.rs` (+15 -0) 📝 `launcher/src/backend.rs` (+100 -84) 📝 `launcher/src/cli.rs` (+4 -2) 📝 `launcher/src/lib.rs` (+2 -0) 📝 `launcher/src/main.rs` (+2 -2) 📝 `launcher/src/mcp.rs` (+2 -2) ➕ `launcher/src/mojang.rs` (+194 -0) ➕ `launcher/src/mojang_tests.rs` (+232 -0) ➕ `launcher/src/sources.rs` (+449 -0) ➕ `launcher/src/sources_tests.rs` (+406 -0) </details> ### 📄 Description Fixes #434. Stacked on #438, which is stacked on #437. Merge in that order; each PR then retargets to main. ## What This is the last way out of #434, for players with no working launcher at all (rdbt's case if Prism isn't an option). It applies when no folder has Minecraft 26.3 **and** the account signed in to Horizon owns Minecraft: Java Edition. **Ownership is checked again** each time: `account::owns_minecraft` sends the saved Minecraft token (refreshed by `session_for_launch` if needed) to the same `mcstore` entitlement endpoint that sign-in uses. There is no other path to the download, no offline path, and nothing of Mojang's is in the repo or in a Horizon build. **What is downloaded** (`launcher/src/mojang.rs`), the way third-party launchers do it: - the version JSON, from `piston-meta.mojang.com/v1/packages/<pinned sha1>/<v>.json`; - the client jar, from the JSON's `downloads.client`, checked against the lock's `client_sha1`; - this system's libraries: `downloads.artifact` where the JSON's `os.name` rules allow `linux` / `osx` / `windows`, the last matching rule deciding; - the asset index and its objects from `resources.download.minecraft.net`, so the game has sound. **How it is stored:** - In `<data dir>/minecraft/`, in the official layout. That folder is searched first on later preparations and used as is, so the download happens once. - Every file is checked against its sha1 and written whole (`.partial`, then renamed), 8 at a time, with a progress line every 5 s. - Files already there and whole are kept, so an interrupted download picks up where it stopped. - A failed asset is a line in the log (the game is then partly silent, as with any launcher missing sounds). Anything else is an error. Paths from the JSON that could leave the folder are refused. **When it can't download,** the not-found error from #437/#438 gets one more line: - not signed in: `• Or sign in with the Microsoft account that owns Minecraft: Horizon then downloads 26.3 from Mojang itself.` - signed in without the game: `• <name>, the signed-in account, doesn't own Minecraft: Java Edition, so Horizon can't download it.` - account check failed (offline, keychain): the reason. - download failed: what failed, e.g. `<url> is not the one Horizon pins (sha1 …)`. `sources.rs` gives the version-file fetch, sha1 check and atomic write to the downloader, and `resolve` now returns `Resolved::Folder` or `Resolved::NotFound(checked)` so the backend can try the download before it reports. ## How tested **Mocked HTTP only for the download itself.** There is no signed-in Microsoft account on the Mac mini, and the download must not run without ownership, so I did not download from Mojang for real. The fake files are served by URL in `mojang_tests.rs`, and none of them are Mojang's: - Linux gets the official layout with only its libraries (a Windows-only one skipped, an allow-then-disallow-osx one kept). - A sound shared by two names is fetched once. - The download is found by `resolve` as an official folder, and a second download fetches nothing. - macOS skips what its rules disallow. - A client jar with the wrong sha1 stops the download and leaves no jar. - A missing sound object is a log line, not an error. - Unsafe paths are refused. `account/tests.rs`: `owns_minecraft` against the existing mock of the Minecraft services, with the account owning the game and then not. **Real CLI run on the Mac mini** (scratch home, v2026.10.15.20, no account signed in, empty folder): ``` error: Minecraft 26.3 was not found. Horizon looked in: /tmp/hz-sources/empty (no Minecraft 26.3 client jar) To fix it: • Play 26.3 once in the official Minecraft launcher, or in Prism Launcher, MultiMC, the Modrinth App, ATLauncher or GDLauncher, then prepare again. • Or choose the folder where your launcher keeps Minecraft 26.3 (Minecraft folder › Choose… in the launcher, --minecraft on the command line). • Or sign in with the Microsoft account that owns Minecraft: Horizon then downloads 26.3 from Mojang itself. ``` ``` cargo fmt --check ok cargo clippy --features gpui/runtime_shaders --all-targets -D warnings ok (launcher) cargo test --features gpui/runtime_shaders ok (50 + 4 + 1 passed, 1 ignored) tools/parity.py --changed origin/main --list 0 harnesses depend on launcher/ workspace clippy not run: no file outside launcher/ (its own workspace) changes ``` ## Needs Ludovic One real end-to-end run when convenient. Start the launcher with `HORIZON_LAUNCHER_HOME=/tmp/hz-owner` (a scratch folder; accounts.json lives there too, so sign in with your Microsoft account in that window), set the Minecraft folder to an empty one, and press Prepare. It should log `<name> owns Minecraft: downloading 26.3 from Mojang`, then the progress lines, then prepare (about 600 MB to download). I didn't sign in for you. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:57:15 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2567
No description provided.