[PR #931] [MERGED] Server: tick blocks around every player, from vanilla's chunk tickets (#890) #2921

Closed
opened 2026-11-02 16:00:08 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/server-block-ticks-no-player


📝 Commits (1)

  • a0bcc13 Tick blocks around every player, from vanilla's chunk tickets (#890)

📊 Changes

13 files changed (+431 additions, -66 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+68 -11)
📝 crates/horizon-client/src/game/block_entity_ticks.rs (+5 -20)
📝 crates/horizon-client/src/game/creatures.rs (+4 -17)
📝 crates/horizon-client/src/game/levels.rs (+5 -1)
📝 crates/horizon-client/src/game/persist.rs (+4 -4)
📝 crates/horizon-client/src/game/sculk.rs (+3 -11)
📝 crates/horizon-client/src/game/sculk_fixture.rs (+2 -0)
📝 crates/horizon-client/src/lan/hub.rs (+6 -0)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/tick_chunk_membership.rs (+45 -0)
➕ crates/horizon-client/src/ticket_levels.rs (+232 -0)
📝 tools/lan_e2e.py (+46 -2)
📝 tools/test_dedicated_server_parity.py (+10 -0)

📄 Description

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

Fixes #890.

The problem

tick_blocks returned early without a local player and otherwise ticked a square of render_distance.min(8) around the local player. A dedicated server or a host on --server-thread ran no scheduled ticks and no random ticks: crops didn't grow, water didn't flow, redstone, pistons and pressure plates stood still. A LAN host ticked only around itself, never around a guest who had walked away.

What vanilla does

DistanceManager keeps two ticket levels per chunk:

  • PLAYER_LOADING at level 31 (entity ticking) on every chunk within the server's view distance (Chebyshev) of every player;
  • PLAYER_SIMULATION at 31 - simulationDistance on the player's own chunk;
  • /forceload: FORCED at 31 of both kinds.

Levels rise by one per chunk away from a ticket, and each chunk takes the lowest. From the two levels:

  • entities tick where both are entity ticking (31 or less);
  • random ticks run in the simulation tracker's entity-ticking chunks that have a ticking chunk (forEachBlockTickingChunk);
  • scheduled ticks, block events and block entities run where both levels are block ticking (32 or less): isPositionTickingWithEntitiesLoaded, shouldTickBlocksAt, LevelChunk.isTicking.

Players count the same whoever they are. A chunk's saved ticks are unpacked when the chunk starts ticking (startTickingChunk, after its neighbours are loaded and lit), not when it loads.

What this ports

  • ticket_levels.rs (new) computes both levels from every player in the level (the local player, every LAN guest in it, a server's players) and the forced chunks. It is rebuilt only when a player changes chunk or a distance or forced chunk changes. A game with no server and no player (the headless fixtures) still ticks everywhere.
  • tick_blocks uses it for random ticks, and is_ticking_chunk (scheduled ticks, block events, pistons, sculk) for the rest. entity_ticking_area, block_ticking_area and the sculk chunk test use the same levels. The early return and the min(8) square are gone.
  • Saved ticks wait in TickChunkMembership until the chunk is block ticking with its 3×3 present and lit. They then unpack at the game time between ticks, as startTickingChunk does.
  • lan/hub.rs: the hub now keeps its tick-rate state current while nobody is in the game. Before, a player joining a server that was frozen while empty was sent ticking_state twice. Freezing the dedicated parity harness exposed this.
  • test_dedicated_server_parity.py: the server is frozen (tick freeze) while the client joins and gets its chunks, and unfrozen once it has them. The harness was flaky on main too: one world had saved water and lava ticks that each server ran before or after sending the chunk, depending on how fast it loaded. Freezing makes both sides send the chunks in the same state.
  • lan_e2e.py: a new growth check. The guest goes 1000 blocks from the host and builds a platform there. Water placed on it must flow (into any of its four neighbours, since vanilla only spreads toward the nearest drop), and wheat must reach age 7 at noon.

Proof

Commits tested. The PR head a0bcc13f is 7e83630b rebased over #887; the only difference is growth appended to the CHECKS list. Clippy for horizon-client was rerun on a0bcc13f and is clean.

Check Result
cargo clippy --workspace --all-targets -D warnings clean (7e83630b)
cargo test -p horizon-client (lib, bins, integration tests) all ok, lib 886 passed (7e83630b)
parity.py --changed origin/main on the pre-rebase commit ffa98487 95 passed, 0 failed
Rerun on 7e83630b: dedicated_server tick random_tick fluid fluid_flow redstone piston_movement block_entity_tickers chorus_plant 9 passed
lan_e2e --check plates --check growth --check time (7e83630b) all PASS
lan_e2e --server-thread --check plates --check growth --check time (7e83630b) all PASS
lan_e2e --check growth on main FAIL: the water flowed, but the wheat stayed at age 0 (random ticks run only around the host)

dedicated_server matches vanilla byte for byte (591 transcript lines identical). The parity run covers the block-tick, fluid, redstone, piston and crop harnesses, among others.

Dedicated-server check. This is an ad hoc script, not in the repo. It starts horizon-client --dedicated --nogui with view and simulation distance 6 and pause-when-empty-seconds=-1, and lets one idle horizon-bot join. It then builds the same platform 20 blocks above the bot from the console: water, and wheat on moist farmland, with random_tick_speed 1000. After 30 s it tests the blocks with execute if block.

Build Water flowed Wheat grew
main (51c49e11) no no
this branch yes yes

MSPT

tools/server_bench.py --servers horizon --bots 10 --behaviour walk --warmup 30 --seconds 120, on the Mac mini. The machine is shared with other sessions, so main and the branch ran interleaved, twice each.

Server MSPT avg P95 P99 CPU % RSS MB
main 51c49e11, run 1 1.40 3.28 11.71 8.1 848
main, run 2 1.80 5.59 21.50 7.7 887
this branch, run 1 14.59 52.18 92.60 13.4 910
this branch, run 2 13.14 47.74 100.66 13.0 593
vanilla 26.3 (same run, for scale) 40.07 145.61 254.40 58.5 3376

Main did no block work at all on a dedicated server, so the before figure is a server that never ticks a block. The branch now ticks blocks around 10 players (view and simulation distance 10, spawn terrain with water and lava). That costs about 12 ms per tick on average. It is still about a third of vanilla's MSPT on the same load. The tail, a P95 near 50 ms, is worth profiling as a follow-up (random ticks and fluid ticks in tick_blocks). The machine was heavily loaded by other sessions (load average about 150), so the absolute numbers are noisy; the before/after runs were interleaved.

Found, not fixed here

Other parts of the world tick that still depend on the local player:

  • spawn_natural (game/natural_spawning.rs) returns without a local player. A dedicated or --server-thread server spawns no mobs naturally, and a LAN host spawns them only around itself.
  • tick_inhabited (game/creatures.rs) adds inhabited time only around the local player.
  • tick_wandering_trader needs a local player.
  • End-portal entry in tick_end handles only the local player.
  • tick_thunder (game/lightning.rs) walks every loaded chunk with no ticking check (vanilla strikes only in the chunks that random-tick).
  • Several entity ticks (paintings, item frames, boats, falling blocks, TNT…) have no ticking-area check.
  • Not modelled yet:
    • vanilla's ticket throttle (4 chunks in flight, closest first);
    • the configuration-phase PLAYER_SPAWN ticket. Here the whole view area is ticketed at once.

Weather already ticks without a player.

Coordination

  • Touches lan/hub.rs (a few lines in tick_level) and tools/test_dedicated_server_parity.py. It does not touch chunk encoding (perf-server-10) or the server benchmark/release (server-host-8).
  • lan_e2e.py: growth is appended to CHECKS, after every existing entry.

🤖 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/931 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/18/2026 **Status:** ✅ Merged **Merged:** 10/18/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/server-block-ticks-no-player` --- ### 📝 Commits (1) - [`a0bcc13`](https://github.com/horizon-rust/horizon/commit/a0bcc13f1c046f845b81c95bc7bfcc3903b6e7ff) Tick blocks around every player, from vanilla's chunk tickets (#890) ### 📊 Changes **13 files changed** (+431 additions, -66 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+68 -11) 📝 `crates/horizon-client/src/game/block_entity_ticks.rs` (+5 -20) 📝 `crates/horizon-client/src/game/creatures.rs` (+4 -17) 📝 `crates/horizon-client/src/game/levels.rs` (+5 -1) 📝 `crates/horizon-client/src/game/persist.rs` (+4 -4) 📝 `crates/horizon-client/src/game/sculk.rs` (+3 -11) 📝 `crates/horizon-client/src/game/sculk_fixture.rs` (+2 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+6 -0) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/tick_chunk_membership.rs` (+45 -0) ➕ `crates/horizon-client/src/ticket_levels.rs` (+232 -0) 📝 `tools/lan_e2e.py` (+46 -2) 📝 `tools/test_dedicated_server_parity.py` (+10 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #890. ## The problem `tick_blocks` returned early without a local player and otherwise ticked a square of `render_distance.min(8)` around the local player. A dedicated server or a host on `--server-thread` ran no scheduled ticks and no random ticks: crops didn't grow, water didn't flow, redstone, pistons and pressure plates stood still. A LAN host ticked only around itself, never around a guest who had walked away. ## What vanilla does `DistanceManager` keeps two ticket levels per chunk: - `PLAYER_LOADING` at level 31 (entity ticking) on every chunk within the server's view distance (Chebyshev) of every player; - `PLAYER_SIMULATION` at `31 - simulationDistance` on the player's own chunk; - `/forceload`: `FORCED` at 31 of both kinds. Levels rise by one per chunk away from a ticket, and each chunk takes the lowest. From the two levels: - **entities** tick where both are entity ticking (31 or less); - **random ticks** run in the simulation tracker's entity-ticking chunks that have a ticking chunk (`forEachBlockTickingChunk`); - **scheduled ticks, block events and block entities** run where both levels are block ticking (32 or less): `isPositionTickingWithEntitiesLoaded`, `shouldTickBlocksAt`, `LevelChunk.isTicking`. Players count the same whoever they are. A chunk's saved ticks are unpacked when the chunk starts ticking (`startTickingChunk`, after its neighbours are loaded and lit), not when it loads. ## What this ports - `ticket_levels.rs` (new) computes both levels from every player in the level (the local player, every LAN guest in it, a server's players) and the forced chunks. It is rebuilt only when a player changes chunk or a distance or forced chunk changes. A game with no server and no player (the headless fixtures) still ticks everywhere. - `tick_blocks` uses it for random ticks, and `is_ticking_chunk` (scheduled ticks, block events, pistons, sculk) for the rest. `entity_ticking_area`, `block_ticking_area` and the sculk chunk test use the same levels. The early return and the `min(8)` square are gone. - Saved ticks wait in `TickChunkMembership` until the chunk is block ticking with its 3×3 present and lit. They then unpack at the game time between ticks, as `startTickingChunk` does. - `lan/hub.rs`: the hub now keeps its tick-rate state current while nobody is in the game. Before, a player joining a server that was frozen while empty was sent `ticking_state` twice. Freezing the dedicated parity harness exposed this. - `test_dedicated_server_parity.py`: the server is frozen (`tick freeze`) while the client joins and gets its chunks, and unfrozen once it has them. The harness was flaky on **main** too: one world had saved water and lava ticks that each server ran before or after sending the chunk, depending on how fast it loaded. Freezing makes both sides send the chunks in the same state. - `lan_e2e.py`: a new `growth` check. The guest goes 1000 blocks from the host and builds a platform there. Water placed on it must flow (into any of its four neighbours, since vanilla only spreads toward the nearest drop), and wheat must reach age 7 at noon. ## Proof **Commits tested.** The PR head `a0bcc13f` is `7e83630b` rebased over #887; the only difference is `growth` appended to the `CHECKS` list. Clippy for `horizon-client` was rerun on `a0bcc13f` and is clean. | Check | Result | | --- | --- | | `cargo clippy --workspace --all-targets -D warnings` | clean (`7e83630b`) | | `cargo test -p horizon-client` (lib, bins, integration tests) | all ok, lib 886 passed (`7e83630b`) | | `parity.py --changed origin/main` on the pre-rebase commit `ffa98487` | 95 passed, 0 failed | | Rerun on `7e83630b`: `dedicated_server tick random_tick fluid fluid_flow redstone piston_movement block_entity_tickers chorus_plant` | 9 passed | | `lan_e2e --check plates --check growth --check time` (`7e83630b`) | all PASS | | `lan_e2e --server-thread --check plates --check growth --check time` (`7e83630b`) | all PASS | | `lan_e2e --check growth` on main | FAIL: the water flowed, but the wheat stayed at age 0 (random ticks run only around the host) | `dedicated_server` matches vanilla byte for byte (591 transcript lines identical). The parity run covers the block-tick, fluid, redstone, piston and crop harnesses, among others. **Dedicated-server check.** This is an ad hoc script, not in the repo. It starts `horizon-client --dedicated --nogui` with view and simulation distance 6 and `pause-when-empty-seconds=-1`, and lets one idle `horizon-bot` join. It then builds the same platform 20 blocks above the bot from the console: water, and wheat on moist farmland, with `random_tick_speed 1000`. After 30 s it tests the blocks with `execute if block`. | Build | Water flowed | Wheat grew | | --- | --- | --- | | main (`51c49e11`) | no | no | | this branch | yes | yes | ## MSPT `tools/server_bench.py --servers horizon --bots 10 --behaviour walk --warmup 30 --seconds 120`, on the Mac mini. The machine is shared with other sessions, so main and the branch ran interleaved, twice each. | Server | MSPT avg | P95 | P99 | CPU % | RSS MB | | --- | --- | --- | --- | --- | --- | | main `51c49e11`, run 1 | 1.40 | 3.28 | 11.71 | 8.1 | 848 | | main, run 2 | 1.80 | 5.59 | 21.50 | 7.7 | 887 | | this branch, run 1 | 14.59 | 52.18 | 92.60 | 13.4 | 910 | | this branch, run 2 | 13.14 | 47.74 | 100.66 | 13.0 | 593 | | vanilla 26.3 (same run, for scale) | 40.07 | 145.61 | 254.40 | 58.5 | 3376 | Main did no block work at all on a dedicated server, so the before figure is a server that never ticks a block. The branch now ticks blocks around 10 players (view and simulation distance 10, spawn terrain with water and lava). That costs about 12 ms per tick on average. It is still about a third of vanilla's MSPT on the same load. The tail, a P95 near 50 ms, is worth profiling as a follow-up (random ticks and fluid ticks in `tick_blocks`). The machine was heavily loaded by other sessions (load average about 150), so the absolute numbers are noisy; the before/after runs were interleaved. ## Found, not fixed here Other parts of the world tick that still depend on the local player: - `spawn_natural` (`game/natural_spawning.rs`) returns without a local player. A dedicated or `--server-thread` server spawns no mobs naturally, and a LAN host spawns them only around itself. - `tick_inhabited` (`game/creatures.rs`) adds inhabited time only around the local player. - `tick_wandering_trader` needs a local player. - End-portal entry in `tick_end` handles only the local player. - `tick_thunder` (`game/lightning.rs`) walks every loaded chunk with no ticking check (vanilla strikes only in the chunks that random-tick). - Several entity ticks (paintings, item frames, boats, falling blocks, TNT…) have no ticking-area check. - Not modelled yet: - vanilla's ticket throttle (4 chunks in flight, closest first); - the configuration-phase `PLAYER_SPAWN` ticket. Here the whole view area is ticketed at once. Weather already ticks without a player. ## Coordination - Touches `lan/hub.rs` (a few lines in `tick_level`) and `tools/test_dedicated_server_parity.py`. It does not touch chunk encoding (perf-server-10) or the server benchmark/release (server-host-8). - `lan_e2e.py`: `growth` is appended to `CHECKS`, after every existing entry. 🤖 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-02 16:00:08 +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#2921
No description provided.