From fefcb78e5671e089f59d49d264b0160271b8be82 Mon Sep 17 00:00:00 2001 From: Alexander Medvedev Date: Thu, 30 Jan 2025 15:13:56 +0100 Subject: [PATCH] Fix reading from invalid level.data Also use Spawn x and z now ! --- README.md | 3 +-- pumpkin-world/src/world_info/anvil.rs | 1 + pumpkin-world/src/world_info/mod.rs | 8 ++++++-- pumpkin/src/world/mod.rs | 10 ++++++---- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d309357f2..08b2730fb 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,6 @@ and customizable experience. It prioritizes performance and player enjoyment whi ## What Pumpkin will not - Be compatible with plugins or mods for other servers -- Function as a framework for building a server from scratch. > [!IMPORTANT] > Pumpkin is currently under heavy development. @@ -87,7 +86,7 @@ and customizable experience. It prioritizes performance and player enjoyment whi - [x] Bungeecord - [x] Velocity -Check out our [Github Project](https://github.com/users/Snowiiii/projects/12/views/3) to see current progress +Check out our [Github Project](https://github.com/orgs/Pumpkin-MC/projects/3) to see current progress ## How to run diff --git a/pumpkin-world/src/world_info/anvil.rs b/pumpkin-world/src/world_info/anvil.rs index 37734af5b..d02b32e27 100644 --- a/pumpkin-world/src/world_info/anvil.rs +++ b/pumpkin-world/src/world_info/anvil.rs @@ -59,6 +59,7 @@ impl WorldInfoWriter for AnvilLevelInfo { spawn_x: info.spawn_x, spawn_y: info.spawn_y, spawn_z: info.spawn_z, + spawn_angle: info.spawn_angle, nbt_version: info.nbt_version, version: info.version, }, diff --git a/pumpkin-world/src/world_info/mod.rs b/pumpkin-world/src/world_info/mod.rs index 9e5d5c312..0c31abdde 100644 --- a/pumpkin-world/src/world_info/mod.rs +++ b/pumpkin-world/src/world_info/mod.rs @@ -21,13 +21,14 @@ pub(crate) trait WorldInfoWriter: Sync + Send { #[derive(Serialize, Deserialize, Clone)] #[serde(rename_all = "PascalCase")] +#[serde(default)] pub struct LevelData { // true if cheats are enabled. pub allow_commands: bool, // An integer displaying the data version. pub data_version: i32, // The current difficulty setting. - pub difficulty: Difficulty, + pub difficulty: u8, // the generation settings for each dimension. pub world_gen_settings: WorldGenSettings, // The Unix time in milliseconds when the level was last loaded. @@ -40,6 +41,8 @@ pub struct LevelData { pub spawn_y: i32, // The Z coordinate of the world spawn. pub spawn_z: i32, + // The Yaw rotation of the world spawn. + pub spawn_angle: f32, #[serde(rename = "version")] // The NBT version of the level pub nbt_version: i32, @@ -97,13 +100,14 @@ impl Default for LevelData { allow_commands: true, // TODO data_version: -1, - difficulty: Difficulty::Normal, + difficulty: Difficulty::Normal as u8, world_gen_settings: Default::default(), last_played: -1, level_name: "world".to_string(), spawn_x: 0, spawn_y: 200, spawn_z: 0, + spawn_angle: 0.0, nbt_version: -1, version: Default::default(), } diff --git a/pumpkin/src/world/mod.rs b/pumpkin/src/world/mod.rs index 46293507c..7504f8960 100644 --- a/pumpkin/src/world/mod.rs +++ b/pumpkin/src/world/mod.rs @@ -306,8 +306,9 @@ impl World { player.send_permission_lvl_update().await; client_cmd_suggestions::send_c_commands_packet(&player, &server.command_dispatcher).await; // teleport - let mut position = Vector3::new(10.0, 120.0, 10.0); - let yaw = 10.0; + let info = &self.level.level_info; + let mut position = Vector3::new(f64::from(info.spawn_x), 120.0, f64::from(info.spawn_z)); + let yaw = info.spawn_angle; let pitch = 10.0; let top = self @@ -498,8 +499,9 @@ impl World { player.send_permission_lvl_update().await; // teleport - let mut position = Vector3::new(10.0, 120.0, 10.0); - let yaw = 10.0; + let info = &self.level.level_info; + let mut position = Vector3::new(f64::from(info.spawn_x), 120.0, f64::from(info.spawn_z)); + let yaw = info.spawn_angle; let pitch = 10.0; let top = self