[PR #5562] [MERGED] Native mods: draw mod block entities on the client (BlockEntityRenderer.submit) #6354

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5562
Author: @ErikKalikas
Created: 10/31/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: mod-block-entity-draw


📝 Commits (9)

  • 4d9dbdb Native mods: draw mod block entities on the client (BlockEntityRenderer.submit)
  • a8a17b1 Merge remote-tracking branch 'upstream/main' into mod-block-entity-draw
  • 91ed167 Native mods: keep the block entity draw helpers for mods (dead_code)
  • 30350fe Merge remote-tracking branch 'upstream/main' into mod-block-entity-draw
  • ee34e19 Native mods: cull mod block entities by the bounds their mod gives (getRenderBoundingBox)
  • 97c8e9e Native mods: the block state in the block entity hooks, items and state properties for drawing
  • 4ad692a Native mods: leave native_draw_item and native_block_state_property for a follow-up
  • 600e7be Native mods: test that infinite bounds skip a frustum that culls everything
  • c652b50 Merge main into #5562 (module list)

📊 Changes

5 files changed (+479 additions, -19 deletions)

View changed files

📝 crates/horizon-client-render/src/hud.rs (+15 -6)
📝 crates/horizon-client/src/game.rs (+17 -13)
➕ crates/horizon-client/src/game/native_block_entity_draw.rs (+391 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+39 -0)
➕ tools/native-hook-fragments/block_entity_submit.json (+17 -0)

📄 Description

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

What and why

Fixes #4028, as planned there (plan, with @arismoko's three additions: reply). A mod block entity reaches clients since #4935/#5220, but nothing drew it: the section's block entity list had mod blocks, and the block entity pass dropped every state without a vanilla renderer.

  • Hook native_block_entity_submit(pos, block, state, &ModBlockEntity, &mut BlockEntityDraw) (BlockEntityRenderer.submit; state as a renderer reads blockEntity.getBlockState(), e.g. for facing): once a frame for each mod block entity in the same pass and with the same culling as vanilla's (sections past the fade-in threshold, the frustum with a block of margin, getViewDistance 64), marked for shader packs (mark_block_entity) and through entity culling, like a chest.
  • Hook native_block_entity_render_bounding_box(pos, block, state, &ModBlockEntity, &mut [f32; 6]) (NeoForge's getRenderBoundingBox): vanilla extracts the block entities of drawn sections (LevelExtractor.extractVisibleBlockEntities), and Horizon also culls each by the frustum with a block of margin. A mod widens that box when it draws further (a tall shaft, a beam), or makes a bound infinite never to be culled (INFINITE_EXTENT_AABB). The view distance test is strict, as Vec3.closerThan in shouldRender.
  • BlockEntityDraw (game/native_block_entity_draw.rs): partial tick, game time and the block's light (LevelRenderer.getLightCoords), and a pose stack (push, pop, translate, rotate_about, scale, as PoseStack) that every helper draws under.
  • Helpers: native_draw_quad (four corners, a sprite's UVs, a tint), native_draw_cube (a model element's box, each face baked by bake_flat_face, i.e. FaceBakery.bakeQuad, so default UVs and corner order match block models), native_draw_block (a block state's baked model, as submitBlockModel, through block_model_vertices, seed 42). Vertices are shaded as vanilla's block entity models (Lighting, draw_part).
  • Textures: content mods' whole textures/entity/ now joins the atlas (it took only entity/equipment), as <ns>:entity/.... Block-atlas sprites (<ns>:block/...) already worked through atlases/blocks.json; checked in game before this change.
  • The hook ships as an API fragment (tools/native-hook-fragments/block_entity_submit.json, #5161). It complements native_world_drawn (#5434): that one is per frame on the GPU, this one is per block entity in the entity batch.

Left for later: native_draw_item and native_block_state_property (@reservedbytes's suggestion; written and checked in game, but they took this past 500 lines, so they follow right after this merges), the breaking overlay on mod block entities, shouldRenderOffScreen and a custom view distance, standalone models and item(stack), and cached or instanced geometry for many machines (#4953).

Kind

  • feature: something new for players (listed under New in the release notes)

Vanilla reference

Horizon-only API following LevelExtractor.extractVisibleBlockEntities, BlockEntityRenderDispatcher.tryExtractRenderState, BlockEntityRenderer (submit, extractRenderState, shouldRender, getViewDistance), NeoForge's getRenderBoundingBox (public javadoc), PoseStack, FaceBakery.bakeQuad, SubmitNodeCollector.submitBlockModel and LevelRenderer.getLightCoords. No harness: unit tests for the pose stack, quad placement, shading and colour order, culling with infinite bounds, the atlas test extended to a mod's entity texture, and the hook catalog test with the fragment.

Checked in game (server thread, offscreen, horizon-ctl): a content block on minecraft:enchanting_table with a temporary body in native_block_entity and native_block_entity_submit drew a spinning native_draw_cube with a mod's entity/ texture, a scaled native_draw_block of another mod block above it, and a tinted native_draw_quad; all three helpers returned true, and the vanilla enchanting table beside it kept its book. Bounds: the same machine drawing a beam 5 blocks up, looked up at with the block itself below the view, lost the beam with the default bounds and kept it with the bounds widened to 6 blocks.

The test machine (left) beside a vanilla enchanting table (right):

image-1793486866464

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on kased-h610mkddr4, against upstream/main at ad5aef0c5, 6 min 6 s)

Check Result
Scope ✅ 5 files, +479 −19
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 511 passed (26 s)
rustfmt ✅ (7 s)
clippy ✅ (1 min 34 s)
tests: horizon-client, horizon-client-render ✅ 2422 passed (3 min 53 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 297 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, blending, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_tint, block_transformer, breaking_model and 285 more
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/5562 **Author:** [@ErikKalikas](https://github.com/ErikKalikas) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `mod-block-entity-draw` --- ### 📝 Commits (9) - [`4d9dbdb`](https://github.com/horizon-rust/horizon/commit/4d9dbdb565792fa2858da2cf82ccd56a3df7cce9) Native mods: draw mod block entities on the client (BlockEntityRenderer.submit) - [`a8a17b1`](https://github.com/horizon-rust/horizon/commit/a8a17b12d075a1b8d0a19b85a3e87726996424e4) Merge remote-tracking branch 'upstream/main' into mod-block-entity-draw - [`91ed167`](https://github.com/horizon-rust/horizon/commit/91ed1679976a9cc410e79b3dbf0263cc2e4fd090) Native mods: keep the block entity draw helpers for mods (dead_code) - [`30350fe`](https://github.com/horizon-rust/horizon/commit/30350feba83900a5fcea244169e54cc085031dd4) Merge remote-tracking branch 'upstream/main' into mod-block-entity-draw - [`ee34e19`](https://github.com/horizon-rust/horizon/commit/ee34e1982a74491a7d75173a456a9638037355a2) Native mods: cull mod block entities by the bounds their mod gives (getRenderBoundingBox) - [`97c8e9e`](https://github.com/horizon-rust/horizon/commit/97c8e9ed15db788532ceb8f8f6b002c64a6f9c58) Native mods: the block state in the block entity hooks, items and state properties for drawing - [`4ad692a`](https://github.com/horizon-rust/horizon/commit/4ad692a07bd9a98b856ef6f983bd2e6744871a95) Native mods: leave native_draw_item and native_block_state_property for a follow-up - [`600e7be`](https://github.com/horizon-rust/horizon/commit/600e7bec7799f46a6cb3dd2b5d1168bd82334119) Native mods: test that infinite bounds skip a frustum that culls everything - [`c652b50`](https://github.com/horizon-rust/horizon/commit/c652b5092013f846991f86ae70f05db4806c61c3) Merge main into #5562 (module list) ### 📊 Changes **5 files changed** (+479 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/hud.rs` (+15 -6) 📝 `crates/horizon-client/src/game.rs` (+17 -13) ➕ `crates/horizon-client/src/game/native_block_entity_draw.rs` (+391 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+39 -0) ➕ `tools/native-hook-fragments/block_entity_submit.json` (+17 -0) </details> ### 📄 Description > 🤖 Opened by ErikKalikas's AI agent (Claude Code, Claude Opus 5.5), not by ErikKalikas personally. ## What and why Fixes #4028, as planned there ([plan](https://github.com/horizon-rust/horizon/issues/4028#issuecomment-6546344387), with @arismoko's three additions: [reply](https://github.com/horizon-rust/horizon/issues/4028#issuecomment-6546834260)). A mod block entity reaches clients since #4935/#5220, but nothing drew it: the section's block entity list had mod blocks, and the block entity pass dropped every state without a vanilla renderer. - **Hook `native_block_entity_submit(pos, block, state, &ModBlockEntity, &mut BlockEntityDraw)`** (`BlockEntityRenderer.submit`; `state` as a renderer reads `blockEntity.getBlockState()`, e.g. for `facing`): once a frame for each mod block entity in the same pass and with the same culling as vanilla's (sections past the fade-in threshold, the frustum with a block of margin, `getViewDistance` 64), marked for shader packs (`mark_block_entity`) and through entity culling, like a chest. - **Hook `native_block_entity_render_bounding_box(pos, block, state, &ModBlockEntity, &mut [f32; 6])`** (NeoForge's `getRenderBoundingBox`): vanilla extracts the block entities of drawn sections (`LevelExtractor.extractVisibleBlockEntities`), and Horizon also culls each by the frustum with a block of margin. A mod widens that box when it draws further (a tall shaft, a beam), or makes a bound infinite never to be culled (`INFINITE_EXTENT_AABB`). The view distance test is strict, as `Vec3.closerThan` in `shouldRender`. - **`BlockEntityDraw`** (`game/native_block_entity_draw.rs`): partial tick, game time and the block's light (`LevelRenderer.getLightCoords`), and a pose stack (`push`, `pop`, `translate`, `rotate_about`, `scale`, as `PoseStack`) that every helper draws under. - **Helpers:** `native_draw_quad` (four corners, a sprite's UVs, a tint), `native_draw_cube` (a model element's box, each face baked by `bake_flat_face`, i.e. `FaceBakery.bakeQuad`, so default UVs and corner order match block models), `native_draw_block` (a block state's baked model, as `submitBlockModel`, through `block_model_vertices`, seed 42). Vertices are shaded as vanilla's block entity models (`Lighting`, `draw_part`). - **Textures:** content mods' whole `textures/entity/` now joins the atlas (it took only `entity/equipment`), as `<ns>:entity/...`. Block-atlas sprites (`<ns>:block/...`) already worked through `atlases/blocks.json`; checked in game before this change. - The hook ships as an API fragment (`tools/native-hook-fragments/block_entity_submit.json`, #5161). It complements `native_world_drawn` (#5434): that one is per frame on the GPU, this one is per block entity in the entity batch. Left for later: `native_draw_item` and `native_block_state_property` (@reservedbytes's suggestion; written and checked in game, but they took this past 500 lines, so they follow right after this merges), the breaking overlay on mod block entities, `shouldRenderOffScreen` and a custom view distance, standalone models and `item(stack)`, and cached or instanced geometry for many machines (#4953). ## Kind - [x] feature: something new for players (listed under New in the release notes) ## Vanilla reference Horizon-only API following `LevelExtractor.extractVisibleBlockEntities`, `BlockEntityRenderDispatcher.tryExtractRenderState`, `BlockEntityRenderer` (`submit`, `extractRenderState`, `shouldRender`, `getViewDistance`), NeoForge's `getRenderBoundingBox` (public javadoc), `PoseStack`, `FaceBakery.bakeQuad`, `SubmitNodeCollector.submitBlockModel` and `LevelRenderer.getLightCoords`. No harness: unit tests for the pose stack, quad placement, shading and colour order, culling with infinite bounds, the atlas test extended to a mod's entity texture, and the hook catalog test with the fragment. **Checked in game** (server thread, offscreen, horizon-ctl): a content block on `minecraft:enchanting_table` with a temporary body in `native_block_entity` and `native_block_entity_submit` drew a spinning `native_draw_cube` with a mod's `entity/` texture, a scaled `native_draw_block` of another mod block above it, and a tinted `native_draw_quad`; all three helpers returned true, and the vanilla enchanting table beside it kept its book. Bounds: the same machine drawing a beam 5 blocks up, looked up at with the block itself below the view, lost the beam with the default bounds and kept it with the bounds widened to 6 blocks. The test machine (left) beside a vanilla enchanting table (right): <img width="1280" height="720" alt="image-1793486866464" src="https://github.com/user-attachments/assets/59bb7131-6fb1-454e-ad45-ffd6e02f0e47" /> ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on kased-h610mkddr4, against upstream/main at ad5aef0c5, 6 min 6 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +479 −19 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 511 passed (26 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (1 min 34 s) | | tests: horizon-client, horizon-client-render | ✅ 2422 passed (3 min 53 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 297 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, blending, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_tint, block_transformer, breaking_model and 285 more | | 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>
bsakaguchi 2026-11-03 06:19:08 +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#6354
No description provided.