[PR #2572] [MERGED] Save and load the difficulty through level.dat's difficulty_settings #4436

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

📋 Pull Request Information

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

Base: main ← Head: fix/2571-difficulty-persist


📝 Commits (1)

  • a934dac Save and load the difficulty through level.dat's difficulty_settings

📊 Changes

2 files changed (+11 additions, -35 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+3 -0)
📝 crates/horizon-client/src/game/chat.rs (+8 -35)

📄 Description

What and why

The difficulty was never saved. The game read and patched the old Data.Difficulty key of level.dat, but Level::write removes that key and stores the difficulty under difficulty_settings.difficulty, from a value that only the Create World screen set. So /difficulty hard (or the options button) was lost on quit, and loading a world always fell back to Normal, including worlds that came with their own difficulty.

Now the live difficulty is copied into the level data before it is written (sync_level), and when a world opens the difficulty is read from the loaded difficulty_settings. The old read/patch helpers for the dead key are removed. Single player on the server thread uses the same load and save path, and the client gets the loaded value in the difficulty packet it already receives.

Fixes #2571.

Vanilla reference

  • PrimaryLevelData.getDifficulty / setDifficulty and the difficulty_settings codec (LevelSettings.DifficultySettings)
  • /difficulty (DifficultyCommand)

Self-check

cargo check -p horizon-client passes.


🔄 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/2572 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/2571-difficulty-persist` --- ### 📝 Commits (1) - [`a934dac`](https://github.com/horizon-rust/horizon/commit/a934dac2bd240267bb02a9c3eac80a89367c09dd) Save and load the difficulty through level.dat's difficulty_settings ### 📊 Changes **2 files changed** (+11 additions, -35 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+3 -0) 📝 `crates/horizon-client/src/game/chat.rs` (+8 -35) </details> ### 📄 Description ## What and why The difficulty was never saved. The game read and patched the old `Data.Difficulty` key of `level.dat`, but `Level::write` removes that key and stores the difficulty under `difficulty_settings.difficulty`, from a value that only the Create World screen set. So `/difficulty hard` (or the options button) was lost on quit, and loading a world always fell back to Normal, including worlds that came with their own difficulty. Now the live difficulty is copied into the level data before it is written (`sync_level`), and when a world opens the difficulty is read from the loaded `difficulty_settings`. The old read/patch helpers for the dead key are removed. Single player on the server thread uses the same load and save path, and the client gets the loaded value in the difficulty packet it already receives. Fixes #2571. ## Vanilla reference - `PrimaryLevelData.getDifficulty` / `setDifficulty` and the `difficulty_settings` codec (`LevelSettings.DifficultySettings`) - `/difficulty` (`DifficultyCommand`) ## Self-check `cargo check -p horizon-client` passes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:17: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#4436
No description provided.