diff options
Diffstat (limited to 'azalea-protocol/src')
7 files changed, 47 insertions, 13 deletions
diff --git a/azalea-protocol/src/connect.rs b/azalea-protocol/src/connect.rs index 149ea95d..06b306b9 100755 --- a/azalea-protocol/src/connect.rs +++ b/azalea-protocol/src/connect.rs @@ -305,7 +305,7 @@ impl Connection<ClientboundLoginPacket, ServerboundLoginPacket> { /// let e = azalea_crypto::encrypt(&p.public_key, &p.nonce).unwrap(); /// conn.authenticate( /// &access_token, - /// &Uuid::parse_str(&profile.id).expect("Invalid UUID"), + /// &profile.id, /// e.secret_key, /// &p /// ).await?; diff --git a/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs b/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs index f33d75a4..77742c0a 100755 --- a/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs @@ -1,7 +1,7 @@ use azalea_buf::McBuf; use azalea_protocol_macros::ClientboundGamePacket; -#[derive(Clone, Debug, McBuf, ClientboundGamePacket)] +#[derive(Clone, Debug, ClientboundGamePacket, McBuf)] pub struct ClientboundInitializeBorderPacket { pub new_center_x: f64, pub new_center_z: f64, diff --git a/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs index eaa34669..6efe1f97 100755 --- a/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs @@ -1,4 +1,4 @@ -use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufWritable}; +use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable}; use azalea_core::ParticleData; use azalea_protocol_macros::ClientboundGamePacket; use std::io::{Cursor, Write}; @@ -51,7 +51,18 @@ impl McBufReadable for ClientboundLevelParticlesPacket { } impl McBufWritable for ClientboundLevelParticlesPacket { - fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> { - todo!(); + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + self.particle_id.var_write_into(buf)?; + self.override_limiter.write_into(buf)?; + self.x.write_into(buf)?; + self.y.write_into(buf)?; + self.z.write_into(buf)?; + self.x_dist.write_into(buf)?; + self.y_dist.write_into(buf)?; + self.z_dist.write_into(buf)?; + self.max_speed.write_into(buf)?; + self.count.write_into(buf)?; + self.data.write_without_id(buf)?; + Ok(()) } } diff --git a/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs index a3a3b45d..4fa16209 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs @@ -3,7 +3,7 @@ use azalea_buf::{ BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable, }; use azalea_chat::Component; -use azalea_core::{BitSet, GameType}; +use azalea_core::{FixedBitSet, GameType}; use azalea_protocol_macros::ClientboundGamePacket; use std::{ collections::HashMap, @@ -151,7 +151,7 @@ impl McBufWritable for ClientboundPlayerInfoUpdatePacket { } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct ActionEnumSet { pub add_player: bool, pub initialize_chat: bool, @@ -163,7 +163,7 @@ pub struct ActionEnumSet { impl McBufReadable for ActionEnumSet { fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { - let set = BitSet::read_fixed(buf, 6)?; + let set = FixedBitSet::<6>::read_from(buf)?; Ok(ActionEnumSet { add_player: set.index(0), initialize_chat: set.index(1), @@ -177,7 +177,7 @@ impl McBufReadable for ActionEnumSet { impl McBufWritable for ActionEnumSet { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { - let mut set = BitSet::new(6); + let mut set = FixedBitSet::<6>::new(); if self.add_player { set.set(0); } @@ -196,6 +196,29 @@ impl McBufWritable for ActionEnumSet { if self.update_display_name { set.set(5); } - set.write_into(buf) + set.write_into(buf)?; + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_action_enum_set() { + let data = ActionEnumSet { + add_player: true, + initialize_chat: false, + update_game_mode: true, + update_listed: false, + update_latency: true, + update_display_name: false, + }; + let mut buf = Vec::new(); + data.write_into(&mut buf).unwrap(); + let mut data_cursor: Cursor<&[u8]> = Cursor::new(&buf); + let read_data = ActionEnumSet::read_from(&mut data_cursor).unwrap(); + assert_eq!(read_data, data); } } diff --git a/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs index 3e6e413a..d09768c7 100755 --- a/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs @@ -40,7 +40,7 @@ impl McBufReadable for TagMap { impl McBufWritable for TagMap { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { - (self.len() as u32).write_into(buf)?; + (self.len() as u32).var_write_into(buf)?; for (k, v) in &self.0 { k.write_into(buf)?; v.write_into(buf)?; diff --git a/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs b/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs index ab1ae9a0..7f979363 100755 --- a/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs @@ -23,7 +23,7 @@ impl McBufWritable for ServerboundPlayerAbilitiesPacket { if self.is_flying { byte |= 2; } - byte.write_into(buf)?; + u8::write_into(&byte, buf)?; Ok(()) } } diff --git a/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs b/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs index 30d3c3ae..2bd7f6eb 100755 --- a/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs @@ -32,7 +32,7 @@ impl McBufWritable for ServerboundPlayerInputPacket { fn write_into(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> { self.xxa.write_into(buf)?; self.zza.write_into(buf)?; - let mut byte = 0; + let mut byte = 0u8; if self.is_jumping { byte |= 1; } |
