[PR #7025] [MERGED] Native mods: PlayerDestroyItemEvent hook (native_player_destroy_item) #7278

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

📋 Pull Request Information

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

Base: main ← Head: fix/6989-player-destroy-item-hook


📝 Commits (2)

  • d48f665 Native mods: PlayerDestroyItemEvent hook (native_player_destroy_item)
  • 452c326 fmt

📊 Changes

4 files changed (+106 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/lan.rs (+38 -1)
📝 crates/horizon-client/src/game/native_hooks.rs (+16 -0)
📝 crates/horizon-client/src/mod_api/generated.rs (+37 -0)
➕ tools/native-hook-fragments/native_player_destroy_item.json (+15 -0)

📄 Description

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

What

Adds the native-mods hook native_player_destroy_item(player, name, item, slot) (listen only, server side). It is heard when a server player's item breaks: tool, shield, rod or armour piece. slot is one of mainhand, offhand, head, chest, legs, feet, body, saddle. native_item_damaged stays the wear event; this is only the break.

It fires from Game::player_equipment_broke, which every player break goes through, so the callers are covered: armour, damage_held, shield, the enchant effects and mounts. It fires before the function's early returns. It is skipped for creative players, whose gear takes no wear. A LAN host's own break is not heard, the same as the totem hook.

Vanilla reference

LivingEntity.onEquippedItemBroken. NeoForge's PlayerDestroyItemEvent carries the original stack and a hand. Armour has no hand, so the fragment says this hook names the slot instead. Bukkit equivalent: PlayerItemBreakEvent.

How tested

  • New unit test pins the slot names mods match on. Expected values are literals.
  • A Game can't be built in a unit test, so the hook call itself is not exercised end to end.
  • Reviewed by a separate Sonnet 5.5 subagent: SIN DEFECTO.

pr_ready --quick --base upstream/main: Scope 4 files, Python tests 611 passed, clippy ✅, tests horizon-client + horizon-client-lib 2061 passed, doc tests ✅, mod API up to date ✅. rustfmt failed on the first run (the test's array formatting) and was fixed in the second commit; I did not rerun pr_ready after that, but cargo fmt --check is clean.

Named harnesses: item_use_order PASS, enchantment_components PASS. No harness directly covers this hook.

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

The API number is a pending fragment and is stamped by tools/stamp_native_hooks.py.

Suggested label: skip-release

Fixes #6989

🤖 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/7025 **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/6989-player-destroy-item-hook` --- ### 📝 Commits (2) - [`d48f665`](https://github.com/horizon-rust/horizon/commit/d48f6653967cccb3d5bae7f38bad0ec68a191ca0) Native mods: PlayerDestroyItemEvent hook (native_player_destroy_item) - [`452c326`](https://github.com/horizon-rust/horizon/commit/452c3268e5e6ca2940a7d44db80868a62272a4d0) fmt ### 📊 Changes **4 files changed** (+106 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan.rs` (+38 -1) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+16 -0) 📝 `crates/horizon-client/src/mod_api/generated.rs` (+37 -0) ➕ `tools/native-hook-fragments/native_player_destroy_item.json` (+15 -0) </details> ### 📄 Description > 🤖 Opened by Joansitoh's AI agent (Claude Code, Sonnet 5.5), not by Joansitoh personally. ## What Adds the native-mods hook `native_player_destroy_item(player, name, item, slot)` (listen only, server side). It is heard when a server player's item breaks: tool, shield, rod or armour piece. `slot` is one of `mainhand`, `offhand`, `head`, `chest`, `legs`, `feet`, `body`, `saddle`. `native_item_damaged` stays the wear event; this is only the break. It fires from `Game::player_equipment_broke`, which every player break goes through, so the callers are covered: armour, `damage_held`, shield, the enchant effects and mounts. It fires before the function's early returns. It is skipped for creative players, whose gear takes no wear. A LAN host's own break is not heard, the same as the totem hook. ## Vanilla reference `LivingEntity.onEquippedItemBroken`. NeoForge's `PlayerDestroyItemEvent` carries the original stack and a hand. Armour has no hand, so the fragment says this hook names the slot instead. Bukkit equivalent: `PlayerItemBreakEvent`. ## How tested - New unit test pins the slot names mods match on. Expected values are literals. - A `Game` can't be built in a unit test, so the hook call itself is not exercised end to end. - Reviewed by a separate Sonnet 5.5 subagent: SIN DEFECTO. `pr_ready --quick --base upstream/main`: Scope 4 files, Python tests 611 passed, clippy ✅, tests horizon-client + horizon-client-lib 2061 passed, doc tests ✅, mod API up to date ✅. rustfmt failed on the first run (the test's array formatting) and was fixed in the second commit; I did not rerun pr_ready after that, but `cargo fmt --check` is clean. Named harnesses: `item_use_order` PASS, `enchantment_components` PASS. No harness directly covers this hook. Remaining affected harnesses: run by CI's parity job. The API number is a pending fragment and is stamped by `tools/stamp_native_hooks.py`. Suggested label: skip-release Fixes #6989 🤖 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:57 +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#7278
No description provided.