[PR #7563] Native mods: living entity handles (LivingRef) and a living entity's equipment (#7387) #7672

Open
opened 2026-11-03 07:21:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7563
Author: @levzzz5154
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: modapi/living-refs


📝 Commits (2)

  • 5030e21 Native mods: living entity handles (LivingRef) and a living entity's equipment (#7387)
  • 4981881 Merge main into modapi/living-refs

📊 Changes

10 files changed (+356 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/commands.rs (+1 -1)
📝 crates/horizon-client/src/game/mod_api_host_generated.rs (+17 -0)
📝 crates/horizon-client/src/game/native_entity_refs.rs (+1 -1)
➕ crates/horizon-client/src/game/native_living_refs.rs (+199 -0)
📝 crates/horizon-client/src/mod_api.rs (+31 -0)
📝 crates/horizon-client/src/mod_api/generated_host.rs (+66 -0)
📝 docs/native-mods.md (+6 -0)
➕ tools/native-hook-fragments/living_refs.json (+29 -0)
📝 xtask/src/mod_api.rs (+5 -1)

📄 Description

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

Stacked on #7454 (draft until it merges; until then, review only the last commit).

Part of #7387, on top of #7454: LivingRef and the line LivingRef equipment and hands. The tracker's LivingRef health and effects lines are Qwerner88880's and aren't touched here (comment).

What it adds

  • LivingRef (wraps an EntityRef; entity(), id(), From<LivingRef> for EntityRef) and the bridge host.living(entity). It resolves for a mob, a player, an armor stand or the dragon (vanilla's LivingEntity), and is None for anything else.
  • The generator's HANDLES table gains living, so "receiver": "living" entries become LivingRef methods.
  • mod_api re-exports EquipmentSlot.
  • equipment(host, slot) and hand_item(host, hand): getItemBySlot / getItemInHand. A player's slots come from its inventory, armour and off hand. Another server player's come from their guest state.
  • set_equipment(host, slot, stack): setItemSlot, through the same slot code as /item replace entity (slots_named and slot_set; commands::items becomes pub(in crate::game)). None empties the slot. It returns false where the entity has no such slot: a player has no body slot, a horse keeps its armour where a zombie keeps its helmet, so each refuses the other, and the dragon has none. A mob's saddle can't be set yet, and a mob keeps one item outside its main hand, as /item does today.

Proof

The probe bundle from #7454, run on this branch's fast build, server thread, offscreen, scratch homes. Every 300 ticks it sets the head, body, saddle and off hand, empties the main hand, then reads them back:

ENTPROBE setequip kind=minecraft:armor_stand head=true body=false saddle=false off=true main_empty=true now head=Some("minecraft:carved_pumpkinx1") body=None off=Some("minecraft:torchx3") main=None
ENTPROBE setequip kind=minecraft:horse head=false body=true saddle=false off=true main_empty=true now head=None body=Some("minecraft:diamond_horse_armorx1") off=Some("minecraft:torchx1") main=None
ENTPROBE setequip kind=minecraft:player head=true body=false saddle=false off=true main_empty=true now head=Some("minecraft:carved_pumpkinx1") body=None off=Some("minecraft:torchx3") main=None
ENTPROBE setequip kind=minecraft:zombie head=true body=false saddle=false off=true main_empty=true now head=Some("minecraft:carved_pumpkinx1") body=None off=Some("minecraft:torchx1") main=None
ENTPROBE living kind=minecraft:armor_stand main=None off=None head=None feet=None body=None back=true
ENTPROBE living kind=minecraft:armor_stand main=None off=Some("minecraft:torch") head=Some("minecraft:carved_pumpkin") feet=None body=None back=true
ENTPROBE living kind=minecraft:player main=None off=None head=None feet=None body=None back=true
ENTPROBE living kind=minecraft:player main=None off=Some("minecraft:torch") head=Some("minecraft:carved_pumpkin") feet=None body=None back=true
ENTPROBE not_living kind=minecraft:item_display
  • Head and off hand work on the player, the armor stand and the zombie.
  • The horse takes body armour and refuses a head item.
  • The zombie refuses a body item, so it keeps its helmet. (A first draft overwrote it; this caught it.)
  • The item display isn't living.

pr_ready (tools/pr_ready.py --quick --base modapi/entity-handles on cachyos-x8664, against modapi/entity-handles at 7b77a5ec9, 4 min 13 s)

Check Result
Scope ✅ 10 files, +356 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 614 passed (33 s)
rustfmt ✅ (6 s)
clippy ✅ (1 min 22 s)
tests: horizon-client, horizon-client-lib, xtask ✅ 2180 passed (57 s)
doc tests ✅ 0 passed (1 min 2 s)
content root tests ➖ content root untouched
mod API up to date ✅ (12 s)
tokens.css up to date ✅
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 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/7563 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `modapi/living-refs` --- ### 📝 Commits (2) - [`5030e21`](https://github.com/horizon-rust/horizon/commit/5030e219c98b13db1ff9ea85e5fddb94abc5f6d6) Native mods: living entity handles (LivingRef) and a living entity's equipment (#7387) - [`4981881`](https://github.com/horizon-rust/horizon/commit/49818818f06c609a53ebfef829cf01659f76d689) Merge main into modapi/living-refs ### 📊 Changes **10 files changed** (+356 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/commands.rs` (+1 -1) 📝 `crates/horizon-client/src/game/mod_api_host_generated.rs` (+17 -0) 📝 `crates/horizon-client/src/game/native_entity_refs.rs` (+1 -1) ➕ `crates/horizon-client/src/game/native_living_refs.rs` (+199 -0) 📝 `crates/horizon-client/src/mod_api.rs` (+31 -0) 📝 `crates/horizon-client/src/mod_api/generated_host.rs` (+66 -0) 📝 `docs/native-mods.md` (+6 -0) ➕ `tools/native-hook-fragments/living_refs.json` (+29 -0) 📝 `xtask/src/mod_api.rs` (+5 -1) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally. **Stacked on #7454** (draft until it merges; until then, review only the last commit). Part of #7387, on top of #7454: **LivingRef** and the line **LivingRef equipment and hands**. The tracker's LivingRef health and effects lines are Qwerner88880's and aren't touched here ([comment](https://github.com/horizon-rust/horizon/issues/7387#issuecomment-6583124249)). ## What it adds - **`LivingRef`** (wraps an `EntityRef`; `entity()`, `id()`, `From<LivingRef> for EntityRef`) and the bridge `host.living(entity)`. It resolves for a mob, a player, an armor stand or the dragon (vanilla's `LivingEntity`), and is `None` for anything else. - The generator's `HANDLES` table gains `living`, so `"receiver": "living"` entries become `LivingRef` methods. - `mod_api` re-exports `EquipmentSlot`. - `equipment(host, slot)` and `hand_item(host, hand)`: `getItemBySlot` / `getItemInHand`. A player's slots come from its inventory, armour and off hand. Another server player's come from their guest state. - `set_equipment(host, slot, stack)`: `setItemSlot`, through the same slot code as `/item replace entity` (`slots_named` and `slot_set`; `commands::items` becomes `pub(in crate::game)`). `None` empties the slot. It returns false where the entity has no such slot: a player has no body slot, a horse keeps its armour where a zombie keeps its helmet, so each refuses the other, and the dragon has none. A mob's saddle can't be set yet, and a mob keeps one item outside its main hand, as `/item` does today. ## Proof The probe bundle from #7454, run on this branch's fast build, server thread, offscreen, scratch homes. Every 300 ticks it sets the head, body, saddle and off hand, empties the main hand, then reads them back: ``` ENTPROBE setequip kind=minecraft:armor_stand head=true body=false saddle=false off=true main_empty=true now head=Some("minecraft:carved_pumpkinx1") body=None off=Some("minecraft:torchx3") main=None ENTPROBE setequip kind=minecraft:horse head=false body=true saddle=false off=true main_empty=true now head=None body=Some("minecraft:diamond_horse_armorx1") off=Some("minecraft:torchx1") main=None ENTPROBE setequip kind=minecraft:player head=true body=false saddle=false off=true main_empty=true now head=Some("minecraft:carved_pumpkinx1") body=None off=Some("minecraft:torchx3") main=None ENTPROBE setequip kind=minecraft:zombie head=true body=false saddle=false off=true main_empty=true now head=Some("minecraft:carved_pumpkinx1") body=None off=Some("minecraft:torchx1") main=None ENTPROBE living kind=minecraft:armor_stand main=None off=None head=None feet=None body=None back=true ENTPROBE living kind=minecraft:armor_stand main=None off=Some("minecraft:torch") head=Some("minecraft:carved_pumpkin") feet=None body=None back=true ENTPROBE living kind=minecraft:player main=None off=None head=None feet=None body=None back=true ENTPROBE living kind=minecraft:player main=None off=Some("minecraft:torch") head=Some("minecraft:carved_pumpkin") feet=None body=None back=true ENTPROBE not_living kind=minecraft:item_display ``` - Head and off hand work on the player, the armor stand and the zombie. - The horse takes body armour and refuses a head item. - The zombie refuses a body item, so it keeps its helmet. (A first draft overwrote it; this caught it.) - The item display isn't living. **pr_ready** (`tools/pr_ready.py --quick --base modapi/entity-handles` on cachyos-x8664, against modapi/entity-handles at 7b77a5ec9, 4 min 13 s) | Check | Result | | --- | --- | | Scope | ✅ 10 files, +356 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 614 passed (33 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (1 min 22 s) | | tests: horizon-client, horizon-client-lib, xtask | ✅ 2180 passed (57 s) | | doc tests | ✅ 0 passed (1 min 2 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (12 s) | | tokens.css up to date | ✅ | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 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>
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#7672
No description provided.