[PR #7059] [MERGED] A pack's blockstate file stacks over vanilla's, state by state #7305

Closed
opened 2026-11-03 06:37:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7059
Author: @breachato
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/7013-blockstate-stack


📝 Commits (2)

  • 82d5ef2 A pack's blockstate file stacks over vanilla's, state by state
  • 82c4c75 Merge main into #7059

📊 Changes

4 files changed (+177 additions, -36 deletions)

View changed files

📝 crates/horizon-client-render/src/models.rs (+10 -1)
📝 crates/horizon-client-render/src/models/catalog.rs (+120 -33)
📝 crates/horizon-client-render/src/packs.rs (+45 -1)
📝 crates/horizon-client-render/src/packs/cache.rs (+2 -1)

📄 Description

🤖 Opened by breachato's AI agent (Claude Code, Claude Opus 5.5), not by breachato personally.

What and why

Fixes #7013.

Vanilla reads a blockstate file as a resource stack. BlockStateModelLoader.loadBlockStateDefinitionStack instantiates the definition from every pack that has the file, bottom first, and a higher pack replaces only the states it binds (putAll). CraftEngine relies on that: its oak_fence_gate.json defines only the 16 powered=true variants, and every other gate state keeps vanilla's model.

Horizon's overlay stacked only lang, font, atlases and sounds.json, so the top pack's blockstate file replaced vanilla's whole. Every state it didn't cover was left unbound. prepare_models then failed on the unbound gallery state (oak_fence_gate[facing=west,open=true]), which dropped the whole server pack with "unbound gallery block state". Fixing only the gallery would have loaded the pack but left ordinary gates invisible, because the mesher skips unbound states.

The fix follows the issue's suggestion:

  • Overlay (packs.rs). assets/*/blockstates/*.json is now a stacked kind (Merge::BlockStates). With more than one parseable definition, vanilla's first, the file becomes {"horizon:layers": [...]} with each definition as its pack wrote it, bottom first. A single definition stays the file as it is. A layer that doesn't parse is skipped, as vanilla logs and skips it.
  • Catalog (models/catalog.rs). definition_layers reads those layers back. Each one is parsed and bound on its own, since concatenating the files would break BlockStateDefinition::bind's overlap rules within one file. topmost gives each state the highest layer that binds it. Every layer gets its own CompiledChoices, and its variants are baked. A layer that doesn't read or bind is logged and left out; with none left, the block gets no model, as before.
  • Gallery (models.rs). A gallery state without a model is logged and skipped, as the mesher does, so one unbound state can't drop a whole pack.
  • Overlay cache (packs/cache.rs). VERSION goes to 7, so overlays built with the old rule are rebuilt.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

  • net.minecraft.client.resources.model.BlockStateModelLoader.loadBlockStateDefinitionStack: one definition per resource in getResourceStack, bottom first. Each is instantiated and putAll into the state map, and one that fails is logged and skipped.

Tests

  • models::catalog::tests::a_partial_pack_blockstate_keeps_vanilla_for_the_other_states: vanilla's gate definition plus a pack's powered=true-only one. powered=false keeps layer 0 and powered=true takes layer 1.
  • packs::tests::stacked_resources_merge_like_vanilla covers the new kind: layers kept bottom first, a bad one skipped, a single definition unchanged.

Not run against the CraftEngine pack or a Paper server here. The issue's two-file pack, as a world's own pack, is the quick end-to-end check: it should load, and fence gates should keep their models.

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on DESKTOP-G0M27UC, against upstream/main at 26b9c0c9b, 9 min 58 s)

Check Result
Scope ✅ 4 files, +177 −36
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 611 passed (4 min 35 s)
rustfmt ✅ (22 s)
clippy ✅ (1 min 6 s)
tests: horizon-client-render ✅ 1127 passed (3 min 43 s)
doc tests ✅ 0 passed (8 s)
content root tests ➖ content root untouched
mod API up to date ➖ native hooks untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 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/7059 **Author:** [@breachato](https://github.com/breachato) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/7013-blockstate-stack` --- ### 📝 Commits (2) - [`82d5ef2`](https://github.com/horizon-rust/horizon/commit/82d5ef26724bfa06aded45940a8c49f2ddc85aa9) A pack's blockstate file stacks over vanilla's, state by state - [`82c4c75`](https://github.com/horizon-rust/horizon/commit/82c4c758c510a5de4df53d9f225b53095b2bd4d8) Merge main into #7059 ### 📊 Changes **4 files changed** (+177 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/models.rs` (+10 -1) 📝 `crates/horizon-client-render/src/models/catalog.rs` (+120 -33) 📝 `crates/horizon-client-render/src/packs.rs` (+45 -1) 📝 `crates/horizon-client-render/src/packs/cache.rs` (+2 -1) </details> ### 📄 Description > 🤖 Opened by breachato's AI agent (Claude Code, Claude Opus 5.5), not by breachato personally. ## What and why Fixes #7013. Vanilla reads a blockstate file as a resource stack. `BlockStateModelLoader.loadBlockStateDefinitionStack` instantiates the definition from every pack that has the file, bottom first, and a higher pack replaces only the states it binds (`putAll`). CraftEngine relies on that: its `oak_fence_gate.json` defines only the 16 `powered=true` variants, and every other gate state keeps vanilla's model. Horizon's overlay stacked only `lang`, `font`, `atlases` and `sounds.json`, so the top pack's blockstate file replaced vanilla's whole. Every state it didn't cover was left unbound. `prepare_models` then failed on the unbound gallery state (`oak_fence_gate[facing=west,open=true]`), which dropped the whole server pack with "unbound gallery block state". Fixing only the gallery would have loaded the pack but left ordinary gates invisible, because the mesher skips unbound states. The fix follows the issue's suggestion: - **Overlay (`packs.rs`).** `assets/*/blockstates/*.json` is now a stacked kind (`Merge::BlockStates`). With more than one parseable definition, vanilla's first, the file becomes `{"horizon:layers": [...]}` with each definition as its pack wrote it, bottom first. A single definition stays the file as it is. A layer that doesn't parse is skipped, as vanilla logs and skips it. - **Catalog (`models/catalog.rs`).** `definition_layers` reads those layers back. Each one is parsed and bound on its own, since concatenating the files would break `BlockStateDefinition::bind`'s overlap rules within one file. `topmost` gives each state the highest layer that binds it. Every layer gets its own `CompiledChoices`, and its variants are baked. A layer that doesn't read or bind is logged and left out; with none left, the block gets no model, as before. - **Gallery (`models.rs`).** A gallery state without a model is logged and skipped, as the mesher does, so one unbound state can't drop a whole pack. - **Overlay cache (`packs/cache.rs`).** `VERSION` goes to 7, so overlays built with the old rule are rebuilt. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference - `net.minecraft.client.resources.model.BlockStateModelLoader.loadBlockStateDefinitionStack`: one definition per resource in `getResourceStack`, bottom first. Each is instantiated and `putAll` into the state map, and one that fails is logged and skipped. ## Tests - `models::catalog::tests::a_partial_pack_blockstate_keeps_vanilla_for_the_other_states`: vanilla's gate definition plus a pack's `powered=true`-only one. `powered=false` keeps layer 0 and `powered=true` takes layer 1. - `packs::tests::stacked_resources_merge_like_vanilla` covers the new kind: layers kept bottom first, a bad one skipped, a single definition unchanged. Not run against the CraftEngine pack or a Paper server here. The issue's two-file pack, as a world's own pack, is the quick end-to-end check: it should load, and fence gates should keep their models. ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on DESKTOP-G0M27UC, against upstream/main at 26b9c0c9b, 9 min 58 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +177 −36 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 611 passed (4 min 35 s) | | rustfmt | ✅ (22 s) | | clippy | ✅ (1 min 6 s) | | tests: horizon-client-render | ✅ 1127 passed (3 min 43 s) | | doc tests | ✅ 0 passed (8 s) | | content root tests | ➖ content root untouched | | mod API up to date | ➖ native hooks untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 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 06:37:27 +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#7305
No description provided.