[PR #3686] [MERGED] An op's spawn egg sets its entity data on a spawner #5151

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

📋 Pull Request Information

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

Base: main ← Head: fix/spawn-egg-entity-data


📝 Commits (3)

  • a839b0c An op's spawn egg sets its entity data on a spawner
  • 7830c6d Merge main into the branch; keep both spawner.rs additions (acting_player_is_op, tick_remote_spawners)
  • 67c4e5e Merge main into the branch; the guest swap keeps both the acting permission and known_movement

📊 Changes

6 files changed (+140 additions, -8 deletions)

View changed files

📝 crates/horizon-client/src/block_entity_item.rs (+51 -0)
📝 crates/horizon-client/src/game.rs (+3 -0)
📝 crates/horizon-client/src/game/creatures.rs (+6 -2)
📝 crates/horizon-client/src/game/lan_actions.rs (+8 -2)
📝 crates/horizon-client/src/game/spawner.rs (+20 -4)
📝 crates/horizon-client/src/mobs/spawner.rs (+52 -0)

📄 Description

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

What and why

A spawn egg that carries entity data (minecraft:entity_data: a name, equipment, effects...) used on a monster spawner gave a plain mob of the egg's own type. In vanilla 26.3:

  • the type comes from SpawnEggItem.getType: the entity data's id when the egg has one, else the egg's own type, for everyone;
  • for an op (PlayerList.isOp) with entity data, Spawner.setEntityData runs: TypedEntityData.loadInto sets the next spawn data's id, then merges the egg's data into it (CompoundTag.merge); anyone else gets setEntityId only.

Horizon always set the egg's own type. Not reported yet; #3516 lists the same gap for trial spawners only.

Change

  • mobs/spawner.rs: SpawnerExt::set_entity_data: set_entity_id, then data_cmd::merge_compound into the next entity.
  • block_entity_item.rs: spawn_egg_on_spawner(stack, op): the type (entity data id, else the egg's) and the data for an op.
  • game/spawner.rs, game/creatures.rs: the egg on a spawner uses both; acting_player_is_op reads the acting player's permission level.
  • game.rs, game/lan_actions.rs: the acting server guest's permission level is kept beside its name and UUID (lan_acting_permission), so a server checks the player who used the egg, not the host.

Not in this PR: trial spawners still take the type only (TrialSpawnerBlockEntity.setEntityData, #3516); the peaceful check before it still reads the egg's own type.

Vanilla reference

SpawnEggItem.useOn, SpawnEggItem.getType, BaseSpawner.setEntityData, SpawnerBlockEntity.setEntityData, TypedEntityData.loadInto(SpawnData, DefaultedRegistry), read from the 26.3 client jar's bytecode (javap -c). No harness covers spawn eggs on spawners; unit tests below.

Testing

  • mobs::spawner::tests::entity_data_sets_the_id_and_merges_into_the_next_entity: id set, the egg's keys over the old ones, nested compounds merged.
  • block_entity_item::tests::a_spawn_egg_sets_its_data_type_and_an_ops_data: plain egg, entity data for a non-op (type only) and for an op (type and data).
  • In game (--profile fast, default server-thread single player, cheats on): item replace entity @s weapon.mainhand with minecraft:zombie_spawn_egg[entity_data={id:'minecraft:skeleton',CustomName:'Guard',equipment:{mainhand:{id:'minecraft:bow',count:1}}}], used on a placed spawner: data get block ... SpawnData gives {entity: {CustomName: "Guard", equipment: {mainhand: {count: 1, id: "minecraft:bow"}}, id: "minecraft:skeleton"}} (main sets only the egg's own type, minecraft:zombie, without the name or the bow). The non-op path was not run in game (it needs a world without commands); the unit test covers it.

Self-check

pr_ready (tools/pr_ready.py --quick --base da9d0dcbe, Windows 11, 4 min 25 s)

Check Result
Scope ✅ 6 files, +140 −8
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 411 run, 1 failure: test_port_publish.test_body_has_names_and_signatures_only expects ~/code/... and gets ~\code\... on Windows; unrelated to this change
rustfmt ✅
clippy ✅
tests: horizon-client ✅ 812 passed
doc tests ✅
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses

🤖 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/3686 **Author:** [@k3yh](https://github.com/k3yh) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/spawn-egg-entity-data` --- ### 📝 Commits (3) - [`a839b0c`](https://github.com/horizon-rust/horizon/commit/a839b0cef1eb4a423633aff26686d860e61d55b6) An op's spawn egg sets its entity data on a spawner - [`7830c6d`](https://github.com/horizon-rust/horizon/commit/7830c6de4a6852cd20239660f16d034f9df2f7a2) Merge main into the branch; keep both spawner.rs additions (acting_player_is_op, tick_remote_spawners) - [`67c4e5e`](https://github.com/horizon-rust/horizon/commit/67c4e5eb1af78f8fac14f465f482e52f5cc5e3f7) Merge main into the branch; the guest swap keeps both the acting permission and known_movement ### 📊 Changes **6 files changed** (+140 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/block_entity_item.rs` (+51 -0) 📝 `crates/horizon-client/src/game.rs` (+3 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+6 -2) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+8 -2) 📝 `crates/horizon-client/src/game/spawner.rs` (+20 -4) 📝 `crates/horizon-client/src/mobs/spawner.rs` (+52 -0) </details> ### 📄 Description > 🤖 Opened by k3yh's AI agent (Claude Code, Claude Opus 5.5), not by k3yh themselves. ## What and why A spawn egg that carries entity data (`minecraft:entity_data`: a name, equipment, effects...) used on a monster spawner gave a plain mob of the egg's own type. In vanilla 26.3: - the type comes from `SpawnEggItem.getType`: the entity data's `id` when the egg has one, else the egg's own type, for everyone; - for an op (`PlayerList.isOp`) with entity data, `Spawner.setEntityData` runs: `TypedEntityData.loadInto` sets the next spawn data's `id`, then merges the egg's data into it (`CompoundTag.merge`); anyone else gets `setEntityId` only. Horizon always set the egg's own type. Not reported yet; #3516 lists the same gap for trial spawners only. ## Change - `mobs/spawner.rs`: `SpawnerExt::set_entity_data`: `set_entity_id`, then `data_cmd::merge_compound` into the next entity. - `block_entity_item.rs`: `spawn_egg_on_spawner(stack, op)`: the type (entity data id, else the egg's) and the data for an op. - `game/spawner.rs`, `game/creatures.rs`: the egg on a spawner uses both; `acting_player_is_op` reads the acting player's permission level. - `game.rs`, `game/lan_actions.rs`: the acting server guest's permission level is kept beside its name and UUID (`lan_acting_permission`), so a server checks the player who used the egg, not the host. Not in this PR: trial spawners still take the type only (`TrialSpawnerBlockEntity.setEntityData`, #3516); the peaceful check before it still reads the egg's own type. ## Vanilla reference `SpawnEggItem.useOn`, `SpawnEggItem.getType`, `BaseSpawner.setEntityData`, `SpawnerBlockEntity.setEntityData`, `TypedEntityData.loadInto(SpawnData, DefaultedRegistry)`, read from the 26.3 client jar's bytecode (`javap -c`). No harness covers spawn eggs on spawners; unit tests below. ## Testing - `mobs::spawner::tests::entity_data_sets_the_id_and_merges_into_the_next_entity`: id set, the egg's keys over the old ones, nested compounds merged. - `block_entity_item::tests::a_spawn_egg_sets_its_data_type_and_an_ops_data`: plain egg, entity data for a non-op (type only) and for an op (type and data). - In game (`--profile fast`, default server-thread single player, cheats on): `item replace entity @s weapon.mainhand with minecraft:zombie_spawn_egg[entity_data={id:'minecraft:skeleton',CustomName:'Guard',equipment:{mainhand:{id:'minecraft:bow',count:1}}}]`, used on a placed spawner: `data get block ... SpawnData` gives `{entity: {CustomName: "Guard", equipment: {mainhand: {count: 1, id: "minecraft:bow"}}, id: "minecraft:skeleton"}}` (main sets only the egg's own type, `minecraft:zombie`, without the name or the bow). The non-op path was not run in game (it needs a world without commands); the unit test covers it. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base da9d0dcbe`, Windows 11, 4 min 25 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +140 −8 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 411 run, 1 failure: `test_port_publish.test_body_has_names_and_signatures_only` expects `~/code/...` and gets `~\code\...` on Windows; unrelated to this change | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client | ✅ 812 passed | | doc tests | ✅ | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | 🤖 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:36 +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#5151
No description provided.