[PR #1088] [MERGED] /tick on a server thread: sprint, query, step and a smooth frozen camera #3038

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

📋 Pull Request Information

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

Base: main ← Head: fix/tick-server-thread


📝 Commits (1)

  • be8b2d5 /tick on a server thread: sprint, query, step and a smooth frozen camera

📊 Changes

11 files changed (+122 additions, -29 deletions)

View changed files

📝 crates/horizon-client/examples/lan_flat.rs (+1 -0)
📝 crates/horizon-client/src/clock.rs (+47 -3)
📝 crates/horizon-client/src/game.rs (+12 -7)
📝 crates/horizon-client/src/game/dedicated.rs (+1 -8)
📝 crates/horizon-client/src/game/integrated.rs (+5 -9)
📝 crates/horizon-client/src/game/lan.rs (+2 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+1 -0)
📝 crates/horizon-client/src/game/levels.rs (+34 -1)
📝 crates/horizon-client/src/game/server_travel.rs (+1 -0)
📝 crates/horizon-client/src/lan/hub.rs (+17 -1)
📝 crates/horizon-client/tests/lan_bot.rs (+1 -0)

📄 Description

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

What and why

rdbtCVS reported (#1038) that /tick misbehaves with --server-thread: freeze and unfreeze work but movement gets jittery, and query, rate, sprint and step are broken. Running each subcommand against main confirmed four causes:

  1. Sprint. The integrated and dedicated loops waited one tick length after every tick, so /tick sprint ran at 20 tps and its report never came. Both loops now end with one helper that follows MinecraftServer.runServer: no wait while sprinting (checkShouldSprintThisTick). When the sprint ends, its report goes to the operators as the server's (finishTickSprint: createCommandSourceStack().sendSuccess(..., true)), which shows as [Server: Sprint completed with …].
  2. Query. The integrated server never recorded tick times (MinecraftServer.tickServer's tickTimesNanos), so /tick query printed 0.0 ms everywhere. It now records them. The dedicated server already did.
  3. Step. Nothing sent ClientboundTickingStepPacket, and a joining player was always sent 0. The hub now broadcasts it whenever a step starts or stops (ServerTickRateManager.updateStepTicks), and a joining player gets the steps left (updateJoiningPlayer). This applies to LAN guests too. FixedStep::step_state counts the starts and stops; the hub compares that count, as it already does for TickingState.
  4. Jitter while frozen. The camera, the hand, the view bobbing and the player's own model all used getGameTimeDeltaPartialTick(false), which is pinned to 1.0 in a frozen level, so the view moved in 20 Hz steps. Vanilla's Camera.getCameraEntityPartialTicks uses getGameTimeDeltaPartialTick(true) for an entity that isn't frozen, and players never are. The new FixedStep::camera_fraction follows it. World effects (sky, weather, other entities) keep the frozen value, as in GameRenderer.extract. This also fixes the in-frame world.

Proof

A horizon-ctl script on the Mac mini (offscreen, --profile fast) runs /tick query, rate 40, query, rate 20, freeze (client day_time over 2 s), step 20, unfreeze, sprint 400 (time until the report), query:

main, --server-thread this branch, --server-thread this branch, in-frame
/tick query Average time per tick: 0.0ms, P50: 0.0ms P95: 0.0ms P99: 0.0ms 2.7ms, P95: 1.8ms P99: 11.4ms 1.4ms, P95: 3.1ms P99: 18.8ms (unchanged)
/tick sprint 400 still running after 30 s, no report 1.0 s, [Server: Sprint completed with 496 ticks per second, or 2.01 ms per tick] 0.7 s, report (unchanged)
freeze, 2 s day_time 665 → 665 119 → 119 1372 → 1372
step 20 665 → 685 (set by the server's time packets) 119 → 139, and the window's level now runs those 20 ticks too 1372 → 1392

New unit tests: the_camera_keeps_interpolating_in_a_frozen_level, only_a_started_or_stopped_step_is_broadcast.

Self-check

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at d128289ca, 5 min 30 s)

Check Result
Scope ✅ 11 files, +122 −29
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (4 s)
clippy ✅ (1 min 23 s)
tests: horizon-client ✅ 1053 passed (4 min 0 s)
doc tests ✅ 0 passed (1 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 320 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 308 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Parity: the 320 affected harnesses run in CI's parity job. Locally they will run once on an integration commit with this batch's other PRs.

Not changed

In the in-frame world, the sprint report is still the player's own feedback and lacks the [Server: …] wrapper. It's listed in FEATURES.md's LATER.

Reported by rdbtCVS.

Fixes #1038

🤖 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/1088 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/21/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/tick-server-thread` --- ### 📝 Commits (1) - [`be8b2d5`](https://github.com/horizon-rust/horizon/commit/be8b2d54fc303ab1b58b2b5525fcb8100d45a838) /tick on a server thread: sprint, query, step and a smooth frozen camera ### 📊 Changes **11 files changed** (+122 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/lan_flat.rs` (+1 -0) 📝 `crates/horizon-client/src/clock.rs` (+47 -3) 📝 `crates/horizon-client/src/game.rs` (+12 -7) 📝 `crates/horizon-client/src/game/dedicated.rs` (+1 -8) 📝 `crates/horizon-client/src/game/integrated.rs` (+5 -9) 📝 `crates/horizon-client/src/game/lan.rs` (+2 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+1 -0) 📝 `crates/horizon-client/src/game/levels.rs` (+34 -1) 📝 `crates/horizon-client/src/game/server_travel.rs` (+1 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+17 -1) 📝 `crates/horizon-client/tests/lan_bot.rs` (+1 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What and why rdbtCVS reported (#1038) that `/tick` misbehaves with `--server-thread`: freeze and unfreeze work but movement gets jittery, and query, rate, sprint and step are broken. Running each subcommand against main confirmed four causes: 1. **Sprint.** The integrated and dedicated loops waited one tick length after every tick, so `/tick sprint` ran at 20 tps and its report never came. Both loops now end with one helper that follows `MinecraftServer.runServer`: no wait while sprinting (`checkShouldSprintThisTick`). When the sprint ends, its report goes to the operators as the server's (`finishTickSprint`: `createCommandSourceStack().sendSuccess(..., true)`), which shows as `[Server: Sprint completed with …]`. 2. **Query.** The integrated server never recorded tick times (`MinecraftServer.tickServer`'s `tickTimesNanos`), so `/tick query` printed 0.0 ms everywhere. It now records them. The dedicated server already did. 3. **Step.** Nothing sent `ClientboundTickingStepPacket`, and a joining player was always sent 0. The hub now broadcasts it whenever a step starts or stops (`ServerTickRateManager.updateStepTicks`), and a joining player gets the steps left (`updateJoiningPlayer`). This applies to LAN guests too. `FixedStep::step_state` counts the starts and stops; the hub compares that count, as it already does for `TickingState`. 4. **Jitter while frozen.** The camera, the hand, the view bobbing and the player's own model all used `getGameTimeDeltaPartialTick(false)`, which is pinned to 1.0 in a frozen level, so the view moved in 20 Hz steps. Vanilla's `Camera.getCameraEntityPartialTicks` uses `getGameTimeDeltaPartialTick(true)` for an entity that isn't frozen, and players never are. The new `FixedStep::camera_fraction` follows it. World effects (sky, weather, other entities) keep the frozen value, as in `GameRenderer.extract`. This also fixes the in-frame world. ## Proof A `horizon-ctl` script on the Mac mini (offscreen, `--profile fast`) runs `/tick query`, `rate 40`, `query`, `rate 20`, `freeze` (client `day_time` over 2 s), `step 20`, `unfreeze`, `sprint 400` (time until the report), `query`: | | main, `--server-thread` | this branch, `--server-thread` | this branch, in-frame | | --- | --- | --- | --- | | `/tick query` | `Average time per tick: 0.0ms`, `P50: 0.0ms P95: 0.0ms P99: 0.0ms` | `2.7ms`, `P95: 1.8ms P99: 11.4ms` | `1.4ms`, `P95: 3.1ms P99: 18.8ms` (unchanged) | | `/tick sprint 400` | still running after 30 s, no report | 1.0 s, `[Server: Sprint completed with 496 ticks per second, or 2.01 ms per tick]` | 0.7 s, report (unchanged) | | freeze, 2 s | `day_time` 665 → 665 | 119 → 119 | 1372 → 1372 | | `step 20` | 665 → 685 (set by the server's time packets) | 119 → 139, and the window's level now runs those 20 ticks too | 1372 → 1392 | New unit tests: `the_camera_keeps_interpolating_in_a_frozen_level`, `only_a_started_or_stopped_step_is_broadcast`. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at d128289ca, 5 min 30 s) | Check | Result | | --- | --- | | Scope | ✅ 11 files, +122 −29 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (4 s) | | clippy | ✅ (1 min 23 s) | | tests: horizon-client | ✅ 1053 passed (4 min 0 s) | | doc tests | ✅ 0 passed (1 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 320 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 308 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Parity: the 320 affected harnesses run in CI's parity job. Locally they will run once on an integration commit with this batch's other PRs. ## Not changed In the in-frame world, the sprint report is still the player's own feedback and lacks the `[Server: …]` wrapper. It's listed in FEATURES.md's LATER. Reported by rdbtCVS. Fixes #1038 🤖 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:59 +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#3038
No description provided.