[PR #1569] [MERGED] Server resource packs: the client's pack manager and downloads #3595

Closed
opened 2026-11-03 04:10:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: feat/server-packs-manager


📝 Commits (1)

  • cdfcc3d Server resource packs: the client's pack manager and downloads

📊 Changes

5 files changed (+1104 additions, -0 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-client/Cargo.toml (+2 -0)
📝 crates/horizon-client/src/lib.rs (+1 -0)
➕ crates/horizon-client/src/server_packs.rs (+618 -0)
➕ crates/horizon-client/src/server_packs/download.rs (+482 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Server resource packs, part 2 of 3: the client's pack manager and downloads. This is library code with unit tests. Part 3 wires it into the game (prompt, setting, apply) and stacks on this branch. Part 1 (#1562) is the server side.

What it ports

server_packs.rs: vanilla's ServerPackManager and DownloadedPackSource, without the game around them.

  • The prompt state: pending, allowed, declined.
  • Each pack's download and activation.
  • The statuses in vanilla's order: ACCEPTED, then DOWNLOADED, then SUCCESSFULLY_LOADED. onSuccess repeats SUCCESSFULLY_LOADED for every pack that stays loaded. A failed reload recovers with the packs that did load.
  • DISCARDED and FAILED_DOWNLOAD come in pack order.
  • Pop, pop all, and leaving the server.

server_packs/download.rs: DownloadQueue and HttpUtil.downloadFile.

  • The file goes to downloads/<pack id>/<sha1>, and a cached file whose hash matches is reused (its mtime is touched).
  • A wrong hash fails. Like vanilla, it keeps the bytes under the requested name and deletes them on the next attempt.
  • With no hash, the pack downloads to a temporary file that is renamed to its SHA-1.
  • The folder is created only once the connection succeeds. Downloads are capped at 250 MiB.
  • Requests carry vanilla's headers: X-Minecraft-Username, -UUID, -Version, -Version-ID, -Pack-Format: 97.1, and User-Agent: Minecraft Java/26.3.
  • Each download adds a log.json entry in vanilla's field order (JsonEventLog).
  • The cache keeps 20 files (DownloadCacheCleaner).

Adds the sha1 crate, which is already in Cargo.lock through another dependency.

Proof

  • 11 unit tests. 7 cover the state machine: an enabled server's pack, the prompt holding packs, a failed download discarding the batch, a failed reload, pop and leaving, a pushed id replacing its pack, URL and hash parsing. 4 cover downloads against a local HTTP server: the cache and the headers, a wrong hash, a dead URL and an oversized pack, log.json, and the 20-file cleaner. The no-hash path is covered by part 3's end-to-end run ("Yes at the prompt, no hash").
  • End to end, this code is exercised by part 3's tools/server_pack_e2e.py against vanilla 26.3's dedicated server and Horizon's: all 8 scenarios pass (details in part 3).

Self-check

cargo fmt --check ✅ · cargo clippy -p horizon-client --lib --tests -D warnings ✅ · cargo test -p horizon-client --lib server_packs ✅ 11 passed. Scope: 5 files, +1104, of which 336 are tests. It is over the ~500-line guide because the state machine and the downloader only make sense together. Part 3 holds the wiring.

🤖 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/1569 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/server-packs-manager` --- ### 📝 Commits (1) - [`cdfcc3d`](https://github.com/horizon-rust/horizon/commit/cdfcc3d4d446e59c075e6fd0018a8cc599519cdc) Server resource packs: the client's pack manager and downloads ### 📊 Changes **5 files changed** (+1104 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-client/Cargo.toml` (+2 -0) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) ➕ `crates/horizon-client/src/server_packs.rs` (+618 -0) ➕ `crates/horizon-client/src/server_packs/download.rs` (+482 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Server resource packs, part 2 of 3: the client's pack manager and downloads. This is library code with unit tests. Part 3 wires it into the game (prompt, setting, apply) and stacks on this branch. Part 1 (#1562) is the server side. ## What it ports **`server_packs.rs`**: vanilla's `ServerPackManager` and `DownloadedPackSource`, without the game around them. - The prompt state: pending, allowed, declined. - Each pack's download and activation. - The statuses in vanilla's order: ACCEPTED, then DOWNLOADED, then SUCCESSFULLY_LOADED. `onSuccess` repeats SUCCESSFULLY_LOADED for every pack that stays loaded. A failed reload recovers with the packs that did load. - DISCARDED and FAILED_DOWNLOAD come in pack order. - Pop, pop all, and leaving the server. **`server_packs/download.rs`**: `DownloadQueue` and `HttpUtil.downloadFile`. - The file goes to `downloads/<pack id>/<sha1>`, and a cached file whose hash matches is reused (its mtime is touched). - A wrong hash fails. Like vanilla, it keeps the bytes under the requested name and deletes them on the next attempt. - With no hash, the pack downloads to a temporary file that is renamed to its SHA-1. - The folder is created only once the connection succeeds. Downloads are capped at 250 MiB. - Requests carry vanilla's headers: `X-Minecraft-Username`, `-UUID`, `-Version`, `-Version-ID`, `-Pack-Format: 97.1`, and `User-Agent: Minecraft Java/26.3`. - Each download adds a `log.json` entry in vanilla's field order (`JsonEventLog`). - The cache keeps 20 files (`DownloadCacheCleaner`). Adds the `sha1` crate, which is already in `Cargo.lock` through another dependency. ## Proof - 11 unit tests. 7 cover the state machine: an enabled server's pack, the prompt holding packs, a failed download discarding the batch, a failed reload, pop and leaving, a pushed id replacing its pack, URL and hash parsing. 4 cover downloads against a local HTTP server: the cache and the headers, a wrong hash, a dead URL and an oversized pack, `log.json`, and the 20-file cleaner. The no-hash path is covered by part 3's end-to-end run ("Yes at the prompt, no hash"). - End to end, this code is exercised by part 3's `tools/server_pack_e2e.py` against vanilla 26.3's dedicated server and Horizon's: all 8 scenarios pass (details in part 3). ## Self-check `cargo fmt --check` ✅ · `cargo clippy -p horizon-client --lib --tests -D warnings` ✅ · `cargo test -p horizon-client --lib server_packs` ✅ 11 passed. Scope: 5 files, +1104, of which 336 are tests. It is over the ~500-line guide because the state machine and the downloader only make sense together. Part 3 holds the wiring. 🤖 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-03 04:10:41 +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#3595
No description provided.