[PR #3857] [MERGED] Fix lever dropping when placed on a piston's back #5253

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3857
Author: @DUzzL
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix/issue-3854-lever-piston


📝 Commits (2)

  • 5782df1 Lever on a piston's back no longer drops when the piston retracts
  • bfda2bf Only a piston base stands in for a retracting moving_piston

📊 Changes

2 files changed (+68 additions, -3 deletions)

View changed files

📝 crates/horizon-world/src/level/query.rs (+30 -3)
📝 crates/horizon-world/src/level/tests.rs (+38 -0)

📄 Description

🤖 Opened by DUzzL's AI agent, not by DUzzL personally.

Fixes #3854

Cause

When a piston retracts, its base position is a moving_piston block for two ticks. The per-state support facts are exported against an empty level, so that block has no block entity and no face counts as sturdy. A lever (or button, wall torch...) on the back of the piston is checked by the neighbour-shape update at the start of the retraction, sees an unsupported face and pops off.

In vanilla the same check goes through PistonMovingBlockEntity.getCollisionShape, which for a retracting source piston contains the extended base (full back face), so the lever stays.

Fix

Sim::sturdy, can_support_center and can_support_rigid_block now use the extended piston base's facts when the block at the position is a moving_piston whose entity is a retracting source piston (!extending && source, moved state is a piston or sticky piston). This mirrors PistonBlockBindings::collision_shape in piston_shape.rs, which uses the extended base in the same case. Every other state is unchanged.

Tests

  • cargo fmt, cargo clippy -p horizon-world --all-targets -- -D warnings: clean.
  • Added lever_on_piston_back_survives_extend_and_retract (piston and sticky piston: lever on the back, power, extend, unpower, retract; the lever must remain).
  • Not verified: the level:: tests skip when the prepared vanilla data (.local/horizon-client/26.3) is missing, and I had none, so the new test compiled but did not execute, and I did not reproduce the bug at runtime. The cause comes from reading the exporter (VanillaBlockBehaviourExporter, EmptyBlockGetter) and the retract path in pistons.rs. port_ledger.py check and pr_ready.py were not run for the same reason.

🔄 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/3857 **Author:** [@DUzzL](https://github.com/DUzzL) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/issue-3854-lever-piston` --- ### 📝 Commits (2) - [`5782df1`](https://github.com/horizon-rust/horizon/commit/5782df1c0322e08a71f1f3238fca728c0739591d) Lever on a piston's back no longer drops when the piston retracts - [`bfda2bf`](https://github.com/horizon-rust/horizon/commit/bfda2bf16503443a77045109972010162fa4dc5c) Only a piston base stands in for a retracting moving_piston ### 📊 Changes **2 files changed** (+68 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-world/src/level/query.rs` (+30 -3) 📝 `crates/horizon-world/src/level/tests.rs` (+38 -0) </details> ### 📄 Description > 🤖 Opened by DUzzL's AI agent, not by DUzzL personally. Fixes #3854 ## Cause When a piston retracts, its base position is a `moving_piston` block for two ticks. The per-state support facts are exported against an empty level, so that block has no block entity and no face counts as sturdy. A lever (or button, wall torch...) on the back of the piston is checked by the neighbour-shape update at the start of the retraction, sees an unsupported face and pops off. In vanilla the same check goes through `PistonMovingBlockEntity.getCollisionShape`, which for a retracting source piston contains the extended base (full back face), so the lever stays. ## Fix `Sim::sturdy`, `can_support_center` and `can_support_rigid_block` now use the extended piston base's facts when the block at the position is a `moving_piston` whose entity is a retracting source piston (`!extending && source`, moved state is a piston or sticky piston). This mirrors `PistonBlockBindings::collision_shape` in `piston_shape.rs`, which uses the extended base in the same case. Every other state is unchanged. ## Tests - `cargo fmt`, `cargo clippy -p horizon-world --all-targets -- -D warnings`: clean. - Added `lever_on_piston_back_survives_extend_and_retract` (piston and sticky piston: lever on the back, power, extend, unpower, retract; the lever must remain). - Not verified: the `level::` tests skip when the prepared vanilla data (`.local/horizon-client/26.3`) is missing, and I had none, so the new test compiled but did not execute, and I did not reproduce the bug at runtime. The cause comes from reading the exporter (`VanillaBlockBehaviourExporter`, `EmptyBlockGetter`) and the retract path in `pistons.rs`. `port_ledger.py check` and `pr_ready.py` were not run for the same reason. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:11:17 +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#5253
No description provided.