[PR #7182] [MERGED] Fix duplicate mobs from spawn eggs used on a block underwater #7396

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7182
Author: @Joansitoh
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/7147-spawn-egg-underwater


📝 Commits (2)

  • 956494a Spawn eggs used on a block end the click client-side (#7147)
  • e8e8136 Inline the spawn egg swing helper

📊 Changes

1 file changed (+17 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game/remote.rs (+17 -0)

📄 Description

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

What

Using a spawn egg on a block while underwater spawned two mobs. The client sent UseItemOn (server spawns on the clicked face) and then UseItem (server spawns again from the fluid ray, added by #5942). In air there was no duplicate because the second ray hit nothing.

The client now ends the click after a spawn egg is used on a block. A mob that can spawn swings. A mob that cannot spawn (peaceful, via spawn_egg_allowed) ends the click without a swing. In adventure mode the click passes unless the item's can_place_on allows the block, so UseItem still follows there, as in the firework branch. The server is unchanged, so LAN guests and dedicated servers are covered too.

Vanilla reference

  • SpawnEggItem.useOn returns FAIL when type == null || !type.canSpawn(level). Otherwise it returns SUCCESS on a client level.
  • Minecraft.startUseItem: FAIL returns without a swing. A result that consumes the action swings and returns. Neither sends UseItem.
  • ItemStack.useOn passes in adventure mode unless canPlaceOnBlockInAdventureMode.

How tested

  • Unit test: a_spawn_egg_on_a_block_swings_only_for_a_mob_that_can_spawn. It only covers the swing-or-not helper. There is no in-process Game test setup for remote_use_item_on, and I did not run the game underwater.
  • I did not add an underwater case to tools/test_spawn_egg_fluid_parity.py. That harness drives vanilla Java clients that send UseItemOn only, so it can't exercise this client change. It was run as a regression check only.

pr_ready --quick (upstream/main 693aa8482): rustfmt ✅, clippy ✅, tests horizon-client 678 passed ✅, Python tests 612 passed ✅, mod API up to date ✅, public tree ✅. Doc tests: 0 passed.

Harness spawn_egg_fluid: PASS (290s). No GPU crashes.

Remaining affected harnesses: run by CI's parity job.

Suggested label: none (a fix)

Fixes #7147

🤖 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/7182 **Author:** [@Joansitoh](https://github.com/Joansitoh) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/7147-spawn-egg-underwater` --- ### 📝 Commits (2) - [`956494a`](https://github.com/horizon-rust/horizon/commit/956494a51abf8e49e6b43ce45e581ff61bf0f67e) Spawn eggs used on a block end the click client-side (#7147) - [`e8e8136`](https://github.com/horizon-rust/horizon/commit/e8e813638a68cfd9ba8e8af7ebe899f79fd47192) Inline the spawn egg swing helper ### 📊 Changes **1 file changed** (+17 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/remote.rs` (+17 -0) </details> ### 📄 Description > 🤖 Opened by Joansitoh's AI agent (Claude Code, Sonnet 5.5), not by Joansitoh personally. ## What Using a spawn egg on a block while underwater spawned two mobs. The client sent `UseItemOn` (server spawns on the clicked face) and then `UseItem` (server spawns again from the fluid ray, added by #5942). In air there was no duplicate because the second ray hit nothing. The client now ends the click after a spawn egg is used on a block. A mob that can spawn swings. A mob that cannot spawn (peaceful, via `spawn_egg_allowed`) ends the click without a swing. In adventure mode the click passes unless the item's `can_place_on` allows the block, so `UseItem` still follows there, as in the firework branch. The server is unchanged, so LAN guests and dedicated servers are covered too. ## Vanilla reference - `SpawnEggItem.useOn` returns FAIL when `type == null || !type.canSpawn(level)`. Otherwise it returns SUCCESS on a client level. - `Minecraft.startUseItem`: FAIL returns without a swing. A result that consumes the action swings and returns. Neither sends `UseItem`. - `ItemStack.useOn` passes in adventure mode unless `canPlaceOnBlockInAdventureMode`. ## How tested - Unit test: `a_spawn_egg_on_a_block_swings_only_for_a_mob_that_can_spawn`. It only covers the swing-or-not helper. There is no in-process `Game` test setup for `remote_use_item_on`, and I did not run the game underwater. - I did not add an underwater case to `tools/test_spawn_egg_fluid_parity.py`. That harness drives vanilla Java clients that send `UseItemOn` only, so it can't exercise this client change. It was run as a regression check only. `pr_ready --quick` (upstream/main 693aa8482): rustfmt ✅, clippy ✅, tests horizon-client 678 passed ✅, Python tests 612 passed ✅, mod API up to date ✅, public tree ✅. Doc tests: 0 passed. Harness `spawn_egg_fluid`: PASS (290s). No GPU crashes. Remaining affected harnesses: run by CI's parity job. Suggested label: none (a fix) Fixes #7147 🤖 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 06:38:54 +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#7396
No description provided.