[PR #6440] [MERGED] LivingEquipmentChangeEvent covers the server's players #6873

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6440
Author: @xFedeT
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/player-equipment-event


📝 Commits (2)

  • 89ca25c LivingEquipmentChangeEvent covers the server's players
  • 2341454 A respawned player's equipment is heard again from empty

📊 Changes

2 files changed (+60 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+9 -0)
📝 crates/horizon-client/src/game/native_mobs.rs (+51 -0)

📄 Description

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

Fixes #6402

What was wrong

LivingEntity.collectEquipmentChanges compares every living entity's equipment slots with the last seen stacks, players included, and NeoForge's LivingEquipmentChangeEvent carries the slot and both stacks. Horizon's native_mobs_equipment compared mobs only, and native_on_equip (the player route) gets no previous stack, fires for the main hand only on a swap or /item, and never for a spectator. A mod could not hear a player's helmet, backpack or selected tool change.

What changes

native_players_equipment (game/native_mobs.rs), run each tick after the player menus for the guests of the level: it compares each guest's main hand (the selected hotbar stack), off hand and the four armor slots with what the mods last heard (equipment_heard, kept per guest with its other play state) and calls native_living_equipment_change with minecraft:player, the slot name, the previous stack and the new one. A guest new to the level counts from empty, as a mob does, and only while a mod listens, so nothing is read otherwise.

Verification

Builds; cargo test -p horizon-client --lib passes and clippy and rustfmt are clean for the changed files (the only clippy error is the existing needless_borrow in horizon-world). The hook is a no-op in this build without a native mod listening, and the issue's test route (a throwaway horizon-machine-sample branch logging the hook) was not run here, so the new comparison is unproven in game.

Not done

native_on_equip is left as it is, as the issue's question leaves open; this adds the per-tick route beside it. The documentation comment that says players are heard by native_on_equip was not reworded.

🤖 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/6440 **Author:** [@xFedeT](https://github.com/xFedeT) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/player-equipment-event` --- ### 📝 Commits (2) - [`89ca25c`](https://github.com/horizon-rust/horizon/commit/89ca25c574aad30eff101c4aedcec0905e9e662c) LivingEquipmentChangeEvent covers the server's players - [`2341454`](https://github.com/horizon-rust/horizon/commit/23414548262612e8584f635c132f11bf543c0c4f) A respawned player's equipment is heard again from empty ### 📊 Changes **2 files changed** (+60 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+9 -0) 📝 `crates/horizon-client/src/game/native_mobs.rs` (+51 -0) </details> ### 📄 Description > 🤖 Opened by xFedeT's AI agent (Claude Code, Sonnet 5.5), not by xFedeT personally. Fixes #6402 ## What was wrong `LivingEntity.collectEquipmentChanges` compares every living entity's equipment slots with the last seen stacks, players included, and NeoForge's `LivingEquipmentChangeEvent` carries the slot and both stacks. Horizon's `native_mobs_equipment` compared mobs only, and `native_on_equip` (the player route) gets no previous stack, fires for the main hand only on a swap or `/item`, and never for a spectator. A mod could not hear a player's helmet, backpack or selected tool change. ## What changes `native_players_equipment` (`game/native_mobs.rs`), run each tick after the player menus for the guests of the level: it compares each guest's main hand (the selected hotbar stack), off hand and the four armor slots with what the mods last heard (`equipment_heard`, kept per guest with its other play state) and calls `native_living_equipment_change` with `minecraft:player`, the slot name, the previous stack and the new one. A guest new to the level counts from empty, as a mob does, and only while a mod listens, so nothing is read otherwise. ## Verification Builds; `cargo test -p horizon-client --lib` passes and clippy and rustfmt are clean for the changed files (the only clippy error is the existing `needless_borrow` in `horizon-world`). The hook is a no-op in this build without a native mod listening, and the issue's test route (a throwaway horizon-machine-sample branch logging the hook) was not run here, so the new comparison is unproven in game. ## Not done `native_on_equip` is left as it is, as the issue's question leaves open; this adds the per-tick route beside it. The documentation comment that says players are heard by `native_on_equip` was not reworded. 🤖 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:28:29 +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#6873
No description provided.