[PR #1573] [MERGED] Commands: a placed block keeps its block entity when a neighbour update changes its state #3600

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1573
Author: @Domanffe
Created: 10/24/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @ludovic111

Base: main ← Head: fix/placed-block-entity-keeps-state


📝 Commits (2)

  • 493e5f8 Commands: a placed block keeps its block entity when a neighbour update changes its state
  • 0c68168 Commands: fold the block check into place_state's condition; cover /fill in the corpus

📊 Changes

2 files changed (+12 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/commands.rs (+4 -1)
📝 tools/command_exec_corpus.py (+8 -0)

📄 Description

🤖 Opened by Alexander's AI agent (Hermes), not by Alexander himself.

Fixes #1506.

What and why

/setblock created a block entity only when the state that landed matched the requested state exactly. A hopper placed into power never matches: HopperBlock.onPlace runs checkPoweredState, so the block is already enabled=false by the time place_state reaches its check, and the hopper ends up with no inventory.

From the player's side: /data get block answers "The target block is not a block entity", items dropped on top stay item entities, and /setblock hopper{Items:[...]} loses its NBT, because load_block_entity_nbt has no entity to write into.

The fix compares the block at the position with the block that was placed, instead of comparing whole states. If a neighbour update put something else there, or removed the block, no entity is created, as before. A state change within the same block keeps it, which is what vanilla does.

The regression sits in tools/command_exec_corpus.py: a redstone block, a hopper above it, then data get and an item replace into the hopper. No new harness, since test_command_exec_parity already compares that corpus group.

Vanilla reference

net.minecraft.world.level.block.HopperBlock#onPlace calls checkPoweredState, which is the enabled flip. LevelChunk#setBlockState builds the block entity from the placed state, and the neighbour updates run after it. The same shape already exists in Game::put_block for agent control and in the player placement path: both create the entity from the block's name.

Self-check

pr_ready (tools/pr_ready.py --quick on dmffe, against origin/main at d65282fb0, 3 min 50 s)

Check Result
Scope ✅ 2 files, +13 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 287 run, FAILED (failures=2, errors=1, skipped=1) (26 s)
rustfmt ✅ (10 s)
clippy ❌ failed (50 s)
tests: horizon-client ❌ 1049 passed, 3 failed (2 min 18 s)
doc tests ✅ 0 passed (2 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

These ran on a Windows box, so three of them fail for reasons that have nothing to do with this diff. I stashed the change and reran the lib suite on a clean tree at d65282fb: same three failures, 1049 passed.

  • clippy: one pre-existing boxed_local warning in streaming.rs:644, a file this PR does not touch. The checks workflow is green on d65282fb.
  • Python tests: symlink_to wants a privilege this shell lacks, and two tests compare paths with separators this platform does not produce.
  • tests: horizon-client: save::tests::session_lock_is_exclusive, packs::cache::tests::directory_inputs_config_and_owned_output_recovery and crash::tests::stacks_start_at_the_panicking_frame are Windows locking, ACL and backtrace specifics.

No vanilla data on this machine, so the harnesses did not run here.

🤖 Generated with Hermes Agent (Nous Research)


🔄 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/1573 **Author:** [@Domanffe](https://github.com/Domanffe) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/placed-block-entity-keeps-state` --- ### 📝 Commits (2) - [`493e5f8`](https://github.com/horizon-rust/horizon/commit/493e5f8d3a825acdf256c3f53a801a9d292644dc) Commands: a placed block keeps its block entity when a neighbour update changes its state - [`0c68168`](https://github.com/horizon-rust/horizon/commit/0c6816811c1959e7268d4a587600651ccb99dd4c) Commands: fold the block check into place_state's condition; cover /fill in the corpus ### 📊 Changes **2 files changed** (+12 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands.rs` (+4 -1) 📝 `tools/command_exec_corpus.py` (+8 -0) </details> ### 📄 Description > 🤖 Opened by Alexander's AI agent (Hermes), not by Alexander himself. Fixes #1506. ## What and why `/setblock` created a block entity only when the state that landed matched the requested state exactly. A hopper placed into power never matches: `HopperBlock.onPlace` runs `checkPoweredState`, so the block is already `enabled=false` by the time `place_state` reaches its check, and the hopper ends up with no inventory. From the player's side: `/data get block` answers "The target block is not a block entity", items dropped on top stay item entities, and `/setblock hopper{Items:[...]}` loses its NBT, because `load_block_entity_nbt` has no entity to write into. The fix compares the block at the position with the block that was placed, instead of comparing whole states. If a neighbour update put something else there, or removed the block, no entity is created, as before. A state change within the same block keeps it, which is what vanilla does. The regression sits in `tools/command_exec_corpus.py`: a redstone block, a hopper above it, then `data get` and an `item replace` into the hopper. No new harness, since `test_command_exec_parity` already compares that corpus group. ## Vanilla reference `net.minecraft.world.level.block.HopperBlock#onPlace` calls `checkPoweredState`, which is the `enabled` flip. `LevelChunk#setBlockState` builds the block entity from the placed state, and the neighbour updates run after it. The same shape already exists in `Game::put_block` for agent control and in the player placement path: both create the entity from the block's name. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on dmffe, against origin/main at d65282fb0, 3 min 50 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +13 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 287 run, FAILED (failures=2, errors=1, skipped=1) (26 s) | | rustfmt | ✅ (10 s) | | clippy | ❌ failed (50 s) | | tests: horizon-client | ❌ 1049 passed, 3 failed (2 min 18 s) | | doc tests | ✅ 0 passed (2 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | These ran on a Windows box, so three of them fail for reasons that have nothing to do with this diff. I stashed the change and reran the lib suite on a clean tree at `d65282fb`: same three failures, 1049 passed. - clippy: one pre-existing `boxed_local` warning in `streaming.rs:644`, a file this PR does not touch. The `checks` workflow is green on `d65282fb`. - Python tests: `symlink_to` wants a privilege this shell lacks, and two tests compare paths with separators this platform does not produce. - `tests: horizon-client`: `save::tests::session_lock_is_exclusive`, `packs::cache::tests::directory_inputs_config_and_owned_output_recovery` and `crash::tests::stacks_start_at_the_panicking_frame` are Windows locking, ACL and backtrace specifics. No vanilla data on this machine, so the harnesses did not run here. 🤖 Generated with Hermes Agent (Nous Research) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:10:44 +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#3600
No description provided.