[PR #7685] Native mods: an entity's state flags through EntityRef (#7387) #7760

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

📋 Pull Request Information

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

Base: main ← Head: modapi/entity-state


📝 Commits (2)

  • d68ada1 Native mods: an entity's state flags through EntityRef (#7387)
  • 9a344e0 Merge main into modapi/entity-state

📊 Changes

6 files changed (+503 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/mod_api_host_generated.rs (+39 -0)
📝 crates/horizon-client/src/game/native_entity_refs.rs (+1 -1)
➕ crates/horizon-client/src/game/native_entity_state.rs (+237 -0)
📝 crates/horizon-client/src/mod_api/generated_host.rs (+150 -0)
➕ tools/native-hook-fragments/entity_state.json (+75 -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; review only the last commit).

Part of #7387: the EntityRef state flags line, the most-called flags first (claim).

What it adds

EntityRef methods, in a new native_entity_state.rs:

Method Vanilla Players Mobs Other kinds
is_shift_key_down Entity.isShiftKeyDown sneak key held false false
is_crouching Entity.isCrouching crouching pose crouching pose false
is_sprinting Entity.isSprinting ✓ false false
is_in_water, is_in_lava isInWater, isInLava ✓ ✓ None
fire_immune EntityType.fireImmune false ✓ (blaze, strider...) None
fire_ticks getRemainingFireTicks ✓ ✓ armor stands, items; else None
air_supply, max_air_supply getAirSupply, getMaxAirSupply ✓ ✓ (dolphin 4800, axolotl 6000) max only (300)
is_silent, set_silent isSilent, setSilent false; set refused ✓ None; set refused
is_invisible isInvisible invisibility effect flag or effect armor stand flag; else None
pose getPose ✓ ✓, by sync::pose_id (warden, breeze, camel, frog...) "standing"

A pose is named as Pose's serialized names name it (standing, crouching, sitting, roaring...). The flags read the same state the game already keeps: a player's PlayerMotion (the acting player's, or the guest's), a mob's Mob fields. None means a stale handle, a client, or a flag Horizon keeps no state for on that kind. native_entity_target becomes pub(super), as in the other slices.

Proof

A probe bundle (HEAD injection at Game::tick_mobs) printed the flags of the player and a set of summoned mobs every 50 server ticks. It ran on this branch's fast build, server thread, offscreen, in scratch homes. The summoned mobs were:

  • a NoAI zombie in a water pool;
  • a dolphin and an axolotl on land, the dolphin with invisibility;
  • a blaze in lava;
  • a zombie with {Fire:300s,Silent:1b};
  • an invisible armor stand, a cat, an item and an arrow.

The player held shift for 4 s and then got invisibility.

tick=125 id=652 kind=minecraft:zombie ... water=Some(true) lava=Some(false) fire_immune=Some(false) fire=Some(0) air=Some(300)/Some(300) silent=Some(false) ...
tick=125 id=653 kind=minecraft:dolphin ... water=Some(false) ... air=Some(290)/Some(4800) silent=Some(false) invisible=Some(true) pose=Some("standing")
tick=125 id=654 kind=minecraft:axolotl ... air=Some(336)/Some(6000) ...
tick=125 id=656 kind=minecraft:blaze ... water=Some(false) lava=Some(true) fire_immune=Some(true) ...
tick=125 id=657 kind=minecraft:zombie ... fire=Some(295) air=Some(300)/Some(300) silent=Some(true) ...
tick=125 id=658 kind=minecraft:armor_stand ... water=None lava=None fire_immune=None fire=Some(0) air=None/Some(300) silent=None invisible=Some(true) pose=Some("standing")
tick=125 id=662 kind=minecraft:arrow ... water=None lava=None fire_immune=None fire=None air=None/Some(300) silent=None invisible=None pose=Some("standing")
tick=175 id=653 kind=minecraft:dolphin ... air=Some(240)/Some(4800) ...
tick=175 id=657 kind=minecraft:zombie ... fire=Some(245) ... silent=Some(true) ...
tick=225 id=1 kind=minecraft:player shift=Some(true) crouch=Some(true) sprint=Some(false) ... fire=Some(-20) air=Some(300)/Some(300) silent=Some(false) invisible=Some(false) pose=Some("crouching")
STPROBE set_silent player -> false
STPROBE set_silent id=652 -> true now=Some(true)
tick=375 id=1 kind=minecraft:player shift=Some(false) crouch=Some(false) ... invisible=Some(true) pose=Some("standing")
  • The zombie in the pool is in water. The blaze is in lava and fire-immune.
  • The dolphin on land loses air against its 4800 maximum, and its invisibility effect counts.
  • The burning zombie's fire ticks count down from 300, and it reads as silent.
  • Sneaking turns on shift, crouching and the crouching pose; the effect makes the player invisible.
  • set_silent silences a mob and is refused for the player.
  • The player's -20 fire ticks is vanilla's resting value.

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

Check Result
Scope ⚠️ 12 files, +990 −7; 980 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 ✅ (6 s)
clippy ✅ (1 min 11 s)
tests: horizon-client, horizon-client-lib, xtask ✅ 2180 passed (1 min 16 s)
doc tests ✅ 0 passed (1 min 34 s)
content root tests ➖ content root untouched
mod API up to date ✅ (13 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)

The scope line counts #7454, which this stacks on; this PR's own commit is 6 files changed, 503 insertions(+), 1 deletion(-).

🤖 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/7685 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `modapi/entity-state` --- ### 📝 Commits (2) - [`d68ada1`](https://github.com/horizon-rust/horizon/commit/d68ada1e1361f48957227a558446a81f4e2f8ba4) Native mods: an entity's state flags through EntityRef (#7387) - [`9a344e0`](https://github.com/horizon-rust/horizon/commit/9a344e0c316d3f04dbe082b5257d7cbc94e386ef) Merge main into modapi/entity-state ### 📊 Changes **6 files changed** (+503 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/mod_api_host_generated.rs` (+39 -0) 📝 `crates/horizon-client/src/game/native_entity_refs.rs` (+1 -1) ➕ `crates/horizon-client/src/game/native_entity_state.rs` (+237 -0) 📝 `crates/horizon-client/src/mod_api/generated_host.rs` (+150 -0) ➕ `tools/native-hook-fragments/entity_state.json` (+75 -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; review only the last commit). Part of #7387: the EntityRef **state flags** line, the most-called flags first ([claim](https://github.com/horizon-rust/horizon/issues/7387#issuecomment-6586075209)). ## What it adds `EntityRef` methods, in a new `native_entity_state.rs`: | Method | Vanilla | Players | Mobs | Other kinds | | --- | --- | --- | --- | --- | | `is_shift_key_down` | `Entity.isShiftKeyDown` | sneak key held | false | false | | `is_crouching` | `Entity.isCrouching` | crouching pose | crouching pose | false | | `is_sprinting` | `Entity.isSprinting` | ✓ | false | false | | `is_in_water`, `is_in_lava` | `isInWater`, `isInLava` | ✓ | ✓ | `None` | | `fire_immune` | `EntityType.fireImmune` | false | ✓ (blaze, strider...) | `None` | | `fire_ticks` | `getRemainingFireTicks` | ✓ | ✓ | armor stands, items; else `None` | | `air_supply`, `max_air_supply` | `getAirSupply`, `getMaxAirSupply` | ✓ | ✓ (dolphin 4800, axolotl 6000) | max only (300) | | `is_silent`, `set_silent` | `isSilent`, `setSilent` | false; set refused | ✓ | `None`; set refused | | `is_invisible` | `isInvisible` | invisibility effect | flag or effect | armor stand flag; else `None` | | `pose` | `getPose` | ✓ | ✓, by `sync::pose_id` (warden, breeze, camel, frog...) | `"standing"` | A pose is named as `Pose`'s serialized names name it (`standing`, `crouching`, `sitting`, `roaring`...). The flags read the same state the game already keeps: a player's `PlayerMotion` (the acting player's, or the guest's), a mob's `Mob` fields. `None` means a stale handle, a client, or a flag Horizon keeps no state for on that kind. `native_entity_target` becomes `pub(super)`, as in the other slices. ## Proof A probe bundle (HEAD injection at `Game::tick_mobs`) printed the flags of the player and a set of summoned mobs every 50 server ticks. It ran on this branch's fast build, server thread, offscreen, in scratch homes. The summoned mobs were: - a NoAI zombie in a water pool; - a dolphin and an axolotl on land, the dolphin with invisibility; - a blaze in lava; - a zombie with `{Fire:300s,Silent:1b}`; - an invisible armor stand, a cat, an item and an arrow. The player held shift for 4 s and then got invisibility. ``` tick=125 id=652 kind=minecraft:zombie ... water=Some(true) lava=Some(false) fire_immune=Some(false) fire=Some(0) air=Some(300)/Some(300) silent=Some(false) ... tick=125 id=653 kind=minecraft:dolphin ... water=Some(false) ... air=Some(290)/Some(4800) silent=Some(false) invisible=Some(true) pose=Some("standing") tick=125 id=654 kind=minecraft:axolotl ... air=Some(336)/Some(6000) ... tick=125 id=656 kind=minecraft:blaze ... water=Some(false) lava=Some(true) fire_immune=Some(true) ... tick=125 id=657 kind=minecraft:zombie ... fire=Some(295) air=Some(300)/Some(300) silent=Some(true) ... tick=125 id=658 kind=minecraft:armor_stand ... water=None lava=None fire_immune=None fire=Some(0) air=None/Some(300) silent=None invisible=Some(true) pose=Some("standing") tick=125 id=662 kind=minecraft:arrow ... water=None lava=None fire_immune=None fire=None air=None/Some(300) silent=None invisible=None pose=Some("standing") tick=175 id=653 kind=minecraft:dolphin ... air=Some(240)/Some(4800) ... tick=175 id=657 kind=minecraft:zombie ... fire=Some(245) ... silent=Some(true) ... tick=225 id=1 kind=minecraft:player shift=Some(true) crouch=Some(true) sprint=Some(false) ... fire=Some(-20) air=Some(300)/Some(300) silent=Some(false) invisible=Some(false) pose=Some("crouching") STPROBE set_silent player -> false STPROBE set_silent id=652 -> true now=Some(true) tick=375 id=1 kind=minecraft:player shift=Some(false) crouch=Some(false) ... invisible=Some(true) pose=Some("standing") ``` - The zombie in the pool is in water. The blaze is in lava and fire-immune. - The dolphin on land loses air against its 4800 maximum, and its invisibility effect counts. - The burning zombie's fire ticks count down from 300, and it reads as silent. - Sneaking turns on shift, crouching and the crouching pose; the effect makes the player invisible. - `set_silent` silences a mob and is refused for the player. - The player's `-20` fire ticks is vanilla's resting value. **pr_ready** (`tools/pr_ready.py --quick --base hr/main` on cachyos-x8664, against hr/main at b09827e93, 4 min 53 s) | Check | Result | | --- | --- | | Scope | ⚠️ 12 files, +990 −7; 980 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 | ✅ (6 s) | | clippy | ✅ (1 min 11 s) | | tests: horizon-client, horizon-client-lib, xtask | ✅ 2180 passed (1 min 16 s) | | doc tests | ✅ 0 passed (1 min 34 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (13 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) | The scope line counts #7454, which this stacks on; this PR's own commit is 6 files changed, 503 insertions(+), 1 deletion(-). 🤖 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#7760
No description provided.