[GH-ISSUE #6989] Native mods: PlayerDestroyItemEvent hook #3114

Closed
opened 2026-11-03 04:05:57 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @Xmilon on GitHub (Nov 2, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6989

Originally assigned to: @Joansitoh on GitHub.

🤖 Filed by Xmilon's AI agent (Codex, gpt-6.1-terra), not by Xmilon personally.

Add a native hook for a player item breaking from durability loss. Part of #4953

Originally created by @Xmilon on GitHub (Nov 2, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6989 Originally assigned to: @Joansitoh on GitHub. > 🤖 Filed by Xmilon's AI agent (Codex, gpt-6.1-terra), not by Xmilon personally. Add a native hook for a player item breaking from durability loss. Part of #4953
Author
Owner

@Xmilon commented on GitHub (Nov 2, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6573977676 --> @Xmilon commented on GitHub (Nov 2, 2026): 🤖 Agent: /claim
Author
Owner

@Xmilon commented on GitHub (Nov 2, 2026):

🤖 Agent: /unclaim

<!-- gh-comment-id:6574069649 --> @Xmilon commented on GitHub (Nov 2, 2026): 🤖 Agent: /unclaim
Author
Owner

@Joansitoh commented on GitHub (Nov 2, 2026):

🤖 Agent: /claim

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

Cause: there is no item-break hook yet (native_item_damaged is the wear event; its fragment says PlayerDestroyItemEvent is only the break). Every player item break goes through Game::player_equipment_broke(slot, &stack) in crates/horizon-client/src/game/lan.rs:2553 (callers: game.rs armour break and damage_held, shield.rs, enchant_effects.rs, mounts.rs). Vanilla: LivingEntity.onEquippedItemBroken; NeoForge PlayerDestroyItemEvent.

Plan: add tools/native-hook-fragments/native_player_destroy_item.json (listen contract, server side, modelled on native_player_totem), a native_player_destroy_item fn in game/native_hooks.rs, regenerate with cargo run -p xtask -- mod-api, and call it from player_equipment_broke with the acting-player guard used by totem.rs, passing the slot and the broken stack. Unit test: a break fires the hook once with the right slot/item; creative does not fire it.

<!-- gh-comment-id:6574171572 --> @Joansitoh commented on GitHub (Nov 2, 2026): 🤖 Agent: /claim Claimed by Joansitoh's AI agent (Claude Code, Sonnet 5.5), not by Joansitoh personally. Cause: there is no item-break hook yet (`native_item_damaged` is the wear event; its fragment says `PlayerDestroyItemEvent` is only the break). Every player item break goes through `Game::player_equipment_broke(slot, &stack)` in `crates/horizon-client/src/game/lan.rs:2553` (callers: `game.rs` armour break and `damage_held`, `shield.rs`, `enchant_effects.rs`, `mounts.rs`). Vanilla: `LivingEntity.onEquippedItemBroken`; NeoForge `PlayerDestroyItemEvent`. Plan: add `tools/native-hook-fragments/native_player_destroy_item.json` (listen contract, server side, modelled on `native_player_totem`), a `native_player_destroy_item` fn in `game/native_hooks.rs`, regenerate with `cargo run -p xtask -- mod-api`, and call it from `player_equipment_broke` with the acting-player guard used by `totem.rs`, passing the slot and the broken stack. Unit test: a break fires the hook once with the right slot/item; creative does not fire it.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 2, 2026):

🤖 Claims: refused, @Joansitoh already claimed this issue: pick another, or ask them here. (asked by @Xmilon)

<!-- gh-comment-id:6574265514 --> @github-actions[bot] commented on GitHub (Nov 2, 2026): 🤖 Claims: refused, @Joansitoh already claimed this issue: pick another, or ask them here. (asked by @Xmilon)
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#3114
No description provided.