[PR #3750] [MERGED] Block entities: a loaded chunk's entity replaces the old one by block state (#3707) #5193

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3750
Author: @leifiyoo
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @ludovic111

Base: main ← Head: fix/chunk-block-entity-replace


📝 Commits (1)

  • 978c422 Replace block entities in a loaded chunk by block state

📊 Changes

1 file changed (+45 additions, -2 deletions)

View changed files

📝 crates/horizon-client-render/src/block_entities.rs (+45 -2)

📄 Description

🤖 Opened by leifiyoo's AI agent (Claude), not by leifiyoo himself.

What and why

Fixes #3707.

BlockEntities::load_chunk put each loaded block entity into the map over any entity already at its position, and kept that position's ticker slot whatever the new block state was. Vanilla's LevelChunk.setBlockEntity drops the previous entry, and updateBlockEntityTicker rebinds the ticker only when the new state has one; without one, it removes the ticker.

This PR records replaced positions and, at the next tick, frees their slot unless their block state ticks (Ticking::Yes). A regression test covers both a replacement that keeps the slot and one that frees it.

Scope, stated plainly: the current callers (streaming.rs receive_generated, remote_chunks.rs remote_chunk) clear the column before loading, so I found no player-facing path that reaches this collision today. This fixes a mismatch with vanilla at the API level; it changes no behaviour a player can currently reach.

Vanilla reference

  • LevelChunk.setBlockEntity (previous entry is marked removed)
  • LevelChunk.updateBlockEntityTicker (rebind if the state has a ticker, otherwise remove it)
  • LevelChunk.registerAllBlockEntitiesAfterLevelLoad (tick order, already followed by chunk_map_order)

Harness: tools/test_block_entity_tickers_parity.py --scenarios 300 with JDK 25: 2074 of 2074 ticks match vanilla.

Not verified

  • No game run.
  • cargo clippy and cargo test for horizon-client, which depends on this crate, were not run. The public API is unchanged.
  • tools/parity.py (and so pr_ready's harness step) fails on this Windows machine with ModuleNotFoundError: No module named 'fcntl'. That is a Unix-only import in the tool, not this change. The harness above was run directly instead.

Self-check

pr_ready (tools/pr_ready.py --base upstream/main, against upstream/main at 2286d42b7, 3 min 31 s)

Scope                         1 file, +45 -2
Cargo.lock                    unchanged
Public tree                   ok
Python tests                  416 passed (58 s)
rustfmt                       ok (9 s)
clippy                        ok (1 min 43 s)
tests: horizon-client-render  518 passed (17 s)
doc tests                     0 passed (15 s)
Parity                        FAIL on Windows: tools/parity.py imports fcntl (see Not verified)

🤖 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/3750 **Author:** [@leifiyoo](https://github.com/leifiyoo) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/chunk-block-entity-replace` --- ### 📝 Commits (1) - [`978c422`](https://github.com/horizon-rust/horizon/commit/978c42216a26d81f1edde7260ba0c9145374bb3d) Replace block entities in a loaded chunk by block state ### 📊 Changes **1 file changed** (+45 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/block_entities.rs` (+45 -2) </details> ### 📄 Description > 🤖 Opened by leifiyoo's AI agent (Claude), not by leifiyoo himself. ## What and why Fixes #3707. `BlockEntities::load_chunk` put each loaded block entity into the map over any entity already at its position, and kept that position's ticker slot whatever the new block state was. Vanilla's `LevelChunk.setBlockEntity` drops the previous entry, and `updateBlockEntityTicker` rebinds the ticker only when the new state has one; without one, it removes the ticker. This PR records replaced positions and, at the next tick, frees their slot unless their block state ticks (`Ticking::Yes`). A regression test covers both a replacement that keeps the slot and one that frees it. **Scope, stated plainly:** the current callers (`streaming.rs` `receive_generated`, `remote_chunks.rs` `remote_chunk`) clear the column before loading, so I found no player-facing path that reaches this collision today. This fixes a mismatch with vanilla at the API level; it changes no behaviour a player can currently reach. ## Vanilla reference - `LevelChunk.setBlockEntity` (previous entry is marked removed) - `LevelChunk.updateBlockEntityTicker` (rebind if the state has a ticker, otherwise remove it) - `LevelChunk.registerAllBlockEntitiesAfterLevelLoad` (tick order, already followed by `chunk_map_order`) Harness: `tools/test_block_entity_tickers_parity.py --scenarios 300` with JDK 25: 2074 of 2074 ticks match vanilla. ## Not verified - No game run. - `cargo clippy` and `cargo test` for `horizon-client`, which depends on this crate, were not run. The public API is unchanged. - `tools/parity.py` (and so `pr_ready`'s harness step) fails on this Windows machine with `ModuleNotFoundError: No module named 'fcntl'`. That is a Unix-only import in the tool, not this change. The harness above was run directly instead. ## Self-check ``` pr_ready (tools/pr_ready.py --base upstream/main, against upstream/main at 2286d42b7, 3 min 31 s) Scope 1 file, +45 -2 Cargo.lock unchanged Public tree ok Python tests 416 passed (58 s) rustfmt ok (9 s) clippy ok (1 min 43 s) tests: horizon-client-render 518 passed (17 s) doc tests 0 passed (15 s) Parity FAIL on Windows: tools/parity.py imports fcntl (see Not verified) ``` 🤖 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:10:52 +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#5193
No description provided.