[PR #7690] Native mods: teleport, rotation, head yaw, facing, size and pushes through EntityRef (#7387) #7765

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

📋 Pull Request Information

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

Base: main ← Head: modapi/entity-moves


📝 Commits (4)

  • b21901f Native mods: entity and level handles, and an entity's position, type, UUID and level (#7387)
  • 7b77a5e Merge main into modapi/entity-handles
  • 464d554 Native mods: an entity's velocity, ground, box, eyes and view through EntityRef (#7387)
  • d48b349 Native mods: teleport, rotation, head yaw, facing, size and pushes through EntityRef (#7387)

📊 Changes

17 files changed (+1150 additions, -9 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+3 -0)
📝 crates/horizon-client/src/game/commands.rs (+6 -1)
📝 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 (+74 -0)
📝 crates/horizon-client/src/game/native_entities.rs (+5 -5)
➕ crates/horizon-client/src/game/native_entity_motion.rs (+142 -0)
➕ crates/horizon-client/src/game/native_entity_moves.rs (+151 -0)
➕ crates/horizon-client/src/game/native_entity_refs.rs (+114 -0)
📝 crates/horizon-client/src/game/native_lifecycle.rs (+6 -0)
📝 crates/horizon-client/src/mod_api.rs (+53 -1)
📝 crates/horizon-client/src/mod_api/generated_host.rs (+290 -0)
📝 docs/native-mods.md (+20 -0)
➕ tools/native-hook-fragments/entity_handles.json (+48 -0)
➕ tools/native-hook-fragments/entity_motion.json (+50 -0)
➕ tools/native-hook-fragments/entity_moves.json (+45 -0)
📝 xtask/src/mod_api.rs (+137 -1)

📄 Description

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

Stacked on #7454 and #7560 (draft until they merge; review only the last commit).

Part of #7387: more of the EntityRef position and movement line, which is mine (claim). It covers teleport (42 mod calls), set_rotation (22), dimensions (12), direction (11), push (7), head_yaw and set_head_yaw (4 each).

What it adds

EntityRef methods, in a new native_entity_moves.rs:

  • teleport_to(host, pos, rotation): Entity.teleportTo. It moves the entity within its level the way /tp does, through the same teleport_to, for every kind: a player is placed and told, a rider gets off, a mob's head and body turn with rotation. It's false outside the world's bounds (30,000,000 out, 20,000,000 up or down) or for a non-finite value. The name avoids the existing entity_teleport hook.
  • set_rotation(host, yaw, pitch): setYRot/setXRot, the way /rotate turns the entity (pitch clamped to −90..90, a player's client told).
  • head_yaw(host) and set_head_yaw(host, yaw): getYHeadRot/setYHeadRot. A mob's head can be set; for the other kinds the set returns false.
  • direction(host): Entity.getDirection (Direction.fromYRot), one of north, south, east or west.
  • dimensions(host): getBbWidth/getBbHeight, read from the entity's box, so it is right for babies and scaled entities.
  • push(host, delta): Entity.push/addDeltaMovement. It adds to the velocity with the same rules as set_velocity in #7560: false for a player, whose client moves it.

teleport_to in commands.rs becomes pub(in crate::game). native_walk_entity and native_target_guest in native_entity_motion.rs become pub(super).

Proof

A probe bundle (HEAD injection at Game::tick_mobs) ran on this branch's fast build, server thread, offscreen, in scratch homes. The test entities were two NoAI zombies (one a baby), an armor stand and a pig, plus the player and the world's own pigs. At tick 260 the probe teleports each by (+3, 0, +1) and rotation (90, 30), and tries a far, a NaN and a stale teleport. At tick 300 it calls set_rotation(-135, 120), set_head_yaw(10) and push(0, 0.8, 0).

tick=200 read id=711 kind=minecraft:zombie pos=Some([-22.5, 65.0, 12.5]) rot=Some([0.0, 0.0]) head=Some(0.0) dir=Some("south") dims=Some([0.6000000238418579, 1.9500000476837158]) vel=Some([0.0, 0.0, 0.0])
tick=200 read id=712 kind=minecraft:zombie ... dims=Some([0.49000000953674316, 0.9800000190734863])
tick=200 read id=290 kind=minecraft:pig ... dims=Some([0.44999998807907104, 0.44999998807907104])
tick=260 teleport id=1 kind=minecraft:player moved=true far=false nan=false stale=false
tick=260 after_teleport id=1 kind=minecraft:player pos=Some([-23.5, 65.0, 9.5]) rot=Some([90.0, 30.0]) head=Some(0.0) dir=Some("west") ...
tick=260 after_teleport id=711 kind=minecraft:zombie pos=Some([-19.5, 65.0, 13.5]) rot=Some([90.0, 30.0]) head=Some(90.0) dir=Some("west") ...
tick=260 after_teleport id=713 kind=minecraft:armor_stand pos=Some([-23.5, 65.0, 4.5]) rot=Some([90.0, 0.0]) head=Some(90.0) dir=Some("west") ...
tick=300 turn id=1 kind=minecraft:player set_rotation=true set_head_yaw=false push=false
tick=300 turn id=711 kind=minecraft:zombie set_rotation=true set_head_yaw=true push=true
tick=300 after_turn id=711 kind=minecraft:zombie ... rot=Some([-135.0, 90.0]) head=Some(10.0) dir=Some("east") ... vel=Some([0.0, 0.8, 0.0])
tick=300 after_turn id=713 kind=minecraft:armor_stand ... rot=Some([-135.0, 0.0]) head=Some(-135.0) dir=Some("east") ... vel=Some([0.0, 0.7215999984741212, 0.0])
tick=320 later id=1 kind=minecraft:player pos=Some([-23.5, 65.0, 9.5]) rot=Some([-135.0, 90.0]) head=Some(-135.0) dir=Some("east") ...
  • Every kind moves by the offset and turns. The far, NaN and stale teleports are refused.
  • The pitch of 120 is clamped to 90, as /rotate does.
  • The player's head yaw follows once its client reports the turn (tick 320).
  • The baby zombie's 0.49×0.98 is vanilla 26.3's Zombie.BABY_DIMENSIONS, and the piglet is half a pig.
  • The armor stand's push shows in its velocity before gravity takes over. The NoAI mobs keep the pushed velocity, since NoAI doesn't move them.

pr_ready (tools/pr_ready.py --quick --base hr/main on cachyos-x8664, against hr/main at b09827e93, 4 min 30 s)

Check Result
Scope ⚠️ 17 files, +1150 −9; 1139 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 614 passed (32 s)
rustfmt ✅ (7 s)
clippy ✅ (1 min 14 s)
tests: horizon-client, horizon-client-lib, xtask ✅ 2181 passed (1 min 24 s)
doc tests ✅ 0 passed (1 min 1 s)
content root tests ➖ content root untouched
mod API up to date ✅ (11 s)
tokens.css up to date ✅ (1 s)
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)

The scope line counts #7454 and #7560, which this stacks on; this PR's own commit is 7 files changed, 341 insertions(+), 3 deletions(-).

🤖 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/7690 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `modapi/entity-moves` --- ### 📝 Commits (4) - [`b21901f`](https://github.com/horizon-rust/horizon/commit/b21901f67698b54bb46148a0409769ce9e24c8d5) Native mods: entity and level handles, and an entity's position, type, UUID and level (#7387) - [`7b77a5e`](https://github.com/horizon-rust/horizon/commit/7b77a5ec989f448298572d44dee9ab84fe38cb50) Merge main into modapi/entity-handles - [`464d554`](https://github.com/horizon-rust/horizon/commit/464d5544eb53fc1a56195310efd409b597b0a710) Native mods: an entity's velocity, ground, box, eyes and view through EntityRef (#7387) - [`d48b349`](https://github.com/horizon-rust/horizon/commit/d48b349d72deaa9617d7f4f81ffb73d1b4a7f909) Native mods: teleport, rotation, head yaw, facing, size and pushes through EntityRef (#7387) ### 📊 Changes **17 files changed** (+1150 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+3 -0) 📝 `crates/horizon-client/src/game/commands.rs` (+6 -1) 📝 `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` (+74 -0) 📝 `crates/horizon-client/src/game/native_entities.rs` (+5 -5) ➕ `crates/horizon-client/src/game/native_entity_motion.rs` (+142 -0) ➕ `crates/horizon-client/src/game/native_entity_moves.rs` (+151 -0) ➕ `crates/horizon-client/src/game/native_entity_refs.rs` (+114 -0) 📝 `crates/horizon-client/src/game/native_lifecycle.rs` (+6 -0) 📝 `crates/horizon-client/src/mod_api.rs` (+53 -1) 📝 `crates/horizon-client/src/mod_api/generated_host.rs` (+290 -0) 📝 `docs/native-mods.md` (+20 -0) ➕ `tools/native-hook-fragments/entity_handles.json` (+48 -0) ➕ `tools/native-hook-fragments/entity_motion.json` (+50 -0) ➕ `tools/native-hook-fragments/entity_moves.json` (+45 -0) 📝 `xtask/src/mod_api.rs` (+137 -1) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally. **Stacked on #7454 and #7560** (draft until they merge; review only the last commit). Part of #7387: more of the EntityRef **position and movement** line, which is mine ([claim](https://github.com/horizon-rust/horizon/issues/7387#issuecomment-6581551573)). It covers `teleport` (42 mod calls), `set_rotation` (22), `dimensions` (12), `direction` (11), `push` (7), `head_yaw` and `set_head_yaw` (4 each). ## What it adds `EntityRef` methods, in a new `native_entity_moves.rs`: - `teleport_to(host, pos, rotation)`: `Entity.teleportTo`. It moves the entity within its level the way `/tp` does, through the same `teleport_to`, for every kind: a player is placed and told, a rider gets off, a mob's head and body turn with `rotation`. It's false outside the world's bounds (30,000,000 out, 20,000,000 up or down) or for a non-finite value. The name avoids the existing `entity_teleport` hook. - `set_rotation(host, yaw, pitch)`: `setYRot`/`setXRot`, the way `/rotate` turns the entity (pitch clamped to −90..90, a player's client told). - `head_yaw(host)` and `set_head_yaw(host, yaw)`: `getYHeadRot`/`setYHeadRot`. A mob's head can be set; for the other kinds the set returns false. - `direction(host)`: `Entity.getDirection` (`Direction.fromYRot`), one of `north`, `south`, `east` or `west`. - `dimensions(host)`: `getBbWidth`/`getBbHeight`, read from the entity's box, so it is right for babies and scaled entities. - `push(host, delta)`: `Entity.push`/`addDeltaMovement`. It adds to the velocity with the same rules as `set_velocity` in #7560: false for a player, whose client moves it. `teleport_to` in `commands.rs` becomes `pub(in crate::game)`. `native_walk_entity` and `native_target_guest` in `native_entity_motion.rs` become `pub(super)`. ## Proof A probe bundle (HEAD injection at `Game::tick_mobs`) ran on this branch's fast build, server thread, offscreen, in scratch homes. The test entities were two NoAI zombies (one a baby), an armor stand and a pig, plus the player and the world's own pigs. At tick 260 the probe teleports each by (+3, 0, +1) and rotation (90, 30), and tries a far, a NaN and a stale teleport. At tick 300 it calls `set_rotation(-135, 120)`, `set_head_yaw(10)` and `push(0, 0.8, 0)`. ``` tick=200 read id=711 kind=minecraft:zombie pos=Some([-22.5, 65.0, 12.5]) rot=Some([0.0, 0.0]) head=Some(0.0) dir=Some("south") dims=Some([0.6000000238418579, 1.9500000476837158]) vel=Some([0.0, 0.0, 0.0]) tick=200 read id=712 kind=minecraft:zombie ... dims=Some([0.49000000953674316, 0.9800000190734863]) tick=200 read id=290 kind=minecraft:pig ... dims=Some([0.44999998807907104, 0.44999998807907104]) tick=260 teleport id=1 kind=minecraft:player moved=true far=false nan=false stale=false tick=260 after_teleport id=1 kind=minecraft:player pos=Some([-23.5, 65.0, 9.5]) rot=Some([90.0, 30.0]) head=Some(0.0) dir=Some("west") ... tick=260 after_teleport id=711 kind=minecraft:zombie pos=Some([-19.5, 65.0, 13.5]) rot=Some([90.0, 30.0]) head=Some(90.0) dir=Some("west") ... tick=260 after_teleport id=713 kind=minecraft:armor_stand pos=Some([-23.5, 65.0, 4.5]) rot=Some([90.0, 0.0]) head=Some(90.0) dir=Some("west") ... tick=300 turn id=1 kind=minecraft:player set_rotation=true set_head_yaw=false push=false tick=300 turn id=711 kind=minecraft:zombie set_rotation=true set_head_yaw=true push=true tick=300 after_turn id=711 kind=minecraft:zombie ... rot=Some([-135.0, 90.0]) head=Some(10.0) dir=Some("east") ... vel=Some([0.0, 0.8, 0.0]) tick=300 after_turn id=713 kind=minecraft:armor_stand ... rot=Some([-135.0, 0.0]) head=Some(-135.0) dir=Some("east") ... vel=Some([0.0, 0.7215999984741212, 0.0]) tick=320 later id=1 kind=minecraft:player pos=Some([-23.5, 65.0, 9.5]) rot=Some([-135.0, 90.0]) head=Some(-135.0) dir=Some("east") ... ``` - Every kind moves by the offset and turns. The far, NaN and stale teleports are refused. - The pitch of 120 is clamped to 90, as `/rotate` does. - The player's head yaw follows once its client reports the turn (tick 320). - The baby zombie's 0.49×0.98 is vanilla 26.3's `Zombie.BABY_DIMENSIONS`, and the piglet is half a pig. - The armor stand's push shows in its velocity before gravity takes over. The NoAI mobs keep the pushed velocity, since NoAI doesn't move them. **pr_ready** (`tools/pr_ready.py --quick --base hr/main` on cachyos-x8664, against hr/main at b09827e93, 4 min 30 s) | Check | Result | | --- | --- | | Scope | ⚠️ 17 files, +1150 −9; 1139 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 614 passed (32 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (1 min 14 s) | | tests: horizon-client, horizon-client-lib, xtask | ✅ 2181 passed (1 min 24 s) | | doc tests | ✅ 0 passed (1 min 1 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (11 s) | | tokens.css up to date | ✅ (1 s) | | 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) | The scope line counts #7454 and #7560, which this stacks on; this PR's own commit is 7 files changed, 341 insertions(+), 3 deletions(-). 🤖 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#7765
No description provided.