[PR #85] [MERGED] Resource packs: reload everything in game and merge stacked files like vanilla (fixes #72) #2318

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

📋 Pull Request Information

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

Base: main ← Head: fix/resource-packs-72


📝 Commits (1)

  • 0d03789 Resource packs: reload everything in game and merge stacked files like vanilla (#72)

📊 Changes

14 files changed (+960 additions, -166 deletions)

View changed files

➕ crates/horizon-client/examples/pack_resources_fixture.rs (+92 -0)
📝 crates/horizon-client/src/assets.rs (+33 -4)
📝 crates/horizon-client/src/audio.rs (+10 -0)
📝 crates/horizon-client/src/game.rs (+58 -35)
📝 crates/horizon-client/src/game/options.rs (+2 -4)
📝 crates/horizon-client/src/game/packs.rs (+69 -53)
📝 crates/horizon-client/src/gfx.rs (+5 -2)
📝 crates/horizon-client/src/lang.rs (+26 -7)
📝 crates/horizon-client/src/packs.rs (+208 -5)
📝 crates/horizon-client/src/sound_events.rs (+38 -22)
📝 crates/horizon-client/src/sprites.rs (+86 -10)
📝 crates/horizon-client/src/streaming.rs (+35 -24)
➕ mods/horizon/src/test/java/dev/horizonlab/parity/VanillaPackResourcesOracle.java (+160 -0)
➕ tools/test_resource_pack_parity.py (+138 -0)

📄 Description

What was wrong

The issue has no description and the reporter hasn't said which pack they used (asked in #horizon-chat), so this fixes every way a Java resource pack could fail to apply:

  1. Picking packs in game changed almost nothing. reload_packs only reloaded the GUI atlas (and skipped it when the atlas size changed, which any pack with bigger textures causes), item models and languages. Block textures and models only changed after a restart. Sounds, clouds and the world border texture never changed.
  2. HD packs were flattened to 16×16. Every block texture was nearest-resampled to a 16×16 array layer.
  3. Files vanilla stacks were replaced instead of merged. The overlay took each file from the top pack only. So a pack with its own en_us.json (very common) wiped every other string. A sounds.json dropped all vanilla sounds, and a font/default.json or atlases/*.json replaced vanilla's providers and sources. Language files outside the minecraft namespace were never read.
  4. A missing or broken block texture (for example one hidden by a pack's filter) made loading fail; at startup that meant the game would not start.
  5. "Open Pack Folder" only worked on Linux (xdg-open).

What vanilla does (26.3)

  • Minecraft.reloadResourcePacks runs every reload listener: texture atlases and block models (then LevelRenderer.allChanged rebuilds every section), SoundManager, ClientLanguage, FontManager, CloudRenderer (clouds.png) and so on. rollbackResourcePacks goes back to the default packs when loading fails.
  • The block atlas stitches sprites at their own resolution and substitutes MissingTextureAtlasSprite for a texture that fails.
  • Resource stacks (ResourceManager.getResourceStack), bottom pack first:
    • ClientLanguage.loadFrom: every namespace; later packs override keys.
    • SoundManager.prepare / Preparations.handleRegistration: an event's sounds add up across packs unless an entry has "replace": true. The subtitle comes from the registration that created the event. A file Gson rejects is skipped whole.
    • FontManager.loadResourceStack: the providers of every pack, the top pack's first.
    • SpriteSourceList.load: the sources of every pack, bottom up.
  • Util.getPlatform().openPath opens the folder on every OS.

The fix

  • Game::reload_packs rebuilds the overlay, then reloads everything from it:

    • block sprites and models (Assets::reload, keeping the block registry), mesh tables, the shared atlas, item models, sounds (Audio::reload), languages, GUI metadata, clouds and forcefield;
    • the meshers' context is swapped (each mesh job reads it), every loaded section is meshed again, and the renderer is rebuilt with the new textures.

    If loading fails nothing switches. At startup it falls back to the default resources.

  • Sprites::finish sizes the array to the largest texture: a power of two, capped so the top level stays under 256 MiB. Smaller textures are scaled by whole pixels and animations upload at that size. A missing texture gets vanilla's missing texture.

  • packs::build_overlay writes merged files for language, sounds.json, font and atlas stacks. Language::load reads every namespace.

  • "Open Pack Folder" uses open on macOS and explorer on Windows.

How it's tested

  • New vanilla differential harness tools/test_resource_pack_parity.py. It builds three test packs:

    • a folder pack with an overlay for 26.3 and one for an older format;
    • a zip pack with a filter;
    • a pack whose sounds.json Gson rejects.

    The packs carry textures, language files in two namespaces, added and replaced sound events, an event reference, font providers and atlas sources. The oracle VanillaPackResourcesOracle opens them with vanilla's FolderRepositorySource and MultiPackResourceManager, then asks ClientLanguage, SoundManager.prepare, FontManager.loadResourceStack and SpriteSourceList what they read. The probe examples/pack_resources_fixture builds Horizon's overlay and reads it with Horizon's loaders. 76/76 queries match over 4 selections (orders and subsets). The harness found the namespace bug before the fix.

  • Unit tests for the merge rules and the overlay.

  • In game on vscreen, with a 32×32 test pack:

    • picked live in Options → Resource Packs → Done: the floor, the hotbar icon and chat text change at once;
    • the pack's text override shows and all other text stays;
    • the HD detail is kept;
    • starting with the pack already in options.txt gives the same result.
  • Existing harnesses: section_mesh 1,008,927/1,008,927 quads identical, breaking_model, sound_event (27,195 lines), pack_selection and pack_screen all pass. block_particles fails on case 1966 the same way on untouched main (Linux and macOS), so that failure is pre-existing and unrelated.

  • cargo fmt --all --check, cargo clippy --workspace --all-targets -D warnings, cargo test -p horizon-client, python tools/check_public_tree.py.

Not covered yet

  • Broken pack models or blockstates still fail the whole load. Horizon keeps the current resources in game, and falls back to the defaults at startup. Vanilla uses the missing model per block.
  • No loading overlay while reloading (the world redraws as sections are re-meshed). Pack shaders and texts/ are not reloaded.

Fixes #72

🤖 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/85 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/resource-packs-72` --- ### 📝 Commits (1) - [`0d03789`](https://github.com/horizon-rust/horizon/commit/0d0378916b83f96024cde11b0d29c5a4626424cf) Resource packs: reload everything in game and merge stacked files like vanilla (#72) ### 📊 Changes **14 files changed** (+960 additions, -166 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-client/examples/pack_resources_fixture.rs` (+92 -0) 📝 `crates/horizon-client/src/assets.rs` (+33 -4) 📝 `crates/horizon-client/src/audio.rs` (+10 -0) 📝 `crates/horizon-client/src/game.rs` (+58 -35) 📝 `crates/horizon-client/src/game/options.rs` (+2 -4) 📝 `crates/horizon-client/src/game/packs.rs` (+69 -53) 📝 `crates/horizon-client/src/gfx.rs` (+5 -2) 📝 `crates/horizon-client/src/lang.rs` (+26 -7) 📝 `crates/horizon-client/src/packs.rs` (+208 -5) 📝 `crates/horizon-client/src/sound_events.rs` (+38 -22) 📝 `crates/horizon-client/src/sprites.rs` (+86 -10) 📝 `crates/horizon-client/src/streaming.rs` (+35 -24) ➕ `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaPackResourcesOracle.java` (+160 -0) ➕ `tools/test_resource_pack_parity.py` (+138 -0) </details> ### 📄 Description ## What was wrong The issue has no description and the reporter hasn't said which pack they used (asked in #horizon-chat), so this fixes every way a Java resource pack could fail to apply: 1. **Picking packs in game changed almost nothing.** `reload_packs` only reloaded the GUI atlas (and skipped it when the atlas size changed, which any pack with bigger textures causes), item models and languages. Block textures and models only changed after a restart. Sounds, clouds and the world border texture never changed. 2. **HD packs were flattened to 16×16.** Every block texture was nearest-resampled to a 16×16 array layer. 3. **Files vanilla stacks were replaced instead of merged.** The overlay took each file from the top pack only. So a pack with its own `en_us.json` (very common) wiped every other string. A `sounds.json` dropped all vanilla sounds, and a `font/default.json` or `atlases/*.json` replaced vanilla's providers and sources. Language files outside the `minecraft` namespace were never read. 4. A missing or broken block texture (for example one hidden by a pack's `filter`) made loading fail; at startup that meant the game would not start. 5. "Open Pack Folder" only worked on Linux (`xdg-open`). ## What vanilla does (26.3) - `Minecraft.reloadResourcePacks` runs every reload listener: texture atlases and block models (then `LevelRenderer.allChanged` rebuilds every section), `SoundManager`, `ClientLanguage`, `FontManager`, `CloudRenderer` (`clouds.png`) and so on. `rollbackResourcePacks` goes back to the default packs when loading fails. - The block atlas stitches sprites at their own resolution and substitutes `MissingTextureAtlasSprite` for a texture that fails. - Resource stacks (`ResourceManager.getResourceStack`), bottom pack first: - `ClientLanguage.loadFrom`: every namespace; later packs override keys. - `SoundManager.prepare` / `Preparations.handleRegistration`: an event's sounds add up across packs unless an entry has `"replace": true`. The subtitle comes from the registration that created the event. A file Gson rejects is skipped whole. - `FontManager.loadResourceStack`: the providers of every pack, the top pack's first. - `SpriteSourceList.load`: the sources of every pack, bottom up. - `Util.getPlatform().openPath` opens the folder on every OS. ## The fix - `Game::reload_packs` rebuilds the overlay, then reloads everything from it: - block sprites and models (`Assets::reload`, keeping the block registry), mesh tables, the shared atlas, item models, sounds (`Audio::reload`), languages, GUI metadata, clouds and forcefield; - the meshers' context is swapped (each mesh job reads it), every loaded section is meshed again, and the renderer is rebuilt with the new textures. If loading fails nothing switches. At startup it falls back to the default resources. - `Sprites::finish` sizes the array to the largest texture: a power of two, capped so the top level stays under 256 MiB. Smaller textures are scaled by whole pixels and animations upload at that size. A missing texture gets vanilla's missing texture. - `packs::build_overlay` writes merged files for language, `sounds.json`, font and atlas stacks. `Language::load` reads every namespace. - "Open Pack Folder" uses `open` on macOS and `explorer` on Windows. ## How it's tested - **New vanilla differential harness** `tools/test_resource_pack_parity.py`. It builds three test packs: - a folder pack with an overlay for 26.3 and one for an older format; - a zip pack with a `filter`; - a pack whose `sounds.json` Gson rejects. The packs carry textures, language files in two namespaces, added and replaced sound events, an event reference, font providers and atlas sources. The oracle `VanillaPackResourcesOracle` opens them with vanilla's `FolderRepositorySource` and `MultiPackResourceManager`, then asks `ClientLanguage`, `SoundManager.prepare`, `FontManager.loadResourceStack` and `SpriteSourceList` what they read. The probe `examples/pack_resources_fixture` builds Horizon's overlay and reads it with Horizon's loaders. **76/76 queries match over 4 selections** (orders and subsets). The harness found the namespace bug before the fix. - Unit tests for the merge rules and the overlay. - In game on vscreen, with a 32×32 test pack: - picked live in Options → Resource Packs → Done: the floor, the hotbar icon and chat text change at once; - the pack's text override shows and all other text stays; - the HD detail is kept; - starting with the pack already in options.txt gives the same result. - Existing harnesses: section_mesh 1,008,927/1,008,927 quads identical, breaking_model, sound_event (27,195 lines), pack_selection and pack_screen all pass. `block_particles` fails on case 1966 the same way on untouched `main` (Linux and macOS), so that failure is pre-existing and unrelated. - `cargo fmt --all --check`, `cargo clippy --workspace --all-targets -D warnings`, `cargo test -p horizon-client`, `python tools/check_public_tree.py`. ## Not covered yet - Broken pack **models or blockstates** still fail the whole load. Horizon keeps the current resources in game, and falls back to the defaults at startup. Vanilla uses the missing model per block. - No loading overlay while reloading (the world redraws as sections are re-meshed). Pack shaders and `texts/` are not reloaded. Fixes #72 🤖 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:54:55 +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#2318
No description provided.