fix: 26.1+ hardcore not being detected (#6744)

* fix: hardcore data schema changed in 26.1

* fix: lint
This commit is contained in:
Calum H.
2026-07-16 18:32:20 +00:00
committed by GitHub
parent 4aeb6cf9ff
commit df653d3e43
+9 -1
View File
@@ -401,7 +401,7 @@ async fn read_singleplayer_world_maybe_locked(
.to_string();
let last_played = data.get::<_, i64>("LastPlayed").unwrap_or(0);
let game_type = data.get::<_, i32>("GameType").unwrap_or(0);
let hardcore = data.get::<_, i8>("hardcore").unwrap_or(0) != 0;
let hardcore = read_hardcore(data);
let icon = if tokio::fs::try_exists(world_path.join("icon.png"))
.await
@@ -438,6 +438,14 @@ async fn read_singleplayer_world_maybe_locked(
})
}
fn read_hardcore(data: &NbtCompound) -> bool {
data.get::<_, &NbtCompound>("difficulty_settings")
.and_then(|settings| settings.get::<_, i8>("hardcore"))
.or_else(|_| data.get::<_, i8>("hardcore"))
.unwrap_or(0)
!= 0
}
async fn get_server_worlds_in_instance(
instance_id: &str,
instance_dir: &Path,