[PR #6117] [MERGED] feat(mods): native block entities on any template #6661

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

📋 Pull Request Information

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

Base: main ← Head: native/mod-block-entity-any-template


📝 Commits (3)

  • 7abfbbe feat(mods): native block entities on any template
  • f2b9a3c perf(mods): per-chunk list of mod block entities for the renderer
  • feee25c Mod block entities: a block change looks one up only once one exists

📊 Changes

10 files changed (+269 additions, -21 deletions)

View changed files

📝 crates/horizon-client-render/src/block_entities.rs (+101 -4)
📝 crates/horizon-client/src/game.rs (+15 -1)
📝 crates/horizon-client/src/game/mods.rs (+0 -6)
📝 crates/horizon-client/src/game/native_block_entity_draw.rs (+13 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+6 -9)
📝 crates/horizon-world/src/level/mod.rs (+6 -0)
📝 crates/horizon-world/src/level/pistons.rs (+1 -0)
📝 crates/horizon-world/src/level/update.rs (+2 -1)
➕ tests/test_mod_block_entity_any_template.py (+120 -0)
➕ tools/native-hook-fragments/mod_block_entity_any_template.json (+5 -0)

📄 Description

🤖 Opened by Xmilon's AI agent (Claude Code, claude-sonnet-5-5), not by Xmilon personally.

What and why

Fixes #5549.

A mod block's block entity (native_block_entity) no longer needs a template that has one. Mods that pick stone for a casing or iron_chain for a thin part now get a block entity too.

  • new_block_entity drops the template check (and its warning).
  • Removal: LevelAccess::has_mod_block_entity(pos) (default false; GameLevel answers from world.block_entities) joins the template's BLOCK_ENTITY flag in chunk_set_block_state, so a mod block entity is removed, with its container spill, when its block is broken or replaced.
  • Pistons: is_pushable asks the same, so no piston moves a mod block entity.
  • Rendering (as discussed with Isloka): the mesher's block entity lists come from the template flag, so mod_block_entity_geometry also gets the mod block entities of templates without one (untemplated_mod_block_entities), and native_block_entity_submit draws them. BlockEntities keeps the positions of its Mod entries by chunk (mods_near), so a frame reads only the chunks within view distance, not every loaded block entity.
  • Ticking, slots, menus, client sync and fluids are unchanged; LAN sync already treated every mod block as able to have one.

Left alone: a saved mod block entity of an unloaded mod is still dropped by the save's template check (save.rs extras).

API fragment only (tools/native-hook-fragments/mod_block_entity_any_template.json).

Kind

  • tooling: tools, CI, tests, harnesses

Vanilla reference

LevelChunk.setBlockState (block entity removal), PistonBaseBlock.isPushable, BlockEntityRenderer. Horizon-only mod API.

Other projects' code

none

Self-check

  • tests/test_mod_block_entity_any_template.py: compiles the real has_mod_block_entity, untemplated_mod_block_entities, the removal condition from update.rs and the piston tail from pistons.rs with fakes: a stone-template mod entity is removed and not pushed, a plain stone block is unchanged, a vanilla entity is not a mod's, and the render list holds only templated-less mod entities. Passes.
  • cargo clippy -p horizon-world -p horizon-client --lib --bins -- -D warnings, rustfmt, public-tree check: clean.
  • BlockEntities unit test (mod_block_entities_are_listed_by_chunk_until_they_go): insert, get_or_insert_with, load_chunk, take/put, remove, replace, retain, clear and distance. Passes.
  • Not run: tools/pr_ready.py harnesses and the full test suite (no vanilla data locally); no in-game check of a custom renderer on a stone-template block.

🤖 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/6117 **Author:** [@Xmilon](https://github.com/Xmilon) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `native/mod-block-entity-any-template` --- ### 📝 Commits (3) - [`7abfbbe`](https://github.com/horizon-rust/horizon/commit/7abfbbea71a0492d8a7a61caf95d574cc8272c04) feat(mods): native block entities on any template - [`f2b9a3c`](https://github.com/horizon-rust/horizon/commit/f2b9a3c6d48b31f2ec99eaef0049d9c4de3d69ed) perf(mods): per-chunk list of mod block entities for the renderer - [`feee25c`](https://github.com/horizon-rust/horizon/commit/feee25c88c40e656249c91e24e05ec7bd8d99160) Mod block entities: a block change looks one up only once one exists ### 📊 Changes **10 files changed** (+269 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/block_entities.rs` (+101 -4) 📝 `crates/horizon-client/src/game.rs` (+15 -1) 📝 `crates/horizon-client/src/game/mods.rs` (+0 -6) 📝 `crates/horizon-client/src/game/native_block_entity_draw.rs` (+13 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+6 -9) 📝 `crates/horizon-world/src/level/mod.rs` (+6 -0) 📝 `crates/horizon-world/src/level/pistons.rs` (+1 -0) 📝 `crates/horizon-world/src/level/update.rs` (+2 -1) ➕ `tests/test_mod_block_entity_any_template.py` (+120 -0) ➕ `tools/native-hook-fragments/mod_block_entity_any_template.json` (+5 -0) </details> ### 📄 Description > 🤖 Opened by Xmilon's AI agent (Claude Code, claude-sonnet-5-5), not by Xmilon personally. ## What and why Fixes #5549. A mod block's block entity (`native_block_entity`) no longer needs a template that has one. Mods that pick stone for a casing or `iron_chain` for a thin part now get a block entity too. - `new_block_entity` drops the template check (and its warning). - Removal: `LevelAccess::has_mod_block_entity(pos)` (default false; `GameLevel` answers from `world.block_entities`) joins the template's `BLOCK_ENTITY` flag in `chunk_set_block_state`, so a mod block entity is removed, with its container spill, when its block is broken or replaced. - Pistons: `is_pushable` asks the same, so no piston moves a mod block entity. - Rendering (as discussed with Isloka): the mesher's block entity lists come from the template flag, so `mod_block_entity_geometry` also gets the mod block entities of templates without one (`untemplated_mod_block_entities`), and `native_block_entity_submit` draws them. `BlockEntities` keeps the positions of its `Mod` entries by chunk (`mods_near`), so a frame reads only the chunks within view distance, not every loaded block entity. - Ticking, slots, menus, client sync and fluids are unchanged; LAN sync already treated every mod block as able to have one. Left alone: a saved mod block entity of an unloaded mod is still dropped by the save's template check (`save.rs` extras). API fragment only (`tools/native-hook-fragments/mod_block_entity_any_template.json`). ## Kind - [x] tooling: tools, CI, tests, harnesses ## Vanilla reference `LevelChunk.setBlockState` (block entity removal), `PistonBaseBlock.isPushable`, `BlockEntityRenderer`. Horizon-only mod API. ## Other projects' code none ## Self-check - `tests/test_mod_block_entity_any_template.py`: compiles the real `has_mod_block_entity`, `untemplated_mod_block_entities`, the removal condition from `update.rs` and the piston tail from `pistons.rs` with fakes: a stone-template mod entity is removed and not pushed, a plain stone block is unchanged, a vanilla entity is not a mod's, and the render list holds only templated-less mod entities. Passes. - `cargo clippy -p horizon-world -p horizon-client --lib --bins -- -D warnings`, rustfmt, public-tree check: clean. - `BlockEntities` unit test (`mod_block_entities_are_listed_by_chunk_until_they_go`): insert, `get_or_insert_with`, `load_chunk`, `take`/`put`, `remove`, replace, `retain`, `clear` and distance. Passes. - Not run: `tools/pr_ready.py` harnesses and the full test suite (no vanilla data locally); no in-game check of a custom renderer on a stone-template block. 🤖 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:24:31 +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#6661
No description provided.