diff --git a/pumpkin-protocol/src/lib.rs b/pumpkin-protocol/src/lib.rs index 412aa8eb2..3e2b8cdff 100644 --- a/pumpkin-protocol/src/lib.rs +++ b/pumpkin-protocol/src/lib.rs @@ -8,9 +8,9 @@ pub mod bytebuf; pub mod client; pub mod packet_decoder; pub mod packet_encoder; +pub mod position; pub mod server; pub mod uuid; -pub mod position; pub const CURRENT_MC_PROTOCOL: u32 = 767; diff --git a/pumpkin-protocol/src/position.rs b/pumpkin-protocol/src/position.rs index afaaf6adc..4ae10833c 100644 --- a/pumpkin-protocol/src/position.rs +++ b/pumpkin-protocol/src/position.rs @@ -3,29 +3,31 @@ use serde::Deserialize; pub struct WorldPosition { x: i32, y: i32, - z: i32 + z: i32, } impl<'de> Deserialize<'de> for WorldPosition { fn deserialize(deserializer: D) -> Result where - D: serde::Deserializer<'de> { - struct Visitor; - impl<'a> serde::de::Visitor<'a> for Visitor { - type Value = WorldPosition; - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - formatter.write_str("An i64 int") - } - fn visit_i64(self, v: i64) -> Result - where - E: serde::de::Error, { - Ok(WorldPosition { - x: (v >> 38) as i32, - y: (v << 52 >> 52) as i32, - z: (v << 26 >> 38) as i32 - }) - } + D: serde::Deserializer<'de>, + { + struct Visitor; + impl<'a> serde::de::Visitor<'a> for Visitor { + type Value = WorldPosition; + fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + formatter.write_str("An i64 int") + } + fn visit_i64(self, v: i64) -> Result + where + E: serde::de::Error, + { + Ok(WorldPosition { + x: (v >> 38) as i32, + y: (v << 52 >> 52) as i32, + z: (v << 26 >> 38) as i32, + }) } - deserializer.deserialize_i64(Visitor) } -} \ No newline at end of file + deserializer.deserialize_i64(Visitor) + } +} diff --git a/pumpkin-protocol/src/server/play/mod.rs b/pumpkin-protocol/src/server/play/mod.rs index dc03c5175..82ede8352 100644 --- a/pumpkin-protocol/src/server/play/mod.rs +++ b/pumpkin-protocol/src/server/play/mod.rs @@ -3,21 +3,21 @@ mod c_interact; mod s_chat_command; mod s_chat_message; mod s_confirm_teleport; +mod s_player_action; mod s_player_command; mod s_player_position; mod s_player_position_rotation; mod s_player_rotation; mod s_swing_arm; -mod s_player_action; pub use c_client_information::*; pub use c_interact::*; pub use s_chat_command::*; pub use s_chat_message::*; pub use s_confirm_teleport::*; +pub use s_player_action::*; pub use s_player_command::*; pub use s_player_position::*; pub use s_player_position_rotation::*; pub use s_player_rotation::*; pub use s_swing_arm::*; -pub use s_player_action::*; diff --git a/pumpkin-protocol/src/server/play/s_player_action.rs b/pumpkin-protocol/src/server/play/s_player_action.rs index 6b4b40616..4a6061167 100644 --- a/pumpkin-protocol/src/server/play/s_player_action.rs +++ b/pumpkin-protocol/src/server/play/s_player_action.rs @@ -9,4 +9,4 @@ pub struct SPlayerAction { location: WorldPosition, face: u8, sequence: VarInt, -} \ No newline at end of file +} diff --git a/pumpkin-world/src/lib.rs b/pumpkin-world/src/lib.rs index 30051a517..6198796ed 100644 --- a/pumpkin-world/src/lib.rs +++ b/pumpkin-world/src/lib.rs @@ -4,5 +4,5 @@ pub const WORLD_HEIGHT: usize = 384; pub const WORLD_Y_START_AT: i32 = -64; pub const DIRECT_PALETTE_BITS: u32 = 15; mod block_registry; +pub mod radial_chunk_iterator; mod world; -pub mod radial_chunk_iterator; \ No newline at end of file diff --git a/pumpkin-world/src/radial_chunk_iterator.rs b/pumpkin-world/src/radial_chunk_iterator.rs index 650a55253..f8be91fdd 100644 --- a/pumpkin-world/src/radial_chunk_iterator.rs +++ b/pumpkin-world/src/radial_chunk_iterator.rs @@ -56,4 +56,4 @@ impl Iterator for RadialIterator { self.steps_taken += 1; Some(result) } -} \ No newline at end of file +} diff --git a/pumpkin-world/src/world.rs b/pumpkin-world/src/world.rs index 2f2c0d407..03c9cab44 100644 --- a/pumpkin-world/src/world.rs +++ b/pumpkin-world/src/world.rs @@ -89,7 +89,11 @@ impl Level { region_file_path.push(format!("r.{}.{}.mca", region.0, region.1)); // return different error when file is not found (because that means that the chunks have just not been generated yet) - let mut region_file = match std::fs::File::options().read(true).write(false).open(®ion_file_path) { + let mut region_file = match std::fs::File::options() + .read(true) + .write(false) + .open(®ion_file_path) + { Ok(f) => f, Err(err) => match err.kind() { std::io::ErrorKind::NotFound => { diff --git a/pumpkin/src/commands/stop.rs b/pumpkin/src/commands/stop.rs index 09d621228..8a2fcfc4f 100644 --- a/pumpkin/src/commands/stop.rs +++ b/pumpkin/src/commands/stop.rs @@ -1,17 +1,15 @@ use super::Command; -pub struct StopCommand { - -} +pub struct StopCommand {} impl<'a> Command<'a> for StopCommand { const NAME: &'static str = "stop"; const DESCRIPTION: &'static str = "Stops the server"; - + fn on_execute(sender: &mut super::CommandSender<'a>, command: String) { std::process::exit(0); } fn player_required() -> bool { true } -} \ No newline at end of file +} diff --git a/pumpkin/src/server.rs b/pumpkin/src/server.rs index fabd93570..b426a75e4 100644 --- a/pumpkin/src/server.rs +++ b/pumpkin/src/server.rs @@ -347,7 +347,7 @@ impl Server { chunk_x: 0.into(), chunk_z: 0.into(), }); - + while let Some((chunk_pos, chunk_data)) = chunk_receiver.recv().await { // dbg!(chunk_pos); let chunk_data = match chunk_data {