[PR #7008] [MERGED] Autosave counts down from max(100, tick rate * 300) ticks #7269

Closed
opened 2026-11-03 06:36:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7008
Author: @MSedgeMC
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/autosave-interval


📝 Commits (1)

  • 8bd75ba Autosave counts down from max(100, tick rate * 300) ticks

📊 Changes

3 files changed (+57 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+52 -1)
📝 crates/horizon-client/src/game/commands/misc.rs (+3 -0)
📝 tools/port_map/rest-013.tsv (+2 -2)

📄 Description

MinecraftServer.computeNextAutosaveInterval asks for Math.max(100, (int)(rate * 300.0F)) ticks - the tick rate, or while /tick sprint runs the measured NANOSECONDS_PER_SECOND / (averageTickTimeNanos + 1) - tickServer counts ticksUntilAutosave down a tick at a time and saves when it reaches zero, and onTickRateChanged shortens a wait that is already running.

Horizon saved on every six-thousandth tick whatever the rate was (self.autosaving = self.ticks.is_multiple_of(6000)), so /tick rate and /tick sprint changed how much world time passed between saves and a slowed server kept the same interval; Game now keeps ticks_until_autosave, counts it down, resets it from next_autosave_interval() (vanilla's formula, using FixedStep::average_nanos, which is getAverageTickTimeNanos, while a sprint runs) and /tick rate calls on_tick_rate_changed. At the default 20 ticks a second the interval is still 6000, so a normal world saves exactly as it did.

The two rest-013 rows this corrects are in the same PR: MinecraftServer.computeNextAutosaveInterval and MinecraftServer.onTickRateChanged now say port and name those two functions.

Proven: rustfmt --edition 2024 --check on both files; the arithmetic and the countdown order are read off MinecraftServer.computeNextAutosaveInterval/tickServer/onTickRateChanged in the extracted 26.3 jar (javap), and misc.rs's /tick rate now calls the hook next to clock.set_rate. GitHub CI runs clippy and the whole test suite; the build VM that gives a local pre-flight was cooling down when this was opened.

Not proven: no local cargo test -p horizon-client --lib autosave or cargo clippy -p horizon-client --lib -- -D warnings yet, and tools/port_ledger.py map-check tools/port_map/rest-013.tsv has not been run for the same reason - they will be run and reported as a comment when the VM is back. No in-game check: the autosave is 300 s of ticks apart, so nothing was watched save.


🔄 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/7008 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/autosave-interval` --- ### 📝 Commits (1) - [`8bd75ba`](https://github.com/horizon-rust/horizon/commit/8bd75ba4ddfb648c10e488581b280f7a2d06cf19) Autosave counts down from max(100, tick rate * 300) ticks ### 📊 Changes **3 files changed** (+57 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+52 -1) 📝 `crates/horizon-client/src/game/commands/misc.rs` (+3 -0) 📝 `tools/port_map/rest-013.tsv` (+2 -2) </details> ### 📄 Description `MinecraftServer.computeNextAutosaveInterval` asks for `Math.max(100, (int)(rate * 300.0F))` ticks - the tick rate, or while `/tick sprint` runs the measured `NANOSECONDS_PER_SECOND / (averageTickTimeNanos + 1)` - `tickServer` counts `ticksUntilAutosave` down a tick at a time and saves when it reaches zero, and `onTickRateChanged` shortens a wait that is already running. Horizon saved on every six-thousandth tick whatever the rate was (`self.autosaving = self.ticks.is_multiple_of(6000)`), so `/tick rate` and `/tick sprint` changed how much world time passed between saves and a slowed server kept the same interval; `Game` now keeps `ticks_until_autosave`, counts it down, resets it from `next_autosave_interval()` (vanilla's formula, using `FixedStep::average_nanos`, which is `getAverageTickTimeNanos`, while a sprint runs) and `/tick rate` calls `on_tick_rate_changed`. At the default 20 ticks a second the interval is still 6000, so a normal world saves exactly as it did. The two `rest-013` rows this corrects are in the same PR: `MinecraftServer.computeNextAutosaveInterval` and `MinecraftServer.onTickRateChanged` now say `port` and name those two functions. **Proven:** `rustfmt --edition 2024 --check` on both files; the arithmetic and the countdown order are read off `MinecraftServer.computeNextAutosaveInterval`/`tickServer`/`onTickRateChanged` in the extracted 26.3 jar (`javap`), and `misc.rs`'s `/tick rate` now calls the hook next to `clock.set_rate`. GitHub CI runs clippy and the whole test suite; the build VM that gives a local pre-flight was cooling down when this was opened. **Not proven:** no local `cargo test -p horizon-client --lib autosave` or `cargo clippy -p horizon-client --lib -- -D warnings` yet, and `tools/port_ledger.py map-check tools/port_map/rest-013.tsv` has not been run for the same reason - they will be run and reported as a comment when the VM is back. No in-game check: the autosave is 300 s of ticks apart, so nothing was watched save. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:36:48 +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#7269
No description provided.