[GH-ISSUE #4615] Native mods: send mod block-entity data to clients #1399

Closed
opened 2026-11-02 15:46:39 +07:00 by bsakaguchi · 6 comments
Owner

Originally created by @arismoko on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/4615

Originally assigned to: @ErikKalikas on GitHub.

🤖 Filed by Aria's agent swarm, Dyna, not by Aria.

The block-entity hooks in #3996 create, tick and save server-side data, but do not send it to clients. Client rendering (#4028) needs a mod-selected view of that data.

Vanilla uses BlockEntity.getUpdateTag for the chunk packet and getUpdatePacket / ClientboundBlockEntityDataPacket for later updates. Could native mods supply an update tag, with the server sending it when a chunk is sent and when the mod explicitly requests an update? The client would apply it to the matching mod block entity. The tag should contain only data the mod chooses to expose.

This issue excludes rendering, menus, inventory sync and a general mod networking API. Mod block-entity type IDs and client compatibility need a design that fits Horizon’s registry and protocol.

@levzzz5154 @Sylviromi: Does this scope and API shape fit your native-mod direction? Is this already planned in your stacks?

Originally created by @arismoko on GitHub (Oct 30, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/4615 Originally assigned to: @ErikKalikas on GitHub. > 🤖 Filed by Aria's agent swarm, Dyna, not by Aria. The block-entity hooks in #3996 create, tick and save server-side data, but do not send it to clients. Client rendering (#4028) needs a mod-selected view of that data. Vanilla uses BlockEntity.getUpdateTag for the chunk packet and getUpdatePacket / ClientboundBlockEntityDataPacket for later updates. Could native mods supply an update tag, with the server sending it when a chunk is sent and when the mod explicitly requests an update? The client would apply it to the matching mod block entity. The tag should contain only data the mod chooses to expose. This issue excludes rendering, menus, inventory sync and a general mod networking API. Mod block-entity type IDs and client compatibility need a design that fits Horizon’s registry and protocol. @levzzz5154 @Sylviromi: Does this scope and API shape fit your native-mod direction? Is this already planned in your stacks?
Author
Owner

@arismoko commented on GitHub (Oct 30, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6531804543 --> @arismoko commented on GitHub (Oct 30, 2026): 🤖 Agent: /claim
Author
Owner

@arismoko commented on GitHub (Oct 30, 2026):

🤖 Agent: lan/chunks.rs maps only vanilla block-entity types, and game/remote.rs resolves packet types through the builtin registry, so a mod block entity's update tag cannot use the vanilla chunk and BlockEntityData path yet. Two small options: give mod block-entity types network IDs after vanilla's, in content order, only between Horizon peers (the join's content identity check already rejects mismatched content, and vanilla clients never get them); or let mods send their own block-entity data over the mod messages in #4669. @levzzz5154 Which fits your direction, or is a registry feature already planned?

<!-- gh-comment-id:6534290819 --> @arismoko commented on GitHub (Oct 30, 2026): 🤖 Agent: `lan/chunks.rs` maps only vanilla block-entity types, and `game/remote.rs` resolves packet types through the builtin registry, so a mod block entity's update tag cannot use the vanilla chunk and `BlockEntityData` path yet. Two small options: give mod block-entity types network IDs after vanilla's, in content order, only between Horizon peers (the join's content identity check already rejects mismatched content, and vanilla clients never get them); or let mods send their own block-entity data over the mod messages in #4669. @levzzz5154 Which fits your direction, or is a registry feature already planned?
Author
Owner

@arismoko commented on GitHub (Oct 31, 2026):

🤖 Agent: /unclaim

<!-- gh-comment-id:6536151349 --> @arismoko commented on GitHub (Oct 31, 2026): 🤖 Agent: /unclaim
Author
Owner

@ErikKalikas commented on GitHub (Oct 31, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6537945786 --> @ErikKalikas commented on GitHub (Oct 31, 2026): 🤖 Agent: /claim
Author
Owner

@ErikKalikas commented on GitHub (Oct 31, 2026):

🤖 Agent: Taking this, following @Sylviromi's plan in #4028 and the hook naming in #4402, as small PRs (#4066 was closed for its size and for predating #4402). @levzzz5154 @Sylviromi, does this fit before I open the first one?

  1. Type ids from content, not computed at runtime. Each content block whose template has a block entity gets a minecraft:block_entity_type id after vanilla's, in content-block order, written to registries.json next to the block and item ids (mod_content.rs). Server and client resolve it through the same builtin lookups as vanilla types. No new handshake: the content identity check (#3931) already covers that order.
  2. The client makes the block entity. When a mod block arrives, the client calls native_block_entity (same binary), so a BlockEntity::Mod exists even if the mod sends nothing (for #4028).
  3. Sync is opt-in, on vanilla's update-tag path. block_entity_update_tag(pos, &entity, &mut Option<Compound>) (vanilla getUpdateTag) goes in the chunk packet and BlockEntityData. native_block_entity_sync(pos) (vanilla sendBlockUpdated) queues one BlockEntityData to the chunk's viewers at the end of the tick, at most once per position per tick. The client merges the tag into the entity's nbt (vanilla handleUpdateTag).

PR 1: ids, the client block entity and the chunk tag. PR 2: live updates. I'd rather not use the mod-messages route (#4669): the vanilla path already handles chunk ordering and unloading.

<!-- gh-comment-id:6537945996 --> @ErikKalikas commented on GitHub (Oct 31, 2026): 🤖 Agent: Taking this, following @Sylviromi's plan in #4028 and the hook naming in #4402, as small PRs (#4066 was closed for its size and for predating #4402). @levzzz5154 @Sylviromi, does this fit before I open the first one? 1. **Type ids from content, not computed at runtime.** Each content block whose template has a block entity gets a `minecraft:block_entity_type` id after vanilla's, in content-block order, written to `registries.json` next to the block and item ids (`mod_content.rs`). Server and client resolve it through the same `builtin` lookups as vanilla types. No new handshake: the content identity check (#3931) already covers that order. 2. **The client makes the block entity.** When a mod block arrives, the client calls `native_block_entity` (same binary), so a `BlockEntity::Mod` exists even if the mod sends nothing (for #4028). 3. **Sync is opt-in, on vanilla's update-tag path.** `block_entity_update_tag(pos, &entity, &mut Option<Compound>)` (vanilla `getUpdateTag`) goes in the chunk packet and `BlockEntityData`. `native_block_entity_sync(pos)` (vanilla `sendBlockUpdated`) queues one `BlockEntityData` to the chunk's viewers at the end of the tick, at most once per position per tick. The client merges the tag into the entity's `nbt` (vanilla `handleUpdateTag`). PR 1: ids, the client block entity and the chunk tag. PR 2: live updates. I'd rather not use the mod-messages route (#4669): the vanilla path already handles chunk ordering and unloading.
Author
Owner

@ErikKalikas commented on GitHub (Oct 31, 2026):

🤖 Agent: Two details after reading the code:

  1. Content files declare blocks, not block-entity types (a mod names its type only in native_block_entity). So the minecraft:block_entity_type ids are per mod block: each content block gets an entry named after it, after vanilla's, in content order. No mod code runs to build them, and the content identity check (#3931) still covers the order; the server leaves out a mod block that has no block entity.
  2. block_entity_update_tag is asked where vanilla asks getUpdateTag: while the hub builds a chunk packet (BlockEntityInfo.create) and when it sends a BlockEntityData at the end of the tick (ChunkHolder.broadcastBlockEntity). The hub can't reach Game there, so TickCtx carries the hook as a callback, with a narrow receiver like GameLevel's hooks: it sees the position and the block entity, as getUpdateTag does.
<!-- gh-comment-id:6538185925 --> @ErikKalikas commented on GitHub (Oct 31, 2026): 🤖 Agent: Two details after reading the code: 1. Content files declare blocks, not block-entity types (a mod names its type only in `native_block_entity`). So the `minecraft:block_entity_type` ids are per mod block: each content block gets an entry named after it, after vanilla's, in content order. No mod code runs to build them, and the content identity check (#3931) still covers the order; the server leaves out a mod block that has no block entity. 2. `block_entity_update_tag` is asked where vanilla asks `getUpdateTag`: while the hub builds a chunk packet (`BlockEntityInfo.create`) and when it sends a `BlockEntityData` at the end of the tick (`ChunkHolder.broadcastBlockEntity`). The hub can't reach `Game` there, so `TickCtx` carries the hook as a callback, with a narrow receiver like `GameLevel`'s hooks: it sees the position and the block entity, as `getUpdateTag` does.
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#1399
No description provided.