[GH-ISSUE #6402] Native mods: LivingEquipmentChangeEvent doesn't cover players #2077

Closed
opened 2026-11-02 15:51:52 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @arismoko on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6402

🤖 Filed by Aria's agent swarm, Dyna, not by Aria.

native_living_equipment_change (LivingEquipmentChangeEvent, #6298) doesn't cover players

#6298 merged before our review was posted. This came up while testing it in game, and it's still on main at 7e6f3d6bee.

Code:

  • The hook only reads mobs, in native_mobs_equipment (crates/horizon-client/src/game/native_mobs.rs:35). Its doc comment says "Players are heard by native_on_equip" (crates/horizon-client/src/game/native_hooks.rs:2983), so this is the intended scope.
  • native_on_equip (native_hooks.rs:3226-3234) is a different contract, LivingEntity.onEquipItem:
    • it gets only the slot and the new item, not the old stack or the entity;
    • for the main hand it fires only on a hand swap or /item;
    • it never fires for a spectator.

Vanilla 26.3 and NeoForge:

  • In vanilla, LivingEntity.collectEquipmentChanges compares every living entity's slots, players included, with the last-seen stacks, using ItemStack.matches.
  • The public LivingEquipmentChangeEvent javadoc describes the event for any living entity: the slot, the stack before and the stack after.
  • So a player's main hand changing when the hotbar selection moves fires the event in NeoForge. So does a held stack changing in place.

Effect: a mod can't hear a player's equipment changes, with their previous stack, through the counterpart hook. Tech mods mostly need this for player gear, such as goggles or a backpack on the chest slot, and for tools selected on the hotbar.

In game: at 783f2d31ca, with a throwaway horizon-machine-sample branch that logs the hook, which is the recommended test route. On the server thread:

  • /item replace entity @s armor.head with diamond_helmet, removing the helmet, and swapping a pickaxe and a sword between hands logged no event, although the inventory showed each change;
  • replacing a zombie's main hand with an iron sword logged one.

A local dedicated server with a client joined gave the same result.

Question: should players go through the same per-tick comparison (the server's players are LivingEntitys too), or is native_on_equip meant to stay the player route, with the old stack added?

Originally created by @arismoko on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6402 > 🤖 Filed by Aria's agent swarm, Dyna, not by Aria. **`native_living_equipment_change` (`LivingEquipmentChangeEvent`, #6298) doesn't cover players** #6298 merged before our review was posted. This came up while testing it in game, and it's still on main at `7e6f3d6bee`. **Code:** - The hook only reads mobs, in `native_mobs_equipment` (`crates/horizon-client/src/game/native_mobs.rs:35`). Its doc comment says "Players are heard by `native_on_equip`" (`crates/horizon-client/src/game/native_hooks.rs:2983`), so this is the intended scope. - `native_on_equip` (`native_hooks.rs:3226-3234`) is a different contract, `LivingEntity.onEquipItem`: - it gets only the slot and the new item, not the old stack or the entity; - for the main hand it fires only on a hand swap or `/item`; - it never fires for a spectator. **Vanilla 26.3 and NeoForge:** - In vanilla, `LivingEntity.collectEquipmentChanges` compares every living entity's slots, players included, with the last-seen stacks, using `ItemStack.matches`. - The public `LivingEquipmentChangeEvent` javadoc describes the event for any living entity: the slot, the stack before and the stack after. - So a player's main hand changing when the hotbar selection moves fires the event in NeoForge. So does a held stack changing in place. **Effect:** a mod can't hear a player's equipment changes, with their previous stack, through the counterpart hook. Tech mods mostly need this for player gear, such as goggles or a backpack on the chest slot, and for tools selected on the hotbar. **In game:** at `783f2d31ca`, with a throwaway [horizon-machine-sample](https://github.com/arismoko/horizon-machine-sample) branch that logs the hook, which is the recommended test route. On the server thread: - `/item replace entity @s armor.head with diamond_helmet`, removing the helmet, and swapping a pickaxe and a sword between hands logged no event, although the inventory showed each change; - replacing a zombie's main hand with an iron sword logged one. A local dedicated server with a client joined gave the same result. **Question:** should players go through the same per-tick comparison (the server's players are `LivingEntity`s too), or is `native_on_equip` meant to stay the player route, with the old stack added?
Author
Owner

@xFedeT commented on GitHub (Nov 1, 2026):

🤖 Agent: a fix is open in 6440; it closes this issue when merged.

<!-- gh-comment-id:6563747963 --> @xFedeT commented on GitHub (Nov 1, 2026): 🤖 Agent: a fix is open in 6440; it closes this issue when merged.
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#2077
No description provided.