[PR #5267] [MERGED] fix(mods): items-only content mods join the content identity check #6176

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

📋 Pull Request Information

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

Base: main ← Head: fix/content-identity-items


📝 Commits (2)

  • 8baff76 fix(mods): items-only content mods join the content identity check
  • 03e50c4 Merge main into #5267 (main builds again after #5251)

📊 Changes

3 files changed (+109 additions, -36 deletions)

View changed files

📝 crates/horizon-client/src/content_identity.rs (+75 -31)
📝 crates/horizon-client/src/mod_content.rs (+3 -5)
📝 crates/horizon-client/src/mod_content_tests.rs (+31 -0)

📄 Description

What and why

A content mod that adds only items gives them item network ids after vanilla's (mod_content.rs, the registries.json table)
But the content root only writes the identity marker when a mod adds blocks or mob effects, so the server never sends the horizon:block_registry challenge
And even with the marker, the identity hashed the block states and the mod effects, never the mod items
Two Horizons with different item sets joined without a warning and read each other's item stacks by the wrong ids

Now the marker is written when the plan has blocks, items or effects
The identity hashes the mods' entries of minecraft:item and minecraft:mob_effect from registries.json, each tagged with its registry name
A root without mod entries keeps its block-only identity, so vanilla roots are unchanged

The new content root test fails on main with prepared data (no marker for an item-only mod) and passes here
The unit tests cover mod items in the hash, that the same id and name in two registries hash apart, and that a root with only minecraft: entries keeps exactly its block hash

Known gaps
Every root with mod items or mod effects gets a new identity once
That includes roots with only mod blocks, since a mod block gets its item by default (item defaults to true in horizon-mods)
An old build and a new build with the same content mods now reject each other with the content mods mismatch message
That happens for an old client on a new server whose mods add items, and for a new client on an old server with mod blocks
A dedicated server and a client updated by the launcher can end up like that
It fails safely with a clean disconnect, not with wrong ids
The check only runs when the server's root has mod content, so a server without mods and a client with items-only mods still join without one
Vanilla ids agree there, since mod ids come after them

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

Item stacks carry the item by its id in the static item registry: Item.STREAM_CODEC = ByteBufCodecs.holderRegistry(Registries.ITEM) (net/minecraft/world/item/Item.java:116), read in ItemStack.OPTIONAL_STREAM_CODEC (net/minecraft/world/item/ItemStack.java:180)
ByteBufCodecs.holderRegistry maps ids through asHolderIdMap with no sync (net/minecraft/network/codec/ByteBufCodecs.java:665)
The item registry is not in RegistryDataLoader.SYNCHRONIZED_REGISTRIES (net/minecraft/resources/RegistryDataLoader.java:164), so ClientboundRegistryDataPacket never carries it
Vanilla has no content mods, so the identity check itself is Horizon-only

Other projects' code

none

Self-check

Check Result
Scope ✅ 3 files, +109 −36
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (56 s)
rustfmt ✅ (8 s)
clippy ✅ (2 min 2 s)
tests: horizon-client ✅ 1343 passed (5 min 20 s)
doc tests ✅ 0 passed (1 s)
content root tests ✅ 8 passed (1 min 3 s)
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)

🔄 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/5267 **Author:** [@reservedbytes](https://github.com/reservedbytes) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/content-identity-items` --- ### 📝 Commits (2) - [`8baff76`](https://github.com/horizon-rust/horizon/commit/8baff760da3b61af6a4f7529335ef4c72c52782b) fix(mods): items-only content mods join the content identity check - [`03e50c4`](https://github.com/horizon-rust/horizon/commit/03e50c439d4a0d0c1862c05edb77f6cb39620e0f) Merge main into #5267 (main builds again after #5251) ### 📊 Changes **3 files changed** (+109 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/content_identity.rs` (+75 -31) 📝 `crates/horizon-client/src/mod_content.rs` (+3 -5) 📝 `crates/horizon-client/src/mod_content_tests.rs` (+31 -0) </details> ### 📄 Description ## What and why A content mod that adds only items gives them item network ids after vanilla's (`mod_content.rs`, the `registries.json` table) But the content root only writes the identity marker when a mod adds blocks or mob effects, so the server never sends the `horizon:block_registry` challenge And even with the marker, the identity hashed the block states and the mod effects, never the mod items Two Horizons with different item sets joined without a warning and read each other's item stacks by the wrong ids Now the marker is written when the plan has blocks, items or effects The identity hashes the mods' entries of `minecraft:item` and `minecraft:mob_effect` from `registries.json`, each tagged with its registry name A root without mod entries keeps its block-only identity, so vanilla roots are unchanged The new content root test fails on `main` with prepared data (no marker for an item-only mod) and passes here The unit tests cover mod items in the hash, that the same id and name in two registries hash apart, and that a root with only `minecraft:` entries keeps exactly its block hash Known gaps Every root with mod items or mod effects gets a new identity once That includes roots with only mod blocks, since a mod block gets its item by default (`item` defaults to `true` in `horizon-mods`) An old build and a new build with the same content mods now reject each other with the content mods mismatch message That happens for an old client on a new server whose mods add items, and for a new client on an old server with mod blocks A dedicated server and a client updated by the launcher can end up like that It fails safely with a clean disconnect, not with wrong ids The check only runs when the server's root has mod content, so a server without mods and a client with items-only mods still join without one Vanilla ids agree there, since mod ids come after them ## 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 ## Vanilla reference Item stacks carry the item by its id in the static item registry: `Item.STREAM_CODEC = ByteBufCodecs.holderRegistry(Registries.ITEM)` (`net/minecraft/world/item/Item.java:116`), read in `ItemStack.OPTIONAL_STREAM_CODEC` (`net/minecraft/world/item/ItemStack.java:180`) `ByteBufCodecs.holderRegistry` maps ids through `asHolderIdMap` with no sync (`net/minecraft/network/codec/ByteBufCodecs.java:665`) The item registry is not in `RegistryDataLoader.SYNCHRONIZED_REGISTRIES` (`net/minecraft/resources/RegistryDataLoader.java:164`), so `ClientboundRegistryDataPacket` never carries it Vanilla has no content mods, so the identity check itself is Horizon-only ## Other projects' code none ## Self-check | Check | Result | | --- | --- | | Scope | ✅ 3 files, +109 −36 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (56 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ (2 min 2 s) | | tests: horizon-client | ✅ 1343 passed (5 min 20 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ✅ 8 passed (1 min 3 s) | | 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) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:15:32 +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#6176
No description provided.