[PR #7560] Native mods: an entity's velocity, ground, box, eyes and view through EntityRef (#7387) #7670

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

📋 Pull Request Information

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

Base: main ← Head: modapi/entity-motion


📝 Commits (2)

  • 464d554 Native mods: an entity's velocity, ground, box, eyes and view through EntityRef (#7387)
  • da40587 Merge main into modapi/entity-motion

📊 Changes

9 files changed (+324 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/commands/execute.rs (+1 -1)
📝 crates/horizon-client/src/game/entity.rs (+5 -0)
📝 crates/horizon-client/src/game/mod_api_host_generated.rs (+24 -0)
➕ crates/horizon-client/src/game/native_entity_motion.rs (+139 -0)
📝 crates/horizon-client/src/game/native_entity_refs.rs (+1 -1)
📝 crates/horizon-client/src/mod_api/generated_host.rs (+100 -0)
📝 docs/native-mods.md (+3 -0)
➕ tools/native-hook-fragments/entity_motion.json (+50 -0)

📄 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: the rest of EntityRef position and movement that the game can answer today.

What it adds

EntityRef methods (catalog entries with "receiver": "entity"):

  • velocity(host): Entity.getDeltaMovement. A player's is the move its client last reported, as getKnownMovement. An entity Horizon doesn't simulate (a display, a painting) has zero.
  • set_velocity(host, v): setDeltaMovement, with the mob marked for sync so clients see it. It returns false for players (their client moves them), for entities Horizon doesn't simulate, and for values that aren't finite.
  • on_ground, bounding_box (lowest and highest corner; None for the kinds whose box Horizon doesn't keep), eye_height, eye_position, view_vector (horizon_world::view_direction::view_vector, vanilla's calculateViewVector) and distance_to_sqr(host, pos).

To support them:

  • The game's Entity trait (game/entity.rs) gains fn velocity(&self) -> Vec3, which the stored_motion! macro implements.
  • target_eye_height becomes pub(in crate::game).

Proof

The probe bundle from #7454, run on this branch's fast build, server thread, offscreen, scratch homes. A NoAI zombie is pushed up with set_velocity([0, 0.9, 0]), then read on the following ticks. In an earlier open-air run, gravity and drag took it 0.9 → 0.8036 → 0.709 → 0.617. In this run it was in a cave and hit the ceiling on the second tick.

ENTPROBE set_velocity id=25 -> true nan=false readback=Some([0.0, 0.9, 0.0])
ENTPROBE after_push tick=151 id=25 pos=Some([-64.71691780088281, -47.1, -0.7057306118717479]) vel=Some([0.0, 0.8036000156402588, 0.0]) ground=Some(false)
ENTPROBE after_push tick=152 id=25 pos=Some([-64.71691780088281, -46.980000019073486, -0.7057306118717479]) vel=Some([0.0, -0.0784000015258789, 0.0]) ground=Some(false)
ENTPROBE after_push tick=153 id=25 pos=Some([-64.71691780088281, -47.058400020599365, -0.7057306118717479]) vel=Some([0.0, -0.1552320045166016, 0.0]) ground=Some(false)
ENTPROBE motion kind=minecraft:player pos=Some([-28.5, 69.0, 0.5]) vel=Some([0.0, 0.0, 0.0]) ground=Some(true) box=Some([[-28.80000001192093, 69.0, 0.19999998807907104], [-28.19999998807907, 70.79999995231628, 0.800000011920929]]) eye_h=Some(1.6200000047683716) eye=Some([-28.5, 70.62000000476837, 0.5]) view=Some([0.0, -0.0, 1.0]) d2_origin=Some(5573.5)
ENTPROBE motion kind=minecraft:armor_stand pos=Some([-28.5, 69.0, 3.5]) vel=Some([0.0, -0.0784000015258789, 0.0]) ground=Some(true) box=Some([[-28.75, 69.0, 3.25], [-28.25, 70.975, 3.75]]) eye_h=Some(1.777500033378601) eye=Some([-28.5, 70.7775000333786, 3.5]) view=Some([0.0, -0.0, 1.0]) d2_origin=Some(5585.5)
ENTPROBE motion kind=minecraft:item_display pos=Some([-31.5, 70.0, 0.5]) vel=Some([0.0, 0.0, 0.0]) ground=Some(false) box=None eye_h=Some(0.0) eye=Some([-31.5, 70.0, 0.5]) view=Some([0.0, -0.0, 1.0]) d2_origin=Some(5892.5)
ENTPROBE motion id=25 kind=minecraft:zombie pos=Some([-67.99281742434368, -49.0, -1.5600329371087]) vel=Some([0.11827066470771148, -0.0784000015258789, 0.00025443948781237125]) ground=Some(true) box=Some([[-68.23781742911206, -49.0, -1.8050329418770716], [-67.74781741957531, -48.019999980926514, -1.3150329323403285]]) eye_h=Some(0.7749999761581421) eye=Some([-67.99281742434368, -48.22500002384186, -1.5600329371087]) view=Some([0.9963862895965576, -0.0, 0.08493759483098984]) d2_origin=Some(7026.456924064999)
ENTPROBE player set_velocity=false
  • The armor stand's box is 0.5 × 1.975, and the player's is 0.6 × 1.8 with eyes at 1.62.
  • The item display has no box, which Horizon doesn't keep for displays.
  • A NaN velocity and a player's velocity are refused.

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

Check Result
Scope ✅ 9 files, +324 −2
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 614 passed (44 s)
rustfmt ✅ (6 s)
clippy ✅ (1 min 27 s)
tests: horizon-client, horizon-client-lib ✅ 2159 passed (1 min 5 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
mod API up to date ✅ (11 s)
tokens.css up to date ➖ theme untouched
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/7560 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `modapi/entity-motion` --- ### 📝 Commits (2) - [`464d554`](https://github.com/horizon-rust/horizon/commit/464d5544eb53fc1a56195310efd409b597b0a710) Native mods: an entity's velocity, ground, box, eyes and view through EntityRef (#7387) - [`da40587`](https://github.com/horizon-rust/horizon/commit/da4058715dc295f15bd2687b7f210c5a26257c57) Merge main into modapi/entity-motion ### 📊 Changes **9 files changed** (+324 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/commands/execute.rs` (+1 -1) 📝 `crates/horizon-client/src/game/entity.rs` (+5 -0) 📝 `crates/horizon-client/src/game/mod_api_host_generated.rs` (+24 -0) ➕ `crates/horizon-client/src/game/native_entity_motion.rs` (+139 -0) 📝 `crates/horizon-client/src/game/native_entity_refs.rs` (+1 -1) 📝 `crates/horizon-client/src/mod_api/generated_host.rs` (+100 -0) 📝 `docs/native-mods.md` (+3 -0) ➕ `tools/native-hook-fragments/entity_motion.json` (+50 -0) </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: the rest of **EntityRef position and movement** that the game can answer today. ## What it adds `EntityRef` methods (catalog entries with `"receiver": "entity"`): - `velocity(host)`: `Entity.getDeltaMovement`. A player's is the move its client last reported, as `getKnownMovement`. An entity Horizon doesn't simulate (a display, a painting) has zero. - `set_velocity(host, v)`: `setDeltaMovement`, with the mob marked for sync so clients see it. It returns false for players (their client moves them), for entities Horizon doesn't simulate, and for values that aren't finite. - `on_ground`, `bounding_box` (lowest and highest corner; `None` for the kinds whose box Horizon doesn't keep), `eye_height`, `eye_position`, `view_vector` (`horizon_world::view_direction::view_vector`, vanilla's `calculateViewVector`) and `distance_to_sqr(host, pos)`. To support them: - The game's `Entity` trait (`game/entity.rs`) gains `fn velocity(&self) -> Vec3`, which the `stored_motion!` macro implements. - `target_eye_height` becomes `pub(in crate::game)`. ## Proof The probe bundle from #7454, run on this branch's fast build, server thread, offscreen, scratch homes. A NoAI zombie is pushed up with `set_velocity([0, 0.9, 0])`, then read on the following ticks. In an earlier open-air run, gravity and drag took it 0.9 → 0.8036 → 0.709 → 0.617. In this run it was in a cave and hit the ceiling on the second tick. ``` ENTPROBE set_velocity id=25 -> true nan=false readback=Some([0.0, 0.9, 0.0]) ENTPROBE after_push tick=151 id=25 pos=Some([-64.71691780088281, -47.1, -0.7057306118717479]) vel=Some([0.0, 0.8036000156402588, 0.0]) ground=Some(false) ENTPROBE after_push tick=152 id=25 pos=Some([-64.71691780088281, -46.980000019073486, -0.7057306118717479]) vel=Some([0.0, -0.0784000015258789, 0.0]) ground=Some(false) ENTPROBE after_push tick=153 id=25 pos=Some([-64.71691780088281, -47.058400020599365, -0.7057306118717479]) vel=Some([0.0, -0.1552320045166016, 0.0]) ground=Some(false) ENTPROBE motion kind=minecraft:player pos=Some([-28.5, 69.0, 0.5]) vel=Some([0.0, 0.0, 0.0]) ground=Some(true) box=Some([[-28.80000001192093, 69.0, 0.19999998807907104], [-28.19999998807907, 70.79999995231628, 0.800000011920929]]) eye_h=Some(1.6200000047683716) eye=Some([-28.5, 70.62000000476837, 0.5]) view=Some([0.0, -0.0, 1.0]) d2_origin=Some(5573.5) ENTPROBE motion kind=minecraft:armor_stand pos=Some([-28.5, 69.0, 3.5]) vel=Some([0.0, -0.0784000015258789, 0.0]) ground=Some(true) box=Some([[-28.75, 69.0, 3.25], [-28.25, 70.975, 3.75]]) eye_h=Some(1.777500033378601) eye=Some([-28.5, 70.7775000333786, 3.5]) view=Some([0.0, -0.0, 1.0]) d2_origin=Some(5585.5) ENTPROBE motion kind=minecraft:item_display pos=Some([-31.5, 70.0, 0.5]) vel=Some([0.0, 0.0, 0.0]) ground=Some(false) box=None eye_h=Some(0.0) eye=Some([-31.5, 70.0, 0.5]) view=Some([0.0, -0.0, 1.0]) d2_origin=Some(5892.5) ENTPROBE motion id=25 kind=minecraft:zombie pos=Some([-67.99281742434368, -49.0, -1.5600329371087]) vel=Some([0.11827066470771148, -0.0784000015258789, 0.00025443948781237125]) ground=Some(true) box=Some([[-68.23781742911206, -49.0, -1.8050329418770716], [-67.74781741957531, -48.019999980926514, -1.3150329323403285]]) eye_h=Some(0.7749999761581421) eye=Some([-67.99281742434368, -48.22500002384186, -1.5600329371087]) view=Some([0.9963862895965576, -0.0, 0.08493759483098984]) d2_origin=Some(7026.456924064999) ENTPROBE player set_velocity=false ``` - The armor stand's box is 0.5 × 1.975, and the player's is 0.6 × 1.8 with eyes at 1.62. - The item display has no box, which Horizon doesn't keep for displays. - A NaN velocity and a player's velocity are refused. **pr_ready** (`tools/pr_ready.py --quick --base modapi/entity-handles` on cachyos-x8664, against modapi/entity-handles at 7b77a5ec9, 3 min 37 s) | Check | Result | | --- | --- | | Scope | ✅ 9 files, +324 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 614 passed (44 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (1 min 27 s) | | tests: horizon-client, horizon-client-lib | ✅ 2159 passed (1 min 5 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (11 s) | | tokens.css up to date | ➖ theme untouched | | 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#7670
No description provided.