[PR #5220] [MERGED] Native mods: sync a mod block entity to clients (sendBlockUpdated) #6146

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

📋 Pull Request Information

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

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


📝 Commits (4)

  • 0ea18b9 Native mods: sync a mod block entity to clients (sendBlockUpdated)
  • 16f7efa Merge mod-block-entity-sync (upstream/main); renumber native_block_entity_sync to API 44
  • d0f81cc Merge main into #5220; native_block_entity_sync takes its API number from a fragment
  • f2b2d3c Merge main into #5220 (main's clippy fix 825a6bbcf)

📊 Changes

3 files changed (+136 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game/native_hooks.rs (+17 -0)
📝 crates/horizon-client/tests/lan_bot.rs (+114 -0)
➕ tools/native-hook-fragments/native-block-entity-sync.json (+5 -0)

📄 Description

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

What and why

Part 2 of #4615. Builds on #4935: until it lands, review only 0ea18b987, and in the merge after it (16f7efa54, which takes in main and #4935) the renumbering to API 44.

native_block_entity_sync(pos) is vanilla's Level.sendBlockUpdated for a mod block entity. It puts the position in the level's block log, as sendBlockUpdated marks ChunkHolder.blockChanged. The hub then sends the block and its update tag (native_block_entity_update_tag) to the players who see its chunk, once per position a tick, as ChunkHolder.broadcastChanges does. spawner_block_updated already does the same for spawners. A change made in a block entity's tick goes out at the start of the next tick, as in vanilla: ServerLevel.tick broadcasts chunks before tickBlockEntities. An unloaded position does nothing. NATIVE_HOOKS_API 44, docs/native-mods.md.

For mods with many machines, the docs say to sync when what clients show changes, not every tick: a menu's data slots carry progress.

Fixes #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), following ServerLevel.sendBlockUpdated → ServerChunkCache.blockChanged → ChunkHolder.blockChanged / broadcastChanges / broadcastBlockEntity, and the order in ServerLevel.tick (read with tools/rea_vanilla.py). Test tests/lan_bot.rs::a_synced_mod_block_entity_reaches_the_chunks_players_once_a_tick: a bot on a real hub gets the machine's tag in the chunk, one BlockEntityData for two syncs in a tick, and none for a block entity whose mod gives no tag.

Self-check

Merged with main at d91cab68d through #4935's branch (renumbered to API 44).

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

Check Result
Scope ✅ 11 files, +326 −30
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (20 s)
rustfmt ✅ (5 s)
clippy ✅ (20 s)
tests: horizon-client ✅ 1345 passed (2 min 13 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/5220 **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-live` --- ### 📝 Commits (4) - [`0ea18b9`](https://github.com/horizon-rust/horizon/commit/0ea18b9878001ecf908a813053a2ee2a2b91767c) Native mods: sync a mod block entity to clients (sendBlockUpdated) - [`16f7efa`](https://github.com/horizon-rust/horizon/commit/16f7efa54d6e7b16613e8500fe97dcd6bb8ab920) Merge mod-block-entity-sync (upstream/main); renumber native_block_entity_sync to API 44 - [`d0f81cc`](https://github.com/horizon-rust/horizon/commit/d0f81cc03984d4bc22f555235089dac072496385) Merge main into #5220; native_block_entity_sync takes its API number from a fragment - [`f2b2d3c`](https://github.com/horizon-rust/horizon/commit/f2b2d3c1c03ebca5c2548b77239cea230e64a0a6) Merge main into #5220 (main's clippy fix 825a6bbcf) ### 📊 Changes **3 files changed** (+136 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/native_hooks.rs` (+17 -0) 📝 `crates/horizon-client/tests/lan_bot.rs` (+114 -0) ➕ `tools/native-hook-fragments/native-block-entity-sync.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 2 of #4615. **Builds on #4935: until it lands, review only `0ea18b987`**, and in the merge after it (`16f7efa54`, which takes in main and #4935) the renumbering to API 44. `native_block_entity_sync(pos)` is vanilla's `Level.sendBlockUpdated` for a mod block entity. It puts the position in the level's block log, as `sendBlockUpdated` marks `ChunkHolder.blockChanged`. The hub then sends the block and its update tag (`native_block_entity_update_tag`) to the players who see its chunk, once per position a tick, as `ChunkHolder.broadcastChanges` does. `spawner_block_updated` already does the same for spawners. A change made in a block entity's tick goes out at the start of the next tick, as in vanilla: `ServerLevel.tick` broadcasts chunks before `tickBlockEntities`. An unloaded position does nothing. `NATIVE_HOOKS_API` 44, `docs/native-mods.md`. For mods with many machines, the docs say to sync when what clients show changes, not every tick: a menu's data slots carry progress. Fixes #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), following `ServerLevel.sendBlockUpdated` → `ServerChunkCache.blockChanged` → `ChunkHolder.blockChanged` / `broadcastChanges` / `broadcastBlockEntity`, and the order in `ServerLevel.tick` (read with `tools/rea_vanilla.py`). Test `tests/lan_bot.rs::a_synced_mod_block_entity_reaches_the_chunks_players_once_a_tick`: a bot on a real hub gets the machine's tag in the chunk, one `BlockEntityData` for two syncs in a tick, and none for a block entity whose mod gives no tag. ## Self-check Merged with main at d91cab68d through #4935's branch (renumbered to API 44). **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on kased-h610mkddr4, against upstream/main at d91cab68d, 3 min 40 s) | Check | Result | | --- | --- | | Scope | ✅ 11 files, +326 −30 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (20 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (20 s) | | tests: horizon-client | ✅ 1345 passed (2 min 13 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 06:14:54 +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#6146
No description provided.