Fix reading from invalid level.data

Also use Spawn x and z now !
This commit is contained in:
Alexander Medvedev 2025-01-30 15:13:56 +01:00
parent c6d349249c
commit fefcb78e56
4 changed files with 14 additions and 8 deletions

View File

@ -25,7 +25,6 @@ and customizable experience. It prioritizes performance and player enjoyment whi
## What Pumpkin will not ## What Pumpkin will not
- Be compatible with plugins or mods for other servers - Be compatible with plugins or mods for other servers
- Function as a framework for building a server from scratch.
> [!IMPORTANT] > [!IMPORTANT]
> Pumpkin is currently under heavy development. > Pumpkin is currently under heavy development.
@ -87,7 +86,7 @@ and customizable experience. It prioritizes performance and player enjoyment whi
- [x] Bungeecord - [x] Bungeecord
- [x] Velocity - [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 ## How to run

View File

@ -59,6 +59,7 @@ impl WorldInfoWriter for AnvilLevelInfo {
spawn_x: info.spawn_x, spawn_x: info.spawn_x,
spawn_y: info.spawn_y, spawn_y: info.spawn_y,
spawn_z: info.spawn_z, spawn_z: info.spawn_z,
spawn_angle: info.spawn_angle,
nbt_version: info.nbt_version, nbt_version: info.nbt_version,
version: info.version, version: info.version,
}, },

View File

@ -21,13 +21,14 @@ pub(crate) trait WorldInfoWriter: Sync + Send {
#[derive(Serialize, Deserialize, Clone)] #[derive(Serialize, Deserialize, Clone)]
#[serde(rename_all = "PascalCase")] #[serde(rename_all = "PascalCase")]
#[serde(default)]
pub struct LevelData { pub struct LevelData {
// true if cheats are enabled. // true if cheats are enabled.
pub allow_commands: bool, pub allow_commands: bool,
// An integer displaying the data version. // An integer displaying the data version.
pub data_version: i32, pub data_version: i32,
// The current difficulty setting. // The current difficulty setting.
pub difficulty: Difficulty, pub difficulty: u8,
// the generation settings for each dimension. // the generation settings for each dimension.
pub world_gen_settings: WorldGenSettings, pub world_gen_settings: WorldGenSettings,
// The Unix time in milliseconds when the level was last loaded. // The Unix time in milliseconds when the level was last loaded.
@ -40,6 +41,8 @@ pub struct LevelData {
pub spawn_y: i32, pub spawn_y: i32,
// The Z coordinate of the world spawn. // The Z coordinate of the world spawn.
pub spawn_z: i32, pub spawn_z: i32,
// The Yaw rotation of the world spawn.
pub spawn_angle: f32,
#[serde(rename = "version")] #[serde(rename = "version")]
// The NBT version of the level // The NBT version of the level
pub nbt_version: i32, pub nbt_version: i32,
@ -97,13 +100,14 @@ impl Default for LevelData {
allow_commands: true, allow_commands: true,
// TODO // TODO
data_version: -1, data_version: -1,
difficulty: Difficulty::Normal, difficulty: Difficulty::Normal as u8,
world_gen_settings: Default::default(), world_gen_settings: Default::default(),
last_played: -1, last_played: -1,
level_name: "world".to_string(), level_name: "world".to_string(),
spawn_x: 0, spawn_x: 0,
spawn_y: 200, spawn_y: 200,
spawn_z: 0, spawn_z: 0,
spawn_angle: 0.0,
nbt_version: -1, nbt_version: -1,
version: Default::default(), version: Default::default(),
} }

View File

@ -306,8 +306,9 @@ impl World {
player.send_permission_lvl_update().await; player.send_permission_lvl_update().await;
client_cmd_suggestions::send_c_commands_packet(&player, &server.command_dispatcher).await; client_cmd_suggestions::send_c_commands_packet(&player, &server.command_dispatcher).await;
// teleport // teleport
let mut position = Vector3::new(10.0, 120.0, 10.0); let info = &self.level.level_info;
let yaw = 10.0; 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 pitch = 10.0;
let top = self let top = self
@ -498,8 +499,9 @@ impl World {
player.send_permission_lvl_update().await; player.send_permission_lvl_update().await;
// teleport // teleport
let mut position = Vector3::new(10.0, 120.0, 10.0); let info = &self.level.level_info;
let yaw = 10.0; 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 pitch = 10.0;
let top = self let top = self