[PR #4930] [MERGED] Send custom_model_data and item_model to the client (#4916) #5949

Closed
opened 2026-11-03 05:16:08 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4930
Author: @k3yh
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/item-custom-model-data


📝 Commits (1)

  • 0e076e0 Send custom_model_data and item_model to the client (#4916)

📊 Changes

2 files changed (+123 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/item_sync.rs (+61 -0)
📝 crates/horizon-client/src/lan/guest.rs (+62 -0)

📄 Description

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

What and why

Fixes #4916.

Single player's window joins the integrated server as a player, and gets its stacks through stack_to_network (lan/guest.rs), as LAN guests do. That function writes a fixed list of components (damage, enchantments, names, potions, trims...). minecraft:custom_model_data and minecraft:item_model were not on it, so the server kept them (/data get shows them) but the client's item model never saw them:

  • custom_model_data tints stayed on their default,
  • a select (or condition, range_dispatch) on custom_model_data took its fallback,
  • an item_model override on a stack was ignored. This is not in the issue, but it has the same cause.

The item model side was already right. I checked it with a temporary test that fed a stack with the component through stack_view and ItemModels::resolve: red tint, gold model.

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

Change

network_stack now also writes:

  • item_model as its id (ITEM_MODEL, Component::Ident),
  • custom_model_data read from its saved form into Component::CustomModelData, whose stream codec the protocol crate already had:
    • floats, flags and strings as lists,
    • colors as ExtraCodecs.RGB_COLOR_CODEC reads them: an int, or three floats made into an opaque colour with ARGB.as8BitChannel.
    • Int and byte arrays are read as lists, since NbtOps saves a list of ints or bytes that way.

The client side (item_sync::components_tag) already turned both back into components.

Vanilla reference

  • DataComponents.CUSTOM_MODEL_DATA / CustomModelData.CODEC and STREAM_CODEC.
  • DataComponents.ITEM_MODEL (Identifier.STREAM_CODEC).
  • ExtraCodecs.RGB_COLOR_CODEC, ARGB.colorFromFloat.
  • Vanilla's server sends a stack's whole component patch (DataComponentPatch.STREAM_CODEC); Horizon's sends the components it encodes.

Test

item_sync::tests::model_components_cross_the_wire:

  • A stick goes through stack_to_network and from_network, given as /give parses it: item_model='minecraft:emerald' and custom_model_data with a float, a flag, a string, an int colour and a float-triple colour.
  • The client stack has both components back, and the float triple arrives as 0xFF00FF00.
  • It fails on main (the stack arrives with no components) and passes with this change.

In game:

  • The test machine was Windows 11, RX 7900 XT, Vulkan, the 2026-10-30 nightly (1da354b) against this branch, single player and creative.
  • I used a resource pack with two item definitions:
    • stick.json: tints: [{custom_model_data, index 0, default 0x00FF00}].
    • diamond.json: select on custom_model_data index 0, with "gold" mapped to item/gold_ingot and item/diamond as the fallback.
  • Then I gave these items, from left to right:
    1. stick
    2. stick[custom_model_data={colors:[16711680]}]
    3. diamond
    4. diamond[custom_model_data={strings:['gold']}]
    5. stick[item_model='minecraft:emerald']
    6. stick[custom_model_data={colors:[[0.0f,0.0f,1.0f]]}]

Not checked: a LAN guest, a dedicated server and a vanilla client joining Horizon. They use the same stack_to_network path, so they should get the same fix. Content mods (--dev-mod, as in the issue) were not checked either; they go through the same function.

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on DESKTOP-S9O4938, against upstream/main at 3dc5b432f, 5 min 49 s)

Check Result
Scope ✅ 2 files, +123 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 486 run, FAILED (errors=2, skipped=1) (48 s)
rustfmt ✅ (7 s)
Rust ⚠️ 1.98.1 is older than CI's stable (1.99): clippy may flag lints CI doesn't, update with rustup update
clippy ✅ (55 s)
tests: horizon-client ❌ 897 passed, 1 failed (3 min 54 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root 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)

The three failures are in code this PR doesn't touch, and each one also fails on main (3dc5b432f) on this machine:

  • motion::tests::a_swimming_passenger_sits_up_even_when_standing_does_not_fit
  • test_port_ledger, which cannot import tests.test_class_index
  • test_perf_bench, whose windows_version() gets nothing back from cmd /C ver on a Spanish Windows.

Screenshots

Before (nightly 2026-10-30), the components are lost: everything shows its default.

before

After: red tint, gold from the select, the emerald model, blue from a float colour.

after

First person, holding the diamond with strings:['gold']:

after, held

🤖 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/4930 **Author:** [@k3yh](https://github.com/k3yh) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/item-custom-model-data` --- ### 📝 Commits (1) - [`0e076e0`](https://github.com/horizon-rust/horizon/commit/0e076e0559e502619b43dc339dd459047aed16f9) Send custom_model_data and item_model to the client (#4916) ### 📊 Changes **2 files changed** (+123 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/item_sync.rs` (+61 -0) 📝 `crates/horizon-client/src/lan/guest.rs` (+62 -0) </details> ### 📄 Description > 🤖 Opened by k3yh's AI agent (Claude Code, Claude Opus 5.5), not by k3yh personally. ## What and why Fixes #4916. Single player's window joins the integrated server as a player, and gets its stacks through `stack_to_network` (`lan/guest.rs`), as LAN guests do. That function writes a fixed list of components (damage, enchantments, names, potions, trims...). `minecraft:custom_model_data` and `minecraft:item_model` were not on it, so the server kept them (`/data get` shows them) but the client's item model never saw them: - `custom_model_data` tints stayed on their `default`, - a `select` (or `condition`, `range_dispatch`) on `custom_model_data` took its fallback, - an `item_model` override on a stack was ignored. This is not in the issue, but it has the same cause. The item model side was already right. I checked it with a temporary test that fed a stack with the component through `stack_view` and `ItemModels::resolve`: red tint, gold model. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [x] 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 ## Change `network_stack` now also writes: - `item_model` as its id (`ITEM_MODEL`, `Component::Ident`), - `custom_model_data` read from its saved form into `Component::CustomModelData`, whose stream codec the protocol crate already had: - `floats`, `flags` and `strings` as lists, - `colors` as `ExtraCodecs.RGB_COLOR_CODEC` reads them: an int, or three floats made into an opaque colour with `ARGB.as8BitChannel`. - Int and byte arrays are read as lists, since `NbtOps` saves a list of ints or bytes that way. The client side (`item_sync::components_tag`) already turned both back into components. ## Vanilla reference - `DataComponents.CUSTOM_MODEL_DATA` / `CustomModelData.CODEC` and `STREAM_CODEC`. - `DataComponents.ITEM_MODEL` (`Identifier.STREAM_CODEC`). - `ExtraCodecs.RGB_COLOR_CODEC`, `ARGB.colorFromFloat`. - Vanilla's server sends a stack's whole component patch (`DataComponentPatch.STREAM_CODEC`); Horizon's sends the components it encodes. ## Test `item_sync::tests::model_components_cross_the_wire`: - A stick goes through `stack_to_network` and `from_network`, given as `/give` parses it: `item_model='minecraft:emerald'` and `custom_model_data` with a float, a flag, a string, an int colour and a float-triple colour. - The client stack has both components back, and the float triple arrives as `0xFF00FF00`. - It fails on main (the stack arrives with no components) and passes with this change. **In game:** - The test machine was Windows 11, RX 7900 XT, Vulkan, the 2026-10-30 nightly (1da354b) against this branch, single player and creative. - I used a resource pack with two item definitions: - `stick.json`: `tints: [{custom_model_data, index 0, default 0x00FF00}]`. - `diamond.json`: `select` on `custom_model_data` index 0, with `"gold"` mapped to `item/gold_ingot` and `item/diamond` as the fallback. - Then I gave these items, from left to right: 1. `stick` 2. `stick[custom_model_data={colors:[16711680]}]` 3. `diamond` 4. `diamond[custom_model_data={strings:['gold']}]` 5. `stick[item_model='minecraft:emerald']` 6. `stick[custom_model_data={colors:[[0.0f,0.0f,1.0f]]}]` Not checked: a LAN guest, a dedicated server and a vanilla client joining Horizon. They use the same `stack_to_network` path, so they should get the same fix. Content mods (`--dev-mod`, as in the issue) were not checked either; they go through the same function. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on DESKTOP-S9O4938, against upstream/main at 3dc5b432f, 5 min 49 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +123 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 486 run, FAILED (errors=2, skipped=1) (48 s) | | rustfmt | ✅ (7 s) | | Rust | ⚠️ 1.98.1 is older than CI's stable (1.99): clippy may flag lints CI doesn't, update with `rustup update` | | clippy | ✅ (55 s) | | tests: horizon-client | ❌ 897 passed, 1 failed (3 min 54 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root 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) | The three failures are in code this PR doesn't touch, and each one also fails on main (3dc5b432f) on this machine: - `motion::tests::a_swimming_passenger_sits_up_even_when_standing_does_not_fit` - `test_port_ledger`, which cannot import `tests.test_class_index` - `test_perf_bench`, whose `windows_version()` gets nothing back from `cmd /C ver` on a Spanish Windows. ## Screenshots Before (nightly 2026-10-30), the components are lost: everything shows its default. ![before](https://raw.githubusercontent.com/k3yh/horizon/pr-assets-4916/4916-before.png) After: red tint, gold from the select, the emerald model, blue from a float colour. ![after](https://raw.githubusercontent.com/k3yh/horizon/pr-assets-4916/4916-after.png) First person, holding the diamond with `strings:['gold']`: ![after, held](https://raw.githubusercontent.com/k3yh/horizon/pr-assets-4916/4916-after-hand.png) 🤖 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 05:16:08 +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#5949
No description provided.