[GH-ISSUE #5671] Native mods: keep a mod block entity's geometry while it doesn't change #1770

Closed
opened 2026-11-02 15:49:32 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @ErikKalikas on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5671

Originally assigned to: @ErikKalikas on GitHub.

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

Part of #4953. Since #5562, native_block_entity_submit (and native_block_entity_render_bounding_box) run every frame for every mod block entity in view. A base of a few thousand idle machines calls the mod thousands of times a frame to rebuild geometry that has not changed.

Proposal

A mod says its geometry can be kept: draw.keep() inside native_block_entity_submit. Then the game keeps that frame's vertices (relative to the block, as SignTexts keeps a sign's text in block_entity_render.rs) with the bounds, and skips both hooks for that block until something in the key changes:

  • the block state,
  • the block entity (ModBlockEntity: what the server sent, so native_block_entity_sync redraws it),
  • the block's light,
  • the atlas (a resource reload).

Each frame a kept machine costs a copy moved to the camera, the frustum test and the occlusion cull, but no call into the mod. A machine that is not kept (a shaft that turns with game_time) is drawn every frame as now, so a mod can keep a machine while idle and stop keeping it while it runs. Entries out of view are swept after 100 ticks, as signs' are.

Helper-only (a method on BlockEntityDraw), no new hook; off unless a mod calls it, so nothing changes for existing mods.

Not in scope: instanced drawing of many moving parts (the separate #4953 line); this only stops redrawing parts that don't move.

Vanilla has no such cache (BlockEntityRenderer.submit runs each frame); it is Horizon-only, for #4953's thousands of machines.

Originally created by @ErikKalikas on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5671 Originally assigned to: @ErikKalikas on GitHub. > 🤖 Filed by ErikKalikas's AI agent (Claude Code, Claude Opus 5.5), not by ErikKalikas personally. Part of #4953. Since #5562, `native_block_entity_submit` (and `native_block_entity_render_bounding_box`) run every frame for every mod block entity in view. A base of a few thousand idle machines calls the mod thousands of times a frame to rebuild geometry that has not changed. ## Proposal A mod says its geometry can be kept: `draw.keep()` inside `native_block_entity_submit`. Then the game keeps that frame's vertices (relative to the block, as `SignTexts` keeps a sign's text in `block_entity_render.rs`) with the bounds, and skips both hooks for that block until something in the key changes: - the block state, - the block entity (`ModBlockEntity`: what the server sent, so `native_block_entity_sync` redraws it), - the block's light, - the atlas (a resource reload). Each frame a kept machine costs a copy moved to the camera, the frustum test and the occlusion cull, but no call into the mod. A machine that is not kept (a shaft that turns with `game_time`) is drawn every frame as now, so a mod can keep a machine while idle and stop keeping it while it runs. Entries out of view are swept after 100 ticks, as signs' are. Helper-only (a method on `BlockEntityDraw`), no new hook; off unless a mod calls it, so nothing changes for existing mods. Not in scope: instanced drawing of many moving parts (the separate #4953 line); this only stops redrawing parts that don't move. Vanilla has no such cache (`BlockEntityRenderer.submit` runs each frame); it is Horizon-only, for #4953's thousands of machines.
Author
Owner

@ErikKalikas commented on GitHub (Nov 1, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6552424903 --> @ErikKalikas commented on GitHub (Nov 1, 2026): 🤖 Agent: /claim
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#1770
No description provided.