[PR #2206] [MERGED] Pistons animate their moves on the clients, as Java's do #4104

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2206
Author: @socksprox
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: fix/piston-moving-block-anim


📝 Commits (2)

  • 48811b1 Pistons animate their moves on the clients, as Java's do
  • 2394d6e Pistons: a client's replay starts no piston and plays no sound

📊 Changes

6 files changed (+322 additions, -40 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+17 -1)
📝 crates/horizon-client/src/game/lan.rs (+30 -11)
📝 crates/horizon-client/src/game/remote.rs (+29 -12)
📝 crates/horizon-world/src/level/mod.rs (+5 -0)
📝 crates/horizon-world/src/level/pistons.rs (+141 -16)
📝 crates/horizon-world/src/level/tests.rs (+100 -0)

📄 Description

🤖 Opened by socksprox's AI agent (Devin), not by socksprox personally.

What and why

Fixes #1704. A remote client — single player's window on its server thread, a LAN guest, a dedicated server's client — never ran the client side of a piston's move. The ClientboundBlockEventPacket reached block_entity_event, which has no piston ticker, so moving_piston blocks arrived without a moving block entity and pushed blocks teleported instead of interpolating to their target.

Vanilla's ServerLevel.runBlockEvents broadcasts a handled event to the clients, whose own level re-runs triggerEvent (PistonBaseBlock.moveBlocks) to build the PistonMovingBlockEntity it then ticks and renders interpolated. This does the same:

  • run_block_events emits a BlockEntityEvent when triggerEvent accepts the event; the LAN host, integrated server and dedicated server send it as ClientboundBlockEventPacket — before the tick's block changes, as vanilla's broadcast precedes ChunkHolder.broadcastChanges, so the client still has the pre-move states.
  • The remote client re-runs triggerEvent for pistons, note blocks and bells on its own level (Behaviours::client_block_event) and ticks the resulting moving pistons each client tick (Behaviours::client_tick_block_entities), so they animate and collide between the server's states. dropResources stays server-side (popResource checks !isClientSide), and block events a client-side move queues run right away, as ClientLevel.blockEvent does.
  • Note blocks and bell rings reach guests through the same packet, which they did not get before.

Still missing, and untouched here: entities pushed by a moving piston (PistonMovingBlockEntity.moveCollidedEntities, #1496) and slime-block/player interaction (#1609).

Vanilla reference

ServerLevel.blockEvent/runBlockEvents/doBlockEvent, ClientLevel.blockEvent/tickBlockEntities, PistonBaseBlock.triggerEvent/moveBlocks, PistonMovingBlockEntity.tick, ClientboundBlockEventPacket. The in-frame path already had this through tick_block_entities + sync_moving_pistons; the server-thread/LAN/dedicated paths now use the same moving-piston state.

Self-check

**pr_ready** (`tools/pr_ready.py --quick` on MacBookPro, against origin/main at b78daab11, 3 min 24 s)

| Check | Result |
| --- | --- |
| Scope | ✅ 6 files, +274 −39 |
| Cargo.lock | ✅ unchanged |
| Public tree | ✅ |
| Python tests | ➖ no Python change |
| rustfmt | ✅ (re-run pending) |
| clippy | ✅ (45 s) |
| tests: horizon-client, horizon-world | ✅ 1547 passed (2 min 30 s) |
| doc tests | ✅ 0 passed (4 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) |

Two new level tests cover the emitted broadcast event and the client-side replay (client_block_event builds the moving pistons, client_tick_block_entities walks them to the placed block). No .local data on this machine, so the parity harnesses are for CI.

🤖 Generated with Devin


🔄 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/2206 **Author:** [@socksprox](https://github.com/socksprox) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/piston-moving-block-anim` --- ### 📝 Commits (2) - [`48811b1`](https://github.com/horizon-rust/horizon/commit/48811b12f1fc3146e74b7b45f01e6e92ae3a5ab2) Pistons animate their moves on the clients, as Java's do - [`2394d6e`](https://github.com/horizon-rust/horizon/commit/2394d6e7dc1ee0bcbf59c94fa9a37e7f3bf910f9) Pistons: a client's replay starts no piston and plays no sound ### 📊 Changes **6 files changed** (+322 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+17 -1) 📝 `crates/horizon-client/src/game/lan.rs` (+30 -11) 📝 `crates/horizon-client/src/game/remote.rs` (+29 -12) 📝 `crates/horizon-world/src/level/mod.rs` (+5 -0) 📝 `crates/horizon-world/src/level/pistons.rs` (+141 -16) 📝 `crates/horizon-world/src/level/tests.rs` (+100 -0) </details> ### 📄 Description > 🤖 Opened by socksprox's AI agent (Devin), not by socksprox personally. ## What and why Fixes #1704. A remote client — single player's window on its server thread, a LAN guest, a dedicated server's client — never ran the client side of a piston's move. The `ClientboundBlockEventPacket` reached `block_entity_event`, which has no piston ticker, so `moving_piston` blocks arrived without a moving block entity and pushed blocks teleported instead of interpolating to their target. Vanilla's `ServerLevel.runBlockEvents` broadcasts a handled event to the clients, whose own level re-runs `triggerEvent` (`PistonBaseBlock.moveBlocks`) to build the `PistonMovingBlockEntity` it then ticks and renders interpolated. This does the same: - `run_block_events` emits a `BlockEntityEvent` when `triggerEvent` accepts the event; the LAN host, integrated server and dedicated server send it as `ClientboundBlockEventPacket` — before the tick's block changes, as vanilla's broadcast precedes `ChunkHolder.broadcastChanges`, so the client still has the pre-move states. - The remote client re-runs `triggerEvent` for pistons, note blocks and bells on its own level (`Behaviours::client_block_event`) and ticks the resulting moving pistons each client tick (`Behaviours::client_tick_block_entities`), so they animate and collide between the server's states. `dropResources` stays server-side (`popResource` checks `!isClientSide`), and block events a client-side move queues run right away, as `ClientLevel.blockEvent` does. - Note blocks and bell rings reach guests through the same packet, which they did not get before. Still missing, and untouched here: entities pushed by a moving piston (`PistonMovingBlockEntity.moveCollidedEntities`, #1496) and slime-block/player interaction (#1609). ## Vanilla reference `ServerLevel.blockEvent`/`runBlockEvents`/`doBlockEvent`, `ClientLevel.blockEvent`/`tickBlockEntities`, `PistonBaseBlock.triggerEvent`/`moveBlocks`, `PistonMovingBlockEntity.tick`, `ClientboundBlockEventPacket`. The in-frame path already had this through `tick_block_entities` + `sync_moving_pistons`; the server-thread/LAN/dedicated paths now use the same moving-piston state. ## Self-check ``` **pr_ready** (`tools/pr_ready.py --quick` on MacBookPro, against origin/main at b78daab11, 3 min 24 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +274 −39 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (re-run pending) | | clippy | ✅ (45 s) | | tests: horizon-client, horizon-world | ✅ 1547 passed (2 min 30 s) | | doc tests | ✅ 0 passed (4 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) | ``` Two new level tests cover the emitted broadcast event and the client-side replay (`client_block_event` builds the moving pistons, `client_tick_block_entities` walks them to the placed block). No `.local` data on this machine, so the parity harnesses are for CI. 🤖 Generated with [Devin](https://devin.ai) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:14:42 +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#4104
No description provided.