mirror of
https://github.com/modrinth/code.git
synced 2026-07-31 13:16:38 +00:00
fix: 26.1+ hardcore not being detected (#6744)
* fix: hardcore data schema changed in 26.1 * fix: lint
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user