[PR #6994] [MERGED] Native mods: mobs leaving a level (native_entity_leave_level) #7257

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

📋 Pull Request Information

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

Base: main ← Head: fix/5162-mob-leave-level


📝 Commits (4)

  • b4aac0a Native mods: mobs leaving a level (native_entity_leave_level)
  • f4eff4b Native mods: regenerate mod API output, keep the hook scan clean
  • c274e34 Leave-level snapshots only when a mod is loaded
  • 6cc2583 Merge main into #6994

📊 Changes

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

View changed files

📝 crates/horizon-client/src/game.rs (+3 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+68 -5)
📝 crates/horizon-client/src/game/persist.rs (+2 -0)
📝 crates/horizon-client/src/mod_api/generated.rs (+2 -2)
📝 docs/native-mods.md (+1 -1)

📄 Description

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

What

native_entity_leave_level now also fires for mobs (kind = mob type id, e.g. minecraft:zombie). Step 3 of #5162 after items/orbs (#5171).

  • native_hooks.rs: mob_ids() snapshot (empty on a client of a server) and native_mobs_left_since(), built on native_entities_left.
  • game.rs: snapshot before tick_mobs, diff after it (only on success). Covers death, despawn, removed, bee entering a hive. Mobs spawned during the tick are not counted.
  • persist.rs: same diff around the chunk-unload retain. One diff per removal site, no double fire.
  • Docs/doc comments say "item entities, orbs and mobs"; mod API output regenerated.

Vanilla

Entity.remove -> onTrackingEnd -> NeoForge EntityLeaveLevelEvent; also on chunk unload (stopTracking).

Not in this slice (follow-ups)

Portal departures (nether_portal.rs), vehicle tree when a player leaves (persist.rs), command/peaceful purges (commands.rs, dedicated.rs, lan_actions.rs), level close (levels.rs). Deliberately not fired: End gateway, dispenser/villagers/creaking take-and-put-back, beehive temporary load/release, remote_vehicles.rs.

Tested

  • Unit test vanished_mobs_are_reported_by_kind: reports exactly the vanished ids with the right kind; nothing when unchanged or only added.
  • pr_ready --quick: all checks pass (Scope 5 files +65 −10, fmt, clippy, 2057 tests, mod API up to date, Python 611 passed).
  • Harnesses: dedicated_server PASS, server_entities PASS.
  • Remaining affected harnesses: run by CI's parity job.

Closes nothing. Part of #5162

Suggested label: feature

🤖 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/6994 **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/5162-mob-leave-level` --- ### 📝 Commits (4) - [`b4aac0a`](https://github.com/horizon-rust/horizon/commit/b4aac0aebccce052699b5d2cea7c7e0b6b949f85) Native mods: mobs leaving a level (native_entity_leave_level) - [`f4eff4b`](https://github.com/horizon-rust/horizon/commit/f4eff4bb39a85b76ac139249951f4865c99700b0) Native mods: regenerate mod API output, keep the hook scan clean - [`c274e34`](https://github.com/horizon-rust/horizon/commit/c274e344636a464b2f202029423ab93c57c6c453) Leave-level snapshots only when a mod is loaded - [`6cc2583`](https://github.com/horizon-rust/horizon/commit/6cc25834e4de5c95e3b9217d1e145a2c96c81a4a) Merge main into #6994 ### 📊 Changes **5 files changed** (+76 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+3 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+68 -5) 📝 `crates/horizon-client/src/game/persist.rs` (+2 -0) 📝 `crates/horizon-client/src/mod_api/generated.rs` (+2 -2) 📝 `docs/native-mods.md` (+1 -1) </details> ### 📄 Description > 🤖 Opened by Joansitoh's AI agent (Claude Code, Sonnet 5.5), not by Joansitoh personally. ## What `native_entity_leave_level` now also fires for mobs (`kind` = mob type id, e.g. `minecraft:zombie`). Step 3 of #5162 after items/orbs (#5171). - `native_hooks.rs`: `mob_ids()` snapshot (empty on a client of a server) and `native_mobs_left_since()`, built on `native_entities_left`. - `game.rs`: snapshot before `tick_mobs`, diff after it (only on success). Covers death, despawn, `removed`, bee entering a hive. Mobs spawned during the tick are not counted. - `persist.rs`: same diff around the chunk-unload retain. One diff per removal site, no double fire. - Docs/doc comments say "item entities, orbs and mobs"; mod API output regenerated. ## Vanilla `Entity.remove` -> `onTrackingEnd` -> NeoForge `EntityLeaveLevelEvent`; also on chunk unload (`stopTracking`). ## Not in this slice (follow-ups) Portal departures (`nether_portal.rs`), vehicle tree when a player leaves (`persist.rs`), command/peaceful purges (`commands.rs`, `dedicated.rs`, `lan_actions.rs`), level close (`levels.rs`). Deliberately not fired: End gateway, dispenser/villagers/creaking take-and-put-back, beehive temporary load/release, `remote_vehicles.rs`. ## Tested - Unit test `vanished_mobs_are_reported_by_kind`: reports exactly the vanished ids with the right kind; nothing when unchanged or only added. - `pr_ready --quick`: all checks pass (Scope 5 files +65 −10, fmt, clippy, 2057 tests, mod API up to date, Python 611 passed). - Harnesses: `dedicated_server` PASS, `server_entities` PASS. - Remaining affected harnesses: run by CI's parity job. Closes nothing. Part of #5162 Suggested label: feature 🤖 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:36:35 +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#7257
No description provided.