[PR #4209] [MERGED] Drowned, zombie and stray conversions keep gear, name and flags #5486

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

📋 Pull Request Information

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

Base: main ← Head: fix-3514-conversion-keeps-gear


📝 Commits (1)

  • 1dd92e5 Drowned, zombie and stray conversions keep gear, name and flags

📊 Changes

4 files changed (+350 additions, -30 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+38 -0)
📝 crates/horizon-client/src/mobs.rs (+9 -0)
➕ crates/horizon-client/src/mobs/conversion.rs (+156 -0)
📝 crates/horizon-client/src/mobs/undead.rs (+147 -30)

📄 Description

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

What and why

Part of #3514 (the ConversionTracker.doConversion row).

A zombie that drowns, a husk that drowns and a skeleton that freezes in powder snow all lost everything they had. mobs/undead.rs pushed MobEvent::SpawnKind with only baby, yaw and persistence. Game then ran spawn_mob (a spawn-finalized mob with new random gear) and apply_setup. So armour, held items, the name tag, effects, NoAI/Silent, the lead and the vehicle were all dropped. A name-tagged zombie came out of the water as an unnamed drowned that can despawn.

Vanilla's ConversionTracker.doConversion calls Mob.convertTo(type, ConversionParams.single(this, true, true)). The new mob comes from EntityType.create(level, CONVERSION), so it has no finalizeSpawn and no random gear. ConversionType.SINGLE and convertCommon copy the old mob's state onto it.

  • New mobs/conversion.rs ports SINGLE and convertCommon:

    • position, motion and vehicle
    • every equipment slot with its stack, enchantments and drop chances (when keepEquipment)
    • fall distance, fall-flying, last-hurt-by-player, hurt time, body yaw and on-ground
    • the lead
    • effects and baby age
    • CanPickUpLoot (when preserveCanPickUpLoot), LeftHanded, NoAI, persistence, CustomNameVisible, Invulnerable and invulnerable time, NoGravity and Silent
    • the custom name
    • canBreakDoors between two zombies

    Health is not copied, matching vanilla.

  • The three undead conversions now push a new MobEvent::Convert { from, kind, params } that carries the removed mob.

  • Game::convert_to (in game/creatures.rs) builds the new mob, moves the old mob's riders onto it, and for a zombie or husk rolls Zombie.handleAttributes(special, CONVERSION), the postConversionStep of Zombie's tracker.

  • The conversion sound (level events 1040, 1041, 1048) is now skipped for a silent mob, as in ConversionTracker.lambda$doConversion$0.

Not in this PR:

  • Piglin/hoglin zombification, tadpole growth and the lightning conversions still use SpawnKind. They are other rows of #3514 and can reuse MobEvent::Convert.
  • The scoreboard team (ConversionParams.team) and the scoreboard tags (entityTags) are not moved yet. Absorption and the portal cooldown are not carried because Horizon's mobs do not model them yet.

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

Read with javap from the 26.3 client jar:

  • net.minecraft.world.entity.ConversionTracker.doConversion and lambda$doConversion$0
  • Mob.convertTo
  • ConversionParams.single
  • ConversionType$1.convert (SINGLE) and ConversionType.convertCommon
  • Zombie.<init> (drowning tracker, postConversionStep = handleAttributes(..., CONVERSION))
  • Skeleton.<init> (freezing tracker into STRAY)

No parity harness runs a 900-tick conversion. These new unit tests check it:

  • mobs::undead::conversion_tests::a_drowning_zombie_keeps_its_gear_and_name_tag and a_husk_turns_into_a_zombie_with_its_flags run custom_server_ai_step on the last conversion tick and build the mob the event describes.
  • mobs::conversion::tests::a_frozen_skeleton_becomes_a_stray_that_keeps_its_bow_and_name checks single with and without keepEquipment.

Self-check

Windows 11, CARGO_TARGET_DIR set to its own folder. tools/pr_ready.py doesn't run on Windows (it needs SIGHUP), so I ran its steps by hand:

  • cargo fmt --all -- --check: clean
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean
  • cargo test -p horizon-client --lib -- mobs::undead mobs::conversion: 3 passed
  • cargo test -p horizon-client --lib mobs::: 152 passed, 6 ignored
  • cargo test -p horizon-client --bin horizon-client -- zombie_villagers creatures: 5 passed
  • Before the fix (only the undead.rs code reverted, tests kept): a_drowning_zombie_keeps_its_gear_and_name_tag FAILED (left: None, right: Some("Bob")) and a_husk_turns_into_a_zombie_with_its_flags FAILED (left: None, right: Some("Dusty")). After the fix: all 3 pass.
  • In game, single player with the server on a thread (cargo build --profile fast -p horizon-client --bins):
    • Setup: /summon minecraft:zombie ... {CustomName:"Bob",CustomNameVisible:1b,PersistenceRequired:1b,equipment:{head:{id:"minecraft:iron_helmet"},mainhand:{id:"minecraft:iron_sword"}}} in a 5-deep glass water tank, then waited 50 s.
    • This branch: the drowned is Bob, still wears the helmet, holds the sword, and has the random_spawn_bonus attributes from handleAttributes. A Frosty skeleton with a bow and chainmail in powder snow became a stray named Frosty with both items.
    • Released v0.2.97, same world seed and setup: the drowned has no name, no helmet and no sword (/data get entity shows no CustomName and no equipment).

Screenshots

after: a zombie named Bob holding an iron sword drowns into a drowned that keeps its name and sword

The same view of the glass water tank, about 50 s after summoning a zombie named Bob with an iron helmet and an iron sword.

  • Before (v0.2.97): a plain, unnamed drowned with no helmet and nothing in its hands.
  • After (this branch): the drowned has the "Bob" name tag above it, wears the iron helmet and holds the iron sword.

🤖 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/4209 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3514-conversion-keeps-gear` --- ### 📝 Commits (1) - [`1dd92e5`](https://github.com/horizon-rust/horizon/commit/1dd92e5f849b4885b890cabcbaabaea119125deb) Drowned, zombie and stray conversions keep gear, name and flags ### 📊 Changes **4 files changed** (+350 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+38 -0) 📝 `crates/horizon-client/src/mobs.rs` (+9 -0) ➕ `crates/horizon-client/src/mobs/conversion.rs` (+156 -0) 📝 `crates/horizon-client/src/mobs/undead.rs` (+147 -30) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando personally. ## What and why Part of #3514 (the `ConversionTracker.doConversion` row). A zombie that drowns, a husk that drowns and a skeleton that freezes in powder snow all lost everything they had. `mobs/undead.rs` pushed `MobEvent::SpawnKind` with only baby, yaw and persistence. `Game` then ran `spawn_mob` (a spawn-finalized mob with new random gear) and `apply_setup`. So armour, held items, the name tag, effects, NoAI/Silent, the lead and the vehicle were all dropped. A name-tagged zombie came out of the water as an unnamed drowned that can despawn. Vanilla's `ConversionTracker.doConversion` calls `Mob.convertTo(type, ConversionParams.single(this, true, true))`. The new mob comes from `EntityType.create(level, CONVERSION)`, so it has no `finalizeSpawn` and no random gear. `ConversionType.SINGLE` and `convertCommon` copy the old mob's state onto it. - New `mobs/conversion.rs` ports `SINGLE` and `convertCommon`: - position, motion and vehicle - every equipment slot with its stack, enchantments and drop chances (when `keepEquipment`) - fall distance, fall-flying, last-hurt-by-player, hurt time, body yaw and on-ground - the lead - effects and baby age - CanPickUpLoot (when `preserveCanPickUpLoot`), LeftHanded, NoAI, persistence, CustomNameVisible, Invulnerable and invulnerable time, NoGravity and Silent - the custom name - `canBreakDoors` between two zombies Health is not copied, matching vanilla. - The three undead conversions now push a new `MobEvent::Convert { from, kind, params }` that carries the removed mob. - `Game::convert_to` (in `game/creatures.rs`) builds the new mob, moves the old mob's riders onto it, and for a zombie or husk rolls `Zombie.handleAttributes(special, CONVERSION)`, the `postConversionStep` of Zombie's tracker. - The conversion sound (level events 1040, 1041, 1048) is now skipped for a silent mob, as in `ConversionTracker.lambda$doConversion$0`. Not in this PR: - Piglin/hoglin zombification, tadpole growth and the lightning conversions still use `SpawnKind`. They are other rows of #3514 and can reuse `MobEvent::Convert`. - The scoreboard team (`ConversionParams.team`) and the scoreboard tags (`entityTags`) are not moved yet. Absorption and the portal cooldown are not carried because Horizon's mobs do not model them yet. ## 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 Read with javap from the 26.3 client jar: - `net.minecraft.world.entity.ConversionTracker.doConversion` and `lambda$doConversion$0` - `Mob.convertTo` - `ConversionParams.single` - `ConversionType$1.convert` (SINGLE) and `ConversionType.convertCommon` - `Zombie.<init>` (drowning tracker, `postConversionStep` = `handleAttributes(..., CONVERSION)`) - `Skeleton.<init>` (freezing tracker into `STRAY`) No parity harness runs a 900-tick conversion. These new unit tests check it: - `mobs::undead::conversion_tests::a_drowning_zombie_keeps_its_gear_and_name_tag` and `a_husk_turns_into_a_zombie_with_its_flags` run `custom_server_ai_step` on the last conversion tick and build the mob the event describes. - `mobs::conversion::tests::a_frozen_skeleton_becomes_a_stray_that_keeps_its_bow_and_name` checks `single` with and without `keepEquipment`. ## Self-check Windows 11, `CARGO_TARGET_DIR` set to its own folder. `tools/pr_ready.py` doesn't run on Windows (it needs SIGHUP), so I ran its steps by hand: - `cargo fmt --all -- --check`: clean - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean - `cargo test -p horizon-client --lib -- mobs::undead mobs::conversion`: 3 passed - `cargo test -p horizon-client --lib mobs::`: 152 passed, 6 ignored - `cargo test -p horizon-client --bin horizon-client -- zombie_villagers creatures`: 5 passed - Before the fix (only the `undead.rs` code reverted, tests kept): `a_drowning_zombie_keeps_its_gear_and_name_tag` FAILED (`left: None, right: Some("Bob")`) and `a_husk_turns_into_a_zombie_with_its_flags` FAILED (`left: None, right: Some("Dusty")`). After the fix: all 3 pass. - In game, single player with the server on a thread (`cargo build --profile fast -p horizon-client --bins`): - Setup: `/summon minecraft:zombie ... {CustomName:"Bob",CustomNameVisible:1b,PersistenceRequired:1b,equipment:{head:{id:"minecraft:iron_helmet"},mainhand:{id:"minecraft:iron_sword"}}}` in a 5-deep glass water tank, then waited 50 s. - This branch: the drowned is `Bob`, still wears the helmet, holds the sword, and has the `random_spawn_bonus` attributes from `handleAttributes`. A `Frosty` skeleton with a bow and chainmail in powder snow became a stray named `Frosty` with both items. - Released v0.2.97, same world seed and setup: the drowned has no name, no helmet and no sword (`/data get entity` shows no `CustomName` and no `equipment`). ## Screenshots ![after: a zombie named Bob holding an iron sword drowns into a drowned that keeps its name and sword](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3514-conversion-keeps-gear-1.png) The same view of the glass water tank, about 50 s after summoning a zombie named Bob with an iron helmet and an iron sword. - Before (v0.2.97): a plain, unnamed drowned with no helmet and nothing in its hands. - After (this branch): the drowned has the "Bob" name tag above it, wears the iron helmet and holds the iron sword. 🤖 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:12: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#5486
No description provided.