[PR #4864] [MERGED] Redstone: a retracting piston no longer breaks the dust on top of it #5899

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4864
Author: @sirrayi
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/redstone-piston-retract


📝 Commits (2)

  • 4f43f49 Redstone: a retracting piston no longer breaks the dust on top of it
  • 07c8bdb Merge main

📊 Changes

4 files changed (+60 additions, -8 deletions)

View changed files

📝 crates/horizon-world/src/level/query.rs (+1 -1)
📝 crates/horizon-world/src/level/redstone.rs (+10 -5)
📝 crates/horizon-world/src/level/survive.rs (+5 -2)
📝 crates/horizon-world/src/level/tests.rs (+44 -0)

📄 Description

🤖 Opened by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi themselves.

What and why

Fixes #4728. Placing redstone dust on a downward-facing piston and activating it broke the dust.

PistonBaseBlock.triggerEvent's retract half writes the base as a moving_piston block for the tick the
base travels in, and still updates the six neighbours around it (level/pistons.rs:699-723). The dust
above the base is one of them, so it is asked whether it can still survive — and Horizon answered no.
moving_piston's exported support facts carry no block entity, so every face reads unsupported
(which is what 5782df1c0's fix for the popping lever documented), while vanilla reads that block
through PistonMovingBlockEntity.getCollisionShape, whose shape contains the extended base. Both dust
paths read the raw facts:

  • survive.rs (RedstoneWireBlock.canSurvive) → is_face_sturdy(below_state, Up) → false → the dust
    drops and is removed;
  • redstone.rs's updateShape down arm → wire_can_survive_on(neighbour) → false → air.

The fix is what the existing Sim::support_state indirection was added for: it answers a moving_piston
whose moved state is a retracting piston base with that piston extended, and every other support query
in the tree already goes through it (sturdy, can_support_rigid_block, can_support_center). Dust now
does too:

  • query.rs: support_state is pub(super) so the redstone module can use it.
  • redstone.rs: wire_can_survive_on takes the position and reads it through support_state instead
    of taking a state by value. Both callers had the position to hand (npos in update_shape, which the
    function already took but ignored, and relative_pos in wire_connecting_side).
  • survive.rs: the RedstoneWire arm uses self.sturdy(below, Up).

Nothing else changes: wire_can_survive_on is dust-only, and the hopper exception keeps reading the real
state. Redstone power and the dust's connection shape are untouched.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Vanilla reference

PistonBaseBlock.triggerEvent (the retracting base written with UPDATE_KNOWN_SHAPE, and
PistonMovingBlockEntity.getCollisionShape holding the extended base), RedstoneWireBlock.canSurvive /
canSurviveOn, and RedstoneWireBlock.updateShape's Direction.DOWN arm. The moving_piston
indirection itself is blocks/entities support, already in query::support_state.

New test level::tests::dust_on_a_downward_piston_survives_extend_and_retract in
crates/horizon-world/src/level/tests.rs, next to the lever case it shares a cause with: a piston facing
down with a redstone block beside it, dust above, four full ticks to extend and four more to retract,
asserting the dust is still redstone_wire after both. It fails on main (the dust is gone after the
retract) and passes with the change.

No harness: this is block-support bookkeeping inside horizon-world, where the existing
test_block_update_parity.py / test_piston_*_parity.py families live; none of them covers a retracting
piston with dust on top. If a maintainer wants one, the natural home is the piston harness with the
downward orientation added.

Self-check

cargo fmt --all -- --check                                   ✅
cargo test -p horizon-world --lib level::                    76 passed; 0 failed
cargo clippy -p horizon-world --all-targets -- -D warnings    ✅

python3 tools/pr_ready.py was not run to completion here: this machine has no prepared vanilla data
(.local/), so its harness half only lists what CI must run, and its workspace-wide clippy pass competes
with other work on the same build cache. CI's verify covers fmt/clippy/tests for the whole workspace.

On main the new test is red by the same path that made the lever pop: moving_piston's exported support
facts carry no block entity and call every face unsupported (5782df1c0's comment on support_state
says so, and the lever's own test was red before that change). I could not re-run it on main here — the
shared build cache is saturated by other agents — so the red half rests on that reasoning rather than on a
recorded run.

Screenshots

Players see it: a piston facing down with dust on it, activated by a lever — the dust used to pop off on
retract and now stays. I have no prepared vanilla data on this machine, so I could not capture it; the
support decision is asserted by the test instead.


🔄 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/4864 **Author:** [@sirrayi](https://github.com/sirrayi) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/redstone-piston-retract` --- ### 📝 Commits (2) - [`4f43f49`](https://github.com/horizon-rust/horizon/commit/4f43f49cf7a05953de611dd56f74268f3aa9bf4a) Redstone: a retracting piston no longer breaks the dust on top of it - [`07c8bdb`](https://github.com/horizon-rust/horizon/commit/07c8bdbc0b163925a10197d6274b3a9640f540f0) Merge main ### 📊 Changes **4 files changed** (+60 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-world/src/level/query.rs` (+1 -1) 📝 `crates/horizon-world/src/level/redstone.rs` (+10 -5) 📝 `crates/horizon-world/src/level/survive.rs` (+5 -2) 📝 `crates/horizon-world/src/level/tests.rs` (+44 -0) </details> ### 📄 Description > 🤖 Opened by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi themselves. ## What and why Fixes #4728. Placing redstone dust on a downward-facing piston and activating it broke the dust. `PistonBaseBlock.triggerEvent`'s retract half writes the base as a `moving_piston` block for the tick the base travels in, and still updates the six neighbours around it (`level/pistons.rs:699-723`). The dust above the base is one of them, so it is asked whether it can still survive — and Horizon answered no. `moving_piston`'s *exported* support facts carry no block entity, so every face reads unsupported (which is what `5782df1c0`'s fix for the popping lever documented), while vanilla reads that block through `PistonMovingBlockEntity.getCollisionShape`, whose shape contains the extended base. Both dust paths read the raw facts: - `survive.rs` (`RedstoneWireBlock.canSurvive`) → `is_face_sturdy(below_state, Up)` → false → the dust drops and is removed; - `redstone.rs`'s `updateShape` down arm → `wire_can_survive_on(neighbour)` → false → air. The fix is what the existing `Sim::support_state` indirection was added for: it answers a `moving_piston` whose moved state is a retracting piston base with that piston *extended*, and every other support query in the tree already goes through it (`sturdy`, `can_support_rigid_block`, `can_support_center`). Dust now does too: - `query.rs`: `support_state` is `pub(super)` so the redstone module can use it. - `redstone.rs`: `wire_can_survive_on` takes the position and reads it through `support_state` instead of taking a state by value. Both callers had the position to hand (`npos` in `update_shape`, which the function already took but ignored, and `relative_pos` in `wire_connecting_side`). - `survive.rs`: the `RedstoneWire` arm uses `self.sturdy(below, Up)`. Nothing else changes: `wire_can_survive_on` is dust-only, and the hopper exception keeps reading the real state. Redstone power and the dust's connection shape are untouched. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Vanilla reference `PistonBaseBlock.triggerEvent` (the retracting base written with `UPDATE_KNOWN_SHAPE`, and `PistonMovingBlockEntity.getCollisionShape` holding the extended base), `RedstoneWireBlock.canSurvive` / `canSurviveOn`, and `RedstoneWireBlock.updateShape`'s `Direction.DOWN` arm. The `moving_piston` indirection itself is `blocks/entities` support, already in `query::support_state`. New test `level::tests::dust_on_a_downward_piston_survives_extend_and_retract` in `crates/horizon-world/src/level/tests.rs`, next to the lever case it shares a cause with: a piston facing down with a redstone block beside it, dust above, four full ticks to extend and four more to retract, asserting the dust is still `redstone_wire` after both. It fails on main (the dust is gone after the retract) and passes with the change. No harness: this is block-support bookkeeping inside `horizon-world`, where the existing `test_block_update_parity.py` / `test_piston_*_parity.py` families live; none of them covers a retracting piston with dust on top. If a maintainer wants one, the natural home is the piston harness with the downward orientation added. ## Self-check ``` cargo fmt --all -- --check ✅ cargo test -p horizon-world --lib level:: 76 passed; 0 failed cargo clippy -p horizon-world --all-targets -- -D warnings ✅ ``` `python3 tools/pr_ready.py` was not run to completion here: this machine has no prepared vanilla data (`.local/`), so its harness half only lists what CI must run, and its workspace-wide clippy pass competes with other work on the same build cache. CI's `verify` covers fmt/clippy/tests for the whole workspace. On main the new test is red by the same path that made the lever pop: `moving_piston`'s exported support facts carry no block entity and call every face unsupported (`5782df1c0`'s comment on `support_state` says so, and the lever's own test was red before that change). I could not re-run it on main here — the shared build cache is saturated by other agents — so the red half rests on that reasoning rather than on a recorded run. ## Screenshots Players see it: a piston facing down with dust on it, activated by a lever — the dust used to pop off on retract and now stays. I have no prepared vanilla data on this machine, so I could not capture it; the support decision is asserted by the test instead. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:15:46 +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#5899
No description provided.