[PR #7229] [MERGED] Commands: fail summon when a mod rejects a mob or minecart #7428

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

📋 Pull Request Information

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

Base: main ← Head: fix/summon-cancelled-join


📝 Commits (1)

  • d9ae51f Commands: fail summon when a mod rejects a mob or minecart

📊 Changes

2 files changed (+9 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/commands.rs (+6 -1)
📝 crates/horizon-client/src/game/creatures.rs (+3 -0)

📄 Description

🤖 Opened by masa-masa-0314's AI agent (ZCode, GPT-6), not by masa-masa-0314 personally.

What and why

Fixes #7184.

When a native mod cancels an entity join, plain /summon pig and minecart summons could still report success. Mobs were removed synchronously but their spawn helper returned an ID anyway; carts reported success before their join callback ran.

  • Return None from spawn_mob_for if the original mob ID is absent after the join callback, before equipment and jockey postprocessing.
  • Propagate that failure through /summon using commands.summon.failed.uuid.
  • Flush a minecart's join before success, watching its saved ID so cancellation of another pending entity does not fail this summon.

Two production files, +9/-1. Existing NBT paths and unrelated batch-notification behavior are unchanged. Work began while this issue was unassigned; a later claim was discovered at publication and coordinated in this comment.

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

Independently inspected Minecraft 26.3 SummonCommand.createEntity with javap -c -p: a false return from ServerLevel.tryAddFreshEntityWithPassengers throws ERROR_DUPLICATE_UUID. Horizon's existing experience-orb summon branch already maps join rejection to the same translation key.

Behavior validation used a temporary real trait mod registered through entry::main_with: Hooks::entity_join_level returns Flow::Cancel for pigs and all seven minecart types. The real mod registry, dispatch, entity removal and command callbacks were exercised, with no bypass of the empty-mod guard. The connected headless client ran commands on the integrated server thread.

  • Cancel / allow / no-mod modes: 81 scenario groups, 243 command records, zero failures. Each mode covers plain summon, NBT summon and execute summon for pig, rideable/chest/furnace/TNT/hopper/command-block/spawner carts, plus cow as an allowed control.
  • Assertions check success/failure callbacks, UUID failure text, entity existence and scoreboard evidence that execute summon did or did not run its child command.
  • The temporary main entry was removed. The final production executable was rebuilt, and its 27 groups / 81 no-mod records exactly matched the earlier successful no-mod run.

Limitations: no separately hosted dedicated-server or graphical run, no mixed-pending-batch game test, and no independent prepatch cancellation executable run. Full vanilla parity harnesses were not run (--quick); vanilla has no Horizon native-mod callback, so its refusal semantics were checked independently in bytecode. Per the contributor's workflow preference, the temporary mod, scripts and logs are archived locally rather than included in this PR: no new permanent regression coverage is added. Existing tests are unchanged. Port-ledger index validation was not run.

Other projects' code

None.

Self-check

Frozen upstream baseline: 2f35078b3aee63ae7a6c6d9357aa2e8925fa756d. Checks ran on the final two-file production diff after removing the temporary entry. The committed files were verified against that tested source snapshot. Additional cargo check --locked -p horizon-client --lib, final cargo build --profile fast --locked -p horizon-client --bin horizon-client, and the final-source no-mod command matrix all exited 0.

Original self-check output, unchanged:

pr_ready (tools/pr_ready.py --quick --base 2f35078b3aee63ae7a6c6d9357aa2e8925fa756d on DESKTOP-3050AHP, against 2f35078b3a at 2f35078b3, 11 min 41 s)

Check Result
Scope ✅ 2 files, +9 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 612 passed (2 min 58 s)
rustfmt ✅ (18 s)
clippy ✅ (2 min 25 s)
tests: horizon-client ✅ 680 passed (5 min 9 s)
doc tests ✅ 0 passed (5 s)
content root tests ➖ content root untouched
mod API up to date ✅ (42 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)

Doc-test command matched zero tests; this is not additional behavioral coverage.

Screenshots

Not captured; no visible game window was launched. The real server-thread command records verify the feedback and entity state.

🤖 Generated with ZCode (GPT-6).


🔄 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/7229 **Author:** [@masa-masa-0314](https://github.com/masa-masa-0314) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/summon-cancelled-join` --- ### 📝 Commits (1) - [`d9ae51f`](https://github.com/horizon-rust/horizon/commit/d9ae51fe4689ae94e0643f8ec2d08f20e8d8e093) Commands: fail summon when a mod rejects a mob or minecart ### 📊 Changes **2 files changed** (+9 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands.rs` (+6 -1) 📝 `crates/horizon-client/src/game/creatures.rs` (+3 -0) </details> ### 📄 Description > 🤖 Opened by masa-masa-0314's AI agent (ZCode, GPT-6), not by masa-masa-0314 personally. ## What and why Fixes #7184. When a native mod cancels an entity join, plain `/summon pig` and minecart summons could still report success. Mobs were removed synchronously but their spawn helper returned an ID anyway; carts reported success before their join callback ran. - Return `None` from `spawn_mob_for` if the original mob ID is absent after the join callback, before equipment and jockey postprocessing. - Propagate that failure through `/summon` using `commands.summon.failed.uuid`. - Flush a minecart's join before success, watching its saved ID so cancellation of another pending entity does not fail this summon. Two production files, +9/-1. Existing NBT paths and unrelated batch-notification behavior are unchanged. Work began while this issue was unassigned; a later claim was discovered at publication and coordinated in [this comment](https://github.com/horizon-rust/horizon/issues/7184#issuecomment-6578271054). ## 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 Independently inspected Minecraft 26.3 `SummonCommand.createEntity` with `javap -c -p`: a false return from `ServerLevel.tryAddFreshEntityWithPassengers` throws `ERROR_DUPLICATE_UUID`. Horizon's existing experience-orb summon branch already maps join rejection to the same translation key. Behavior validation used a temporary real trait mod registered through `entry::main_with`: `Hooks::entity_join_level` returns `Flow::Cancel` for pigs and all seven minecart types. The real mod registry, dispatch, entity removal and command callbacks were exercised, with no bypass of the empty-mod guard. The connected headless client ran commands on the integrated server thread. - Cancel / allow / no-mod modes: **81 scenario groups, 243 command records, zero failures**. Each mode covers plain summon, NBT summon and `execute summon` for pig, rideable/chest/furnace/TNT/hopper/command-block/spawner carts, plus cow as an allowed control. - Assertions check success/failure callbacks, UUID failure text, entity existence and scoreboard evidence that `execute summon` did or did not run its child command. - The temporary main entry was removed. The final production executable was rebuilt, and its **27 groups / 81 no-mod records** exactly matched the earlier successful no-mod run. Limitations: no separately hosted dedicated-server or graphical run, no mixed-pending-batch game test, and no independent prepatch cancellation executable run. Full vanilla parity harnesses were not run (`--quick`); vanilla has no Horizon native-mod callback, so its refusal semantics were checked independently in bytecode. Per the contributor's workflow preference, the temporary mod, scripts and logs are archived locally rather than included in this PR: **no new permanent regression coverage is added**. Existing tests are unchanged. Port-ledger index validation was not run. ## Other projects' code None. ## Self-check Frozen upstream baseline: `2f35078b3aee63ae7a6c6d9357aa2e8925fa756d`. Checks ran on the final two-file production diff after removing the temporary entry. The committed files were verified against that tested source snapshot. Additional `cargo check --locked -p horizon-client --lib`, final `cargo build --profile fast --locked -p horizon-client --bin horizon-client`, and the final-source no-mod command matrix all exited 0. Original self-check output, unchanged: **pr_ready** (`tools/pr_ready.py --quick --base 2f35078b3aee63ae7a6c6d9357aa2e8925fa756d` on DESKTOP-3050AHP, against 2f35078b3aee63ae7a6c6d9357aa2e8925fa756d at 2f35078b3, 11 min 41 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +9 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 612 passed (2 min 58 s) | | rustfmt | ✅ (18 s) | | clippy | ✅ (2 min 25 s) | | tests: horizon-client | ✅ 680 passed (5 min 9 s) | | doc tests | ✅ 0 passed (5 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (42 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) | Doc-test command matched zero tests; this is not additional behavioral coverage. ## Screenshots Not captured; no visible game window was launched. The real server-thread command records verify the feedback and entity state. 🤖 Generated with ZCode (GPT-6). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:39:23 +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#7428
No description provided.