[PR #6291] [MERGED] Native mods: drawing a player and adding layers to entities, RenderPlayerEvent and AddLayers #6773

Closed
opened 2026-11-03 06:26:24 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6291
Author: @levzzz5154
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @levzzz5154

Base: main ← Head: mods/native-render-player


📝 Commits (3)

  • 27722b0 Native mods: player render and entity layers (RenderPlayerEvent, AddLayers)
  • 67e3fad Native mods: pose players and mobs for the render hooks only while a mod listens
  • 34a22fd Merge main into #6291 (main has remote_player_name)

📊 Changes

6 files changed (+191 additions, -12 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+20 -5)
📝 crates/horizon-client/src/game/native_hooks.rs (+42 -1)
📝 crates/horizon-client/src/game/native_mob_draw.rs (+82 -5)
📝 crates/horizon-client/src/game/perspective.rs (+14 -1)
📝 docs/native-mods.md (+7 -0)
➕ tools/native-hook-fragments/player_render.json (+26 -0)

📄 Description

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

What and why

Fixes #6257; part of #4953 ("Player render and entity render layers"). native_mob_submit (#5895) draws any mob but a player with a mod's own model; there was no way to draw a player's model, nor to add something to a model that stays vanilla. Two client hooks, in the same frame as native_mob_submit (a BlockEntityDraw at the entity's feet, turned with its body, drawn with native_draw_cube/quad/block/item):

  • native_player_submit(player, who, draw, drawn): NeoForge's RenderPlayerEvent.Pre. Once a frame for every other player in view and for this window's player in third person (and F5 front view); an invisible player is not asked. who (NativePlayerRender) has the profile name and local. Setting drawn leaves out the vanilla model, armour, held items, cape and the other layers.
  • native_mob_layer(mob, who, draw): EntityRenderersEvent.AddLayers (and RenderLivingEvent.Post / RenderPlayerEvent.Post, which a layer drawn after everything covers). Once a frame after the vanilla model and its layers, for every mob and player in view that a mod did not draw itself (native_mob_submit / native_player_submit); who is set for a player. Whatever the mod adds is drawn with the entity (and is part of its glowing outline and cull).

native_mob_submit itself is unchanged ("every mob but players"). Its draw code is now one helper, mod_entity_draw, used by the three.

Where Horizon differs from NeoForge: a RenderLayer there takes the parent model and attaches to its parts (the head, an arm). Here the layer has the entity's frame and NativeMobRender (body, head_yaw, pitch, the walk cycle) and computes a part's place itself; exposing baked model part poses by a stable name per model is the alternative, recommended as a follow-up once a mod needs it (it is in the issue). The local player's own model is drawn only in third person, as vanilla's LevelExtractor skips the camera entity.

Call sites: creatures.rs mob_geometry (other players and all mobs) and perspective.rs player_model_geometry (the window's own player). Docs: docs/native-mods.md ("Mobs drawn by a mod").

Kind

  • feature: something new for players (a mod's models and layers on players and mobs)

Vanilla reference

LivingEntityRenderer.submit, PlayerRenderer's layers and EntityRenderer.submit for the frame (same as #5895); NeoForge's public contract for RenderPlayerEvent, RenderLivingEvent and EntityRenderersEvent.AddLayers.

Other projects' code

None; names and contracts only.

Proof in the real game

Offscreen client, single player on the server thread and, for a remote player, a dedicated server (port 25740) with two clients; a throwaway probe in the two hook bodies (removed before commit, git diff shows no TESTHOOK) that logs each call and, from env vars, draws a cube above the entity's head or replaces the player with a cube. Screenshots read back with the image reader:

  • Single player in third person (F5), a pig and a cow nearby: player_submit id=0 name=... local=true and mob_layer kind=minecraft:player who=Some((name, true)) every frame, mob_layer for pig, cow and the other mobs with who=None. With the layer on, a cube floats above the player's head (and a small one above the cow). With drawn set, the vanilla player is gone and the mod's cube stands in its place.
  • Dedicated server, a second client "Bob" 4 blocks away: player_submit id=<n> name=Bob local=false and mob_layer kind=minecraft:player who=Some(("Bob", false)); the cube floats over Bob with his name tag over it. (A first attempt at y 100 was under water and showed nothing; the hook still fired.)

Not run: the invisible and spectator cases, the F5 front view, a glowing player, a real native mod bundle with a model, native_mob_submit after the refactor beyond the log (its call is unchanged: the pig with drawn left false draws as vanilla in the screenshots), the parity harnesses (--quick).

Self-check

pr_ready (tools/pr_ready.py --quick --base hr/main, against hr/main at 455b6916b)

Check Result
Scope ✅ 6 files, +172 −12
Public tree ✅
Python tests ✅ 586 passed
rustfmt ✅
clippy ✅
tests: horizon-client ✅ 1805 passed
doc tests ✅
Parity ➖ not run (--quick)

🤖 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/6291 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `mods/native-render-player` --- ### 📝 Commits (3) - [`27722b0`](https://github.com/horizon-rust/horizon/commit/27722b05787de328736d423b30c339fcc48835e7) Native mods: player render and entity layers (RenderPlayerEvent, AddLayers) - [`67e3fad`](https://github.com/horizon-rust/horizon/commit/67e3fadf720be26ada1f568111d87d809465024c) Native mods: pose players and mobs for the render hooks only while a mod listens - [`34a22fd`](https://github.com/horizon-rust/horizon/commit/34a22fde394e6bdd89d3f9e313ad5d79850d1a13) Merge main into #6291 (main has remote_player_name) ### 📊 Changes **6 files changed** (+191 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+20 -5) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+42 -1) 📝 `crates/horizon-client/src/game/native_mob_draw.rs` (+82 -5) 📝 `crates/horizon-client/src/game/perspective.rs` (+14 -1) 📝 `docs/native-mods.md` (+7 -0) ➕ `tools/native-hook-fragments/player_render.json` (+26 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. ## What and why Fixes #6257; part of #4953 ("Player render and entity render layers"). `native_mob_submit` (#5895) draws any mob but a player with a mod's own model; there was no way to draw a player's model, nor to add something to a model that stays vanilla. Two client hooks, in the same frame as `native_mob_submit` (a `BlockEntityDraw` at the entity's feet, turned with its body, drawn with `native_draw_cube`/`quad`/`block`/`item`): - `native_player_submit(player, who, draw, drawn)`: NeoForge's `RenderPlayerEvent.Pre`. Once a frame for every other player in view and for this window's player in third person (and F5 front view); an invisible player is not asked. `who` (`NativePlayerRender`) has the profile name and `local`. Setting `drawn` leaves out the vanilla model, armour, held items, cape and the other layers. - `native_mob_layer(mob, who, draw)`: `EntityRenderersEvent.AddLayers` (and `RenderLivingEvent.Post` / `RenderPlayerEvent.Post`, which a layer drawn after everything covers). Once a frame after the vanilla model and its layers, for every mob and player in view that a mod did not draw itself (`native_mob_submit` / `native_player_submit`); `who` is set for a player. Whatever the mod adds is drawn with the entity (and is part of its glowing outline and cull). `native_mob_submit` itself is unchanged ("every mob but players"). Its draw code is now one helper, `mod_entity_draw`, used by the three. Where Horizon differs from NeoForge: a `RenderLayer` there takes the parent model and attaches to its parts (the head, an arm). Here the layer has the entity's frame and `NativeMobRender` (body, `head_yaw`, `pitch`, the walk cycle) and computes a part's place itself; exposing baked model part poses by a stable name per model is the alternative, recommended as a follow-up once a mod needs it (it is in the issue). The local player's own model is drawn only in third person, as vanilla's `LevelExtractor` skips the camera entity. Call sites: `creatures.rs` `mob_geometry` (other players and all mobs) and `perspective.rs` `player_model_geometry` (the window's own player). Docs: `docs/native-mods.md` ("Mobs drawn by a mod"). ## Kind - [x] feature: something new for players (a mod's models and layers on players and mobs) ## Vanilla reference `LivingEntityRenderer.submit`, `PlayerRenderer`'s layers and `EntityRenderer.submit` for the frame (same as #5895); NeoForge's public contract for `RenderPlayerEvent`, `RenderLivingEvent` and `EntityRenderersEvent.AddLayers`. ## Other projects' code None; names and contracts only. ## Proof in the real game Offscreen client, single player on the server thread and, for a remote player, a dedicated server (port 25740) with two clients; a throwaway probe in the two hook bodies (removed before commit, `git diff` shows no TESTHOOK) that logs each call and, from env vars, draws a cube above the entity's head or replaces the player with a cube. Screenshots read back with the image reader: - Single player in third person (F5), a pig and a cow nearby: `player_submit id=0 name=... local=true` and `mob_layer kind=minecraft:player who=Some((name, true))` every frame, `mob_layer` for pig, cow and the other mobs with `who=None`. With the layer on, a cube floats above the player's head (and a small one above the cow). With `drawn` set, the vanilla player is gone and the mod's cube stands in its place. - Dedicated server, a second client "Bob" 4 blocks away: `player_submit id=<n> name=Bob local=false` and `mob_layer kind=minecraft:player who=Some(("Bob", false))`; the cube floats over Bob with his name tag over it. (A first attempt at y 100 was under water and showed nothing; the hook still fired.) Not run: the invisible and spectator cases, the F5 front view, a glowing player, a real native mod bundle with a model, `native_mob_submit` after the refactor beyond the log (its call is unchanged: the pig with `drawn` left false draws as vanilla in the screenshots), the parity harnesses (`--quick`). ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base hr/main`, against hr/main at 455b6916b) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +172 −12 | | Public tree | ✅ | | Python tests | ✅ 586 passed | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client | ✅ 1805 passed | | doc tests | ✅ | | Parity | ➖ not run (--quick) | 🤖 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>
bsakaguchi 2026-11-03 06:26:24 +07:00
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#6773
No description provided.