[GH-ISSUE #5313] Native mods: moving block structures (design proposal) #1637

Open
opened 2026-11-02 15:48:33 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @sirrayi on GitHub (Oct 31, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5313

🤖 Filed by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi personally.

Part of #4953, under Moving block structures — the item that issue singles out as needing a design discussion before any PR, and the one its progress note counts as the largest single piece left ("Nothing like this exists yet").

This is a proposal to start that discussion, not a plan to implement. What follows is what the code already gives us, what a mod actually needs, and where I think the real decisions are. The last section is the set of questions I do not think I should answer alone.

What a tech mod needs

An entity that carries a group of blocks — with their block entities — and moves or rotates them as one, with:

  • collision, so players and mobs can stand on and be pushed by it;
  • saving, so a frame in motion survives a chunk save and a restart;
  • sync to clients, so everyone sees it in the same place;
  • rendering, of the blocks themselves, at the interpolated position.

What the code already has

Worth knowing before designing: several of the pieces are closer than the checklist suggests.

A single moving block already works end to end. Vanilla's piston is a minecraft:moving_piston block whose block entity (minecraft:piston) holds the real state — MovingPiston { moved_state, direction, extending, source, progress, progress_o, last_ticked, death_ticks, id } in crates/horizon-world/src/level/pistons.rs:22-35. It advances progress + 0.5 a tick (pistons.rs:259), is ticked after entities (crates/horizon-world/src/level/mod.rs:24-31), and is skipped outside ticking chunks (pistons.rs:857-858). It is saved mid-move as block-entity NBT with blockState/facing/progress/extending/source and resumes from progress_o (crates/horizon-client/src/game/persist.rs:104-235, from #3310). So "carry a block state through a move, save it, draw it interpolated" is already solved for a set of one.

Rendering many blocks under one transform is a loop away. block_model_vertices(state, seed, Mat4, …) (crates/horizon-client/src/game/minecarts.rs:1292-1311) bakes a block under an arbitrary matrix. block_display already uses it for a display entity (game/text_displays.rs:273-330) and moving pistons use it per block (game/moving_pistons.rs:125-166).

Collision for an entity is an AABB channel. MotionWorld { entities: &'w [Aabb], … } (crates/horizon-client/src/motion.rs:887-895) and EntityCollisions { blocks, entities: &'a [Aabb], … } (crates/horizon-client-render/src/collisions.rs:85-91), filled each tick by the host. Anything put in that slice is solid and standable. It is boxes only, though — per-block shapes come only through the piston path (crates/horizon-world/src/piston_shape.rs:158-195).

The hook that exists is cancel-only. native_piston_move(dimension, piston, direction, push: &[BlockPos], destroy: &[BlockPos], canceled: &mut bool) (game/native_hooks.rs:262-270) can stop a piston but cannot redirect or extend it, so it is not the shape a mod controllable structure would use.

The decisions I think are actually hard

  1. An entity, or a block entity? NeoForge contraptions are entities, and entities are the natural fit for "a thing that moves". But this codebase mints entity type ids only from the pinned vanilla registry (crates/horizon-client/src/lan/hub.rs:342-354), so a mod cannot register a new entity type today — that is the same gap as #4615's "block-entity types registered by mods, with network IDs", only worse, because entity types also drive the tracker's per-type range/interval table. A mod block entity persists per chunk already (native_block_entity, API 15), but its tick is chunk-gated like the piston's.

  2. Crossing a chunk boundary. The piston solution is a single block position, so "which chunk owns it" is trivial. A structure spanning chunks has no owner: it can be partly in an unloaded chunk, and the piston's tick is skipped for non-ticking chunks. This needs a decision on where the structure's authoritative state lives — a controller position, an entity, or a level-level list — before anything else can be designed.

  3. What happens when a structure is interrupted. Vanilla's answer for one block is death_ticks and a lingering client copy (pistons.rs:218-224). For a structure, "the world unloaded mid-move" and "the player left mid-move" both need an answer, and the piston precedent (conclude on load, progress_o) may not extend well.

  4. Rotation. The issue asks for "moves or rotates them as one". Moving pistons never rotate a block, so a rotated structure needs per-block state recomputation (facing/axis/direction translated by the rotation), which is a per-block-type problem (stairs, slabs, rails, mod blocks with their own states — see #5290). Whether v1 supports translation only, and rotation deferred, is worth deciding up front.

  5. Does the piston hook need a redirect form first? A cheap and self-contained first step that is useful on its own: give native_piston_move the ability to change push/destroy rather than only cancel. That would let a mod make a vanilla-sized move of its own choosing, with none of the structure problems, and it exercises the hook shape a bigger API would need.

Suggested staging, if the above lands that way

  1. native_piston_move gains an output form (redirect the push), no new machinery.
  2. A mod block entity that declares the positions it owns, so a controller exists to hold structure state.
  3. Collision and rendering for those positions (both reuse existing paths, per above).
  4. Saving and client sync — the hard part, and the one that depends on decision 2.
  5. Rotation last.

Questions for the maintainers

  • Entity or block-entity carrier? If entity, does mod entity-type registration land first, or does a structure reuse an existing vanilla type?
  • Where does a cross-chunk structure's state live, and what is the rule when part of it is in an unloaded chunk?
  • Is rotation in scope for v1, or translation only?
  • Is a redirect form of native_piston_move welcome as a small standalone PR, before any of this?

I have not written any code for this and would not start before these are settled. Happy to research or prototype a specific answer if a direction is picked.

Originally created by @sirrayi on GitHub (Oct 31, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5313 > 🤖 Filed by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi personally. Part of #4953, under **Moving block structures** — the item that issue singles out as needing a design discussion before any PR, and the one its progress note counts as the largest single piece left ("Nothing like this exists yet"). This is a proposal to start that discussion, not a plan to implement. What follows is what the code already gives us, what a mod actually needs, and where I think the real decisions are. The last section is the set of questions I do not think I should answer alone. ## What a tech mod needs An entity that carries a group of blocks — with their block entities — and moves or rotates them as one, with: - collision, so players and mobs can stand on and be pushed by it; - saving, so a frame in motion survives a chunk save and a restart; - sync to clients, so everyone sees it in the same place; - rendering, of the blocks themselves, at the interpolated position. ## What the code already has Worth knowing before designing: several of the pieces are closer than the checklist suggests. **A single moving block already works end to end.** Vanilla's piston is a `minecraft:moving_piston` block whose block entity (`minecraft:piston`) holds the real state — `MovingPiston { moved_state, direction, extending, source, progress, progress_o, last_ticked, death_ticks, id }` in `crates/horizon-world/src/level/pistons.rs:22-35`. It advances `progress + 0.5` a tick (`pistons.rs:259`), is ticked *after* entities (`crates/horizon-world/src/level/mod.rs:24-31`), and is **skipped outside ticking chunks** (`pistons.rs:857-858`). It is saved mid-move as block-entity NBT with `blockState/facing/progress/extending/source` and resumes from `progress_o` (`crates/horizon-client/src/game/persist.rs:104-235`, from #3310). So "carry a block state through a move, save it, draw it interpolated" is already solved for a set of one. **Rendering many blocks under one transform is a loop away.** `block_model_vertices(state, seed, Mat4, …)` (`crates/horizon-client/src/game/minecarts.rs:1292-1311`) bakes a block under an arbitrary matrix. `block_display` already uses it for a display entity (`game/text_displays.rs:273-330`) and moving pistons use it per block (`game/moving_pistons.rs:125-166`). **Collision for an entity is an AABB channel.** `MotionWorld { entities: &'w [Aabb], … }` (`crates/horizon-client/src/motion.rs:887-895`) and `EntityCollisions { blocks, entities: &'a [Aabb], … }` (`crates/horizon-client-render/src/collisions.rs:85-91`), filled each tick by the host. Anything put in that slice is solid and standable. It is boxes only, though — per-block shapes come only through the piston path (`crates/horizon-world/src/piston_shape.rs:158-195`). **The hook that exists is cancel-only.** `native_piston_move(dimension, piston, direction, push: &[BlockPos], destroy: &[BlockPos], canceled: &mut bool)` (`game/native_hooks.rs:262-270`) can stop a piston but cannot redirect or extend it, so it is not the shape a mod controllable structure would use. ## The decisions I think are actually hard 1. **An entity, or a block entity?** NeoForge contraptions are entities, and entities are the natural fit for "a thing that moves". But this codebase mints entity type ids only from the pinned vanilla registry (`crates/horizon-client/src/lan/hub.rs:342-354`), so **a mod cannot register a new entity type today** — that is the same gap as #4615's "block-entity types registered by mods, with network IDs", only worse, because entity types also drive the tracker's per-type range/interval table. A mod block entity persists per chunk already (`native_block_entity`, API 15), but its tick is chunk-gated like the piston's. 2. **Crossing a chunk boundary.** The piston solution is a single block position, so "which chunk owns it" is trivial. A structure spanning chunks has no owner: it can be partly in an unloaded chunk, and the piston's tick is skipped for non-ticking chunks. This needs a decision on where the structure's authoritative state lives — a controller position, an entity, or a level-level list — before anything else can be designed. 3. **What happens when a structure is interrupted.** Vanilla's answer for one block is `death_ticks` and a lingering client copy (`pistons.rs:218-224`). For a structure, "the world unloaded mid-move" and "the player left mid-move" both need an answer, and the piston precedent (conclude on load, `progress_o`) may not extend well. 4. **Rotation.** The issue asks for "moves or rotates them as one". Moving pistons never rotate a block, so a rotated structure needs per-block state recomputation (facing/axis/direction translated by the rotation), which is a per-block-type problem (`stairs`, `slabs`, `rails`, mod blocks with their own states — see #5290). Whether v1 supports translation only, and rotation deferred, is worth deciding up front. 5. **Does the piston hook need a redirect form first?** A cheap and self-contained first step that is useful on its own: give `native_piston_move` the ability to change `push`/`destroy` rather than only cancel. That would let a mod make a *vanilla-sized* move of its own choosing, with none of the structure problems, and it exercises the hook shape a bigger API would need. ## Suggested staging, if the above lands that way 1. `native_piston_move` gains an output form (redirect the push), no new machinery. 2. A mod block entity that declares the positions it owns, so a controller exists to hold structure state. 3. Collision and rendering for those positions (both reuse existing paths, per above). 4. Saving and client sync — the hard part, and the one that depends on decision 2. 5. Rotation last. ## Questions for the maintainers - Entity or block-entity carrier? If entity, does mod entity-type registration land first, or does a structure reuse an existing vanilla type? - Where does a cross-chunk structure's state live, and what is the rule when part of it is in an unloaded chunk? - Is rotation in scope for v1, or translation only? - Is a redirect form of `native_piston_move` welcome as a small standalone PR, before any of this? I have not written any code for this and would not start before these are settled. Happy to research or prototype a specific answer if a direction is picked.
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#1637
No description provided.