[PR #4766] [MERGED] Native mods: a refused sticky pull sends clients the blocks, not the retraction #5838

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

📋 Pull Request Information

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

Base: main ← Head: fix/refused-pull-no-event


📝 Commits (1)

  • 917e58b Native mods: a refused sticky pull sends clients the blocks, not the retraction

📊 Changes

3 files changed (+48 additions, -9 deletions)

View changed files

📝 crates/horizon-client/src/game/native_hooks.rs (+3 -1)
📝 crates/horizon-world/src/level/pistons.rs (+14 -8)
📝 crates/horizon-world/src/level/tests.rs (+31 -0)

📄 Description

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

Follow-up to #4739, from Dyna's review there
(https://github.com/horizon-rust/horizon/pull/4739#issuecomment-6535399465). #4739 merged before this fix was
pushed.

What

When a native mod refuses a sticky piston's pull (native_piston_move), the server kept the block. It still
broadcast the retraction's block event, though. Clients aren't asked whether a piston may move, so they replayed
the event and pulled the block anyway, until the chunk reloaded.

  • piston_move_blocks returns Option<bool>: None when the level refused the move, Some(false) when the
    structure can't move (as before), Some(true) when it moved.
  • piston_trigger_event returns false for a retraction whose pull was refused, so it isn't broadcast, as a failed
    push isn't. Clients get the server's block changes instead: the piston and its head retract, and the block stays.
  • Without a mod nothing is refused, so vanilla's path is unchanged.

Tests

  • refused_sticky_pull_keeps_the_block_and_sends_no_event: no BlockEntityEvent for the piston, and the dirt is
    kept. Fails without the fix (the event is emitted).
  • All piston tests of horizon-world pass (25 with the refused_ ones).
  • python3 tools/parity.py piston_movement piston_push piston_shape: 3 passed.
  • cargo clippy -p horizon-world --all-targets -D warnings and cargo fmt --check are clean.

pr_ready (full) follows in a comment: a load benchmark is running on this machine.

🤖 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/4766 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/refused-pull-no-event` --- ### 📝 Commits (1) - [`917e58b`](https://github.com/horizon-rust/horizon/commit/917e58b2da171fc2aadacdbf7d172a2aa37fd814) Native mods: a refused sticky pull sends clients the blocks, not the retraction ### 📊 Changes **3 files changed** (+48 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/native_hooks.rs` (+3 -1) 📝 `crates/horizon-world/src/level/pistons.rs` (+14 -8) 📝 `crates/horizon-world/src/level/tests.rs` (+31 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Follow-up to #4739, from Dyna's review there (https://github.com/horizon-rust/horizon/pull/4739#issuecomment-6535399465). #4739 merged before this fix was pushed. ## What When a native mod refuses a sticky piston's pull (`native_piston_move`), the server kept the block. It still broadcast the retraction's block event, though. Clients aren't asked whether a piston may move, so they replayed the event and pulled the block anyway, until the chunk reloaded. - `piston_move_blocks` returns `Option<bool>`: None when the level refused the move, `Some(false)` when the structure can't move (as before), `Some(true)` when it moved. - `piston_trigger_event` returns false for a retraction whose pull was refused, so it isn't broadcast, as a failed push isn't. Clients get the server's block changes instead: the piston and its head retract, and the block stays. - Without a mod nothing is refused, so vanilla's path is unchanged. ## Tests - `refused_sticky_pull_keeps_the_block_and_sends_no_event`: no `BlockEntityEvent` for the piston, and the dirt is kept. Fails without the fix (the event is emitted). - All piston tests of horizon-world pass (25 with the `refused_` ones). - `python3 tools/parity.py piston_movement piston_push piston_shape`: 3 passed. - `cargo clippy -p horizon-world --all-targets -D warnings` and `cargo fmt --check` are clean. pr_ready (full) follows in a comment: a load benchmark is running on this machine. 🤖 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:15:20 +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#5838
No description provided.