[PR #3675] [MERGED] Mooshrooms keep their colour: save Type, sync DATA_TYPE at 18 #5140

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3675
Author: @d3grando
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3236


📝 Commits (3)

  • e8c1a79 Mooshrooms keep their colour: save Type, sync DATA_TYPE at 18
  • 34c77f9 lan_e2e: check that a mooshroom's colour reaches the guest
  • ef3163c Merge origin/main into fix-3236

📊 Changes

5 files changed (+92 additions, -8 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+23 -1)
📝 crates/horizon-client/src/game/lan.rs (+3 -3)
📝 crates/horizon-client/src/game/remote_mob_data.rs (+18 -2)
📝 tools/lan_e2e.py (+46 -0)
📝 tools/port_map/animal-1.tsv (+2 -2)

📄 Description

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

Fixes #3236

What and why

Two separate bugs made a mooshroom lose its colour.

1. The colour went to the wrong synched-data slot. MushroomCow.DATA_TYPE is entry 18. AgeableMob defines two entries (DATA_BABY_ID at 16, AGE_LOCKED at 17), and AbstractCow adds none. Horizon read and wrote the colour at 17:

  • Horizon client on a vanilla server (the report): the server sends the colour at 18, which Horizon ignored. When MushroomCow.thunderHit turned a mooshroom brown, it stayed red on screen.
  • Horizon host with vanilla clients: the host sent an INT at 17, where vanilla expects AGE_LOCKED's BOOLEAN. Vanilla's SynchedEntityData.assignValue throws Invalid entity data item type for field 17 on that mismatch, so a brown mooshroom would break a vanilla client's connection. I haven't tested this case with a real vanilla client. It follows from the bytecode.

Fix: game/lan.rs (sender) and game/remote_mob_data.rs (receiver) now both use 18. Foxes, pandas and sheep already use 18+ for their own entries after the same two AgeableMob entries.

2. Type was never saved or loaded. MushroomCow.addAdditionalSaveData and readAdditionalSaveData had no port. These are the missing rows in the port map. A brown mooshroom, whether summoned with {Type:"brown"}, turned by lightning or loaded from a vanilla save, came back red. /data get kept showing the stale Type from the raw tag. entity_nbt.rs now writes Type (red/brown) from the live mob. On load it reads Type back, and a missing or unknown value falls back to Variant.DEFAULT (red), as vanilla does. stew_effects is not modelled yet (flower feeding is a separate missing row), so it is still not written. The two tools/port_map/animal-1.tsv rows change from missing to port with that gap noted.

Vanilla reference

  • net.minecraft.world.entity.animal.cow.MushroomCow.addAdditionalSaveData / readAdditionalSaveData: Type through MushroomCow.Variant.CODEC (red, brown), .orElse(Variant.DEFAULT) on read.
  • MushroomCow.<clinit> defines DATA_TYPE (INT). AgeableMob.<clinit> defines DATA_BABY_ID and AGE_LOCKED (both BOOLEAN), so DATA_TYPE is 18.
  • SynchedEntityData.assignValue: throws IllegalStateException on a serializer mismatch.

All checked with javap on the 26.3 jars.

Tests (fail before, pass after)

The fix's code was reverted with the tests kept:

test entity_nbt::sheep_nbt_tests::foxes_mooshrooms_rabbits_and_goats_keep_their_kind ... FAILED
  left: None
 right: Some("brown")
test game::remote_mob_data::tests::a_mooshroom_takes_its_type_after_the_age_lock ... FAILED
  left: 0
 right: 1

With the fix:

test entity_nbt::sheep_nbt_tests::foxes_mooshrooms_rabbits_and_goats_keep_their_kind ... ok
test game::remote_mob_data::tests::a_mooshroom_takes_its_type_after_the_age_lock ... ok
test result: ok. 13 passed (entity_nbt); 12 passed (remote_mob_data)

In game

  • Vanilla 26.3 dedicated server (the reported case; local, offline mode, commands over RCON): I summoned one mooshroom with {Type:"brown"} and one with {Type:"red"}, then hit the red one with summon lightning_bolt. The server's data get then reported both as brown.
    • Before: the Horizon client drew both mooshrooms red, before and after the strike.
    • After: the brown one is drawn brown from the start, and the red one turns brown when the bolt hits.
  • Single player (integrated server): same two summons, then a bolt on the red one, then save, quit and reopen the world.
    • Before: the {Type:"brown"} mooshroom was drawn red. The struck one turned brown but came back red after reopening the world, and data get … Type kept printing the stale summoned value.
    • After: both are brown before and after reopening the world, and data get … Type prints brown for both.

Self-check

tools/pr_ready.py and tools/parity.py don't run on Windows (signal.SIGHUP). These ran instead:

cargo fmt --all -- --check                                                          # clean
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings          # clean
cargo test -p horizon-client --features mods --lib entity_nbt                        # 13 passed
cargo test -p horizon-client --features mods --bin horizon-client remote_mob_data    # 12 passed

test_save_roundtrip_parity.py already has a {Type:"brown"} mooshroom in its scene. It passed before because the raw tag carried Type through. I didn't run it here because it needs Linux or macOS.

🤖 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/3675 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3236` --- ### 📝 Commits (3) - [`e8c1a79`](https://github.com/horizon-rust/horizon/commit/e8c1a797c8437d0906d9c0eb1a9f91ff2a7bc490) Mooshrooms keep their colour: save Type, sync DATA_TYPE at 18 - [`34c77f9`](https://github.com/horizon-rust/horizon/commit/34c77f9eaca40af4dfb08ff89f0d5c85e7c0814b) lan_e2e: check that a mooshroom's colour reaches the guest - [`ef3163c`](https://github.com/horizon-rust/horizon/commit/ef3163c2444e4286daf7a2b2d89d1a725f5d1afd) Merge origin/main into fix-3236 ### 📊 Changes **5 files changed** (+92 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+23 -1) 📝 `crates/horizon-client/src/game/lan.rs` (+3 -3) 📝 `crates/horizon-client/src/game/remote_mob_data.rs` (+18 -2) 📝 `tools/lan_e2e.py` (+46 -0) 📝 `tools/port_map/animal-1.tsv` (+2 -2) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. Fixes #3236 ## What and why Two separate bugs made a mooshroom lose its colour. **1. The colour went to the wrong synched-data slot.** `MushroomCow.DATA_TYPE` is entry **18**. `AgeableMob` defines two entries (`DATA_BABY_ID` at 16, `AGE_LOCKED` at 17), and `AbstractCow` adds none. Horizon read and wrote the colour at 17: - **Horizon client on a vanilla server (the report):** the server sends the colour at 18, which Horizon ignored. When `MushroomCow.thunderHit` turned a mooshroom brown, it stayed red on screen. - **Horizon host with vanilla clients:** the host sent an `INT` at 17, where vanilla expects `AGE_LOCKED`'s `BOOLEAN`. Vanilla's `SynchedEntityData.assignValue` throws `Invalid entity data item type for field 17` on that mismatch, so a brown mooshroom would break a vanilla client's connection. I haven't tested this case with a real vanilla client. It follows from the bytecode. Fix: `game/lan.rs` (sender) and `game/remote_mob_data.rs` (receiver) now both use 18. Foxes, pandas and sheep already use 18+ for their own entries after the same two `AgeableMob` entries. **2. `Type` was never saved or loaded.** `MushroomCow.addAdditionalSaveData` and `readAdditionalSaveData` had no port. These are the `missing` rows in the port map. A brown mooshroom, whether summoned with `{Type:"brown"}`, turned by lightning or loaded from a vanilla save, came back red. `/data get` kept showing the stale `Type` from the raw tag. `entity_nbt.rs` now writes `Type` (`red`/`brown`) from the live mob. On load it reads `Type` back, and a missing or unknown value falls back to `Variant.DEFAULT` (red), as vanilla does. `stew_effects` is not modelled yet (flower feeding is a separate missing row), so it is still not written. The two `tools/port_map/animal-1.tsv` rows change from `missing` to `port` with that gap noted. ## Vanilla reference - `net.minecraft.world.entity.animal.cow.MushroomCow.addAdditionalSaveData` / `readAdditionalSaveData`: `Type` through `MushroomCow.Variant.CODEC` (`red`, `brown`), `.orElse(Variant.DEFAULT)` on read. - `MushroomCow.<clinit>` defines `DATA_TYPE` (INT). `AgeableMob.<clinit>` defines `DATA_BABY_ID` and `AGE_LOCKED` (both BOOLEAN), so `DATA_TYPE` is 18. - `SynchedEntityData.assignValue`: throws `IllegalStateException` on a serializer mismatch. All checked with `javap` on the 26.3 jars. ## Tests (fail before, pass after) The fix's code was reverted with the tests kept: ``` test entity_nbt::sheep_nbt_tests::foxes_mooshrooms_rabbits_and_goats_keep_their_kind ... FAILED left: None right: Some("brown") test game::remote_mob_data::tests::a_mooshroom_takes_its_type_after_the_age_lock ... FAILED left: 0 right: 1 ``` With the fix: ``` test entity_nbt::sheep_nbt_tests::foxes_mooshrooms_rabbits_and_goats_keep_their_kind ... ok test game::remote_mob_data::tests::a_mooshroom_takes_its_type_after_the_age_lock ... ok test result: ok. 13 passed (entity_nbt); 12 passed (remote_mob_data) ``` ## In game - **Vanilla 26.3 dedicated server** (the reported case; local, offline mode, commands over RCON): I summoned one mooshroom with `{Type:"brown"}` and one with `{Type:"red"}`, then hit the red one with `summon lightning_bolt`. The server's `data get` then reported both as `brown`. - Before: the Horizon client drew both mooshrooms red, before and after the strike. - After: the brown one is drawn brown from the start, and the red one turns brown when the bolt hits. - **Single player (integrated server):** same two summons, then a bolt on the red one, then save, quit and reopen the world. - Before: the `{Type:"brown"}` mooshroom was drawn red. The struck one turned brown but came back red after reopening the world, and `data get … Type` kept printing the stale summoned value. - After: both are brown before and after reopening the world, and `data get … Type` prints `brown` for both. ## Self-check `tools/pr_ready.py` and `tools/parity.py` don't run on Windows (`signal.SIGHUP`). These ran instead: ``` cargo fmt --all -- --check # clean cargo clippy -p horizon-client --features mods --all-targets -- -D warnings # clean cargo test -p horizon-client --features mods --lib entity_nbt # 13 passed cargo test -p horizon-client --features mods --bin horizon-client remote_mob_data # 12 passed ``` `test_save_roundtrip_parity.py` already has a `{Type:"brown"}` mooshroom in its scene. It passed before because the raw tag carried `Type` through. I didn't run it here because it needs Linux or macOS. 🤖 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:10: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#5140
No description provided.