[PR #4935] [MERGED] Native mods: send mod block entities to clients #5954

Closed
opened 2026-11-03 05:16:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

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


📝 Commits (4)

  • 89f4d8e Native mods: send mod block entities to clients
  • dd0c770 Drop empty chunk update tags; replace a mod block entity on another block
  • f755be1 Merge upstream/main; renumber mod block entity update tags to API 43
  • 28cbd6c Merge main; renumber mod block entity update tags to API 45

📊 Changes

10 files changed (+192 additions, -30 deletions)

View changed files

📝 crates/horizon-client/src/game/lan.rs (+5 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+20 -3)
📝 crates/horizon-client/src/game/remote.rs (+29 -10)
📝 crates/horizon-client/src/game/remote_chunks.rs (+1 -1)
📝 crates/horizon-client/src/lan/chunks.rs (+104 -10)
📝 crates/horizon-client/src/lan/hub.rs (+1 -1)
📝 crates/horizon-client/src/mod_content.rs (+11 -3)
📝 crates/horizon-client/src/mod_content_tests.rs (+9 -2)
📝 docs/native-mods.md (+7 -0)
📝 native-hooks.json (+5 -0)

📄 Description

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

What and why

Part 1 of #4615 (plan: comment, correction). A mod block's block entity now reaches clients the way vanilla sends its own; until now a client had no copy of it at all (sync_block_entity only knew BlockEntity::for_block).

  • Type ids (mod_content.rs): each content block gets a minecraft:block_entity_type entry in registries.json, named after it, after vanilla's, in content order. No mod code runs to build them; the content identity check (#3931) covers the order.
  • Server (lan/chunks.rs, lan/hub.rs): the chunk encoder flags mod blocks, sends their block entity with the block's type and the tag of the new hook native_block_entity_update_tag (getUpdateTag, read from the block entity alone), and leaves out a mod block whose mod made no block entity. BlockEntityData on a block change uses the same hook (ChunkEncoder::update_tag). The hook is asked only for chunks actually sent, so machines nobody watches cost nothing.
  • Client (game/remote.rs): makes its copy through native_block_entity (same binary), and merges the update tag into the copy's nbt (handleUpdateTag). The section is not redrawn: nothing is drawn from it yet (#4028).
  • Saved chunks past the view distance (lan::far, from main): its detached encoder keeps the hook, so the hook may run off the server thread there; the docs say to read only entity.
  • NATIVE_HOOKS_API 43, native-hooks.json, docs/native-mods.md.

One difference from the correction comment: the hook has no receiver (it only sees the position and the block entity, as getUpdateTag does), so the encoder keeps it as a plain fn pointer (ChunkEncoder::mod_update_tag, set in game/lan.rs) instead of a callback in TickCtx.

Next, PR 2: native_block_entity_sync(pos) (sendBlockUpdated), which puts the position in the block log so the hub sends the BlockEntityData at the end of the tick.

Refs #4615

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Horizon-only (native mods). Follows where vanilla asks BlockEntity.getUpdateTag: ClientboundLevelChunkPacketData.BlockEntityInfo.create and ChunkHolder.broadcastBlockEntity (checked with tools/rea_vanilla.py callers). Unit tests: lan::chunks::tests::mod_block_entities_carry_their_blocks_type_and_the_mods_tag, and the block entity type ids in mod_content::tests::allocated_ids_follow_mod_and_entry_order_after_vanilla. Checked in game by @arismoko on the server thread: block replacement (this PR), live syncs and a chunk reload (#5220).

Self-check

Merged with main at d91cab68d (hooks renumbered to API 43).

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

Check Result
Scope ✅ 10 files, +190 −30
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (20 s)
rustfmt ✅ (5 s)
clippy ✅ (25 s)
tests: horizon-client ✅ 1344 passed (2 min 11 s)
doc tests ✅ 0 passed (1 s)
content root tests ✅ 7 passed (36 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 274 affected, to run in CI (--quick): cauldron, creative, datafix, datapack_worldgen, decorated_region, decoration, decoration_region, dedicated_server, delta, density, disk, dispenser and 262 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/4935 **Author:** [@ErikKalikas](https://github.com/ErikKalikas) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `mod-block-entity-sync` --- ### 📝 Commits (4) - [`89f4d8e`](https://github.com/horizon-rust/horizon/commit/89f4d8e6351d363e4dfc5f39d217454d0029a22e) Native mods: send mod block entities to clients - [`dd0c770`](https://github.com/horizon-rust/horizon/commit/dd0c770b864e789f84ee28b488b9a502304cd55a) Drop empty chunk update tags; replace a mod block entity on another block - [`f755be1`](https://github.com/horizon-rust/horizon/commit/f755be19d820347446cc318e28e3d90bfab56674) Merge upstream/main; renumber mod block entity update tags to API 43 - [`28cbd6c`](https://github.com/horizon-rust/horizon/commit/28cbd6c861aaaf6b5eec887c47ae1e4e0434b2f3) Merge main; renumber mod block entity update tags to API 45 ### 📊 Changes **10 files changed** (+192 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan.rs` (+5 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+20 -3) 📝 `crates/horizon-client/src/game/remote.rs` (+29 -10) 📝 `crates/horizon-client/src/game/remote_chunks.rs` (+1 -1) 📝 `crates/horizon-client/src/lan/chunks.rs` (+104 -10) 📝 `crates/horizon-client/src/lan/hub.rs` (+1 -1) 📝 `crates/horizon-client/src/mod_content.rs` (+11 -3) 📝 `crates/horizon-client/src/mod_content_tests.rs` (+9 -2) 📝 `docs/native-mods.md` (+7 -0) 📝 `native-hooks.json` (+5 -0) </details> ### 📄 Description > 🤖 Opened by ErikKalikas's AI agent (Claude Code, Claude Opus 5.5), not by ErikKalikas personally. ## What and why Part 1 of #4615 (plan: [comment](https://github.com/horizon-rust/horizon/issues/4615#issuecomment-6537945996), [correction](https://github.com/horizon-rust/horizon/issues/4615#issuecomment-6538185925)). A mod block's block entity now reaches clients the way vanilla sends its own; until now a client had no copy of it at all (`sync_block_entity` only knew `BlockEntity::for_block`). - **Type ids** (`mod_content.rs`): each content block gets a `minecraft:block_entity_type` entry in `registries.json`, named after it, after vanilla's, in content order. No mod code runs to build them; the content identity check (#3931) covers the order. - **Server** (`lan/chunks.rs`, `lan/hub.rs`): the chunk encoder flags mod blocks, sends their block entity with the block's type and the tag of the new hook `native_block_entity_update_tag` (`getUpdateTag`, read from the block entity alone), and leaves out a mod block whose mod made no block entity. `BlockEntityData` on a block change uses the same hook (`ChunkEncoder::update_tag`). The hook is asked only for chunks actually sent, so machines nobody watches cost nothing. - **Client** (`game/remote.rs`): makes its copy through `native_block_entity` (same binary), and merges the update tag into the copy's `nbt` (`handleUpdateTag`). The section is not redrawn: nothing is drawn from it yet (#4028). - **Saved chunks past the view distance** (`lan::far`, from main): its detached encoder keeps the hook, so the hook may run off the server thread there; the docs say to read only `entity`. - `NATIVE_HOOKS_API` 43, `native-hooks.json`, `docs/native-mods.md`. One difference from the correction comment: the hook has no receiver (it only sees the position and the block entity, as `getUpdateTag` does), so the encoder keeps it as a plain `fn` pointer (`ChunkEncoder::mod_update_tag`, set in `game/lan.rs`) instead of a callback in `TickCtx`. Next, PR 2: `native_block_entity_sync(pos)` (`sendBlockUpdated`), which puts the position in the block log so the hub sends the `BlockEntityData` at the end of the tick. Refs #4615 ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [x] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Horizon-only (native mods). Follows where vanilla asks `BlockEntity.getUpdateTag`: `ClientboundLevelChunkPacketData.BlockEntityInfo.create` and `ChunkHolder.broadcastBlockEntity` (checked with `tools/rea_vanilla.py callers`). Unit tests: `lan::chunks::tests::mod_block_entities_carry_their_blocks_type_and_the_mods_tag`, and the block entity type ids in `mod_content::tests::allocated_ids_follow_mod_and_entry_order_after_vanilla`. Checked in game by @arismoko on the server thread: block replacement (this PR), live syncs and a chunk reload (#5220). ## Self-check Merged with main at d91cab68d (hooks renumbered to API 43). **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on kased-h610mkddr4, against upstream/main at d91cab68d, 3 min 44 s) | Check | Result | | --- | --- | | Scope | ✅ 10 files, +190 −30 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (20 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (25 s) | | tests: horizon-client | ✅ 1344 passed (2 min 11 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ✅ 7 passed (36 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 274 affected, to run in CI (--quick): cauldron, creative, datafix, datapack_worldgen, decorated_region, decoration, decoration_region, dedicated_server, delta, density, disk, dispenser and 262 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 05:16:10 +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#5954
No description provided.