diff options
| author | mat <github@matdoes.dev> | 2022-04-24 16:18:51 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-04-24 16:18:51 -0500 |
| commit | b7641ff308aab7840d2a2253ae50f8ee496b2a97 (patch) | |
| tree | f33eb83f119da5aae08f56a5c7543db15594b01d /azalea-protocol/src/packets | |
| parent | 97d392f4e5721d8aa8940f253918965ff0b40348 (diff) | |
| download | azalea-drasl-b7641ff308aab7840d2a2253ae50f8ee496b2a97.tar.xz | |
1.18.2 support
Diffstat (limited to 'azalea-protocol/src/packets')
6 files changed, 48 insertions, 5 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs b/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs new file mode 100644 index 00000000..74f5f72e --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs @@ -0,0 +1,9 @@ +use azalea_chat::component::Component; +use azalea_core::resource_location::ResourceLocation; +use packet_macros::GamePacket; +use serde::Deserialize; + +#[derive(Clone, Debug, GamePacket)] +pub struct ClientboundDisconnectPacket { + pub reason: Component, +} diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs index e150606c..dde3f753 100755 --- a/azalea-protocol/src/packets/game/mod.rs +++ b/azalea-protocol/src/packets/game/mod.rs @@ -1,6 +1,7 @@ pub mod clientbound_change_difficulty_packet; pub mod clientbound_custom_payload_packet; pub mod clientbound_declare_commands_packet; +pub mod clientbound_disconnect_packet; pub mod clientbound_login_packet; pub mod clientbound_player_abilities_packet; pub mod clientbound_set_carried_item_packet; @@ -15,6 +16,7 @@ declare_state_packets!( Clientbound => { 0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket, 0x12: clientbound_declare_commands_packet::ClientboundDeclareCommandsPacket, + 0x1a: clientbound_disconnect_packet::ClientboundDisconnectPacket, 0x18: clientbound_custom_payload_packet::ClientboundCustomPayloadPacket, 0x26: clientbound_login_packet::ClientboundLoginPacket, 0x32: clientbound_player_abilities_packet::ClientboundPlayerAbilitiesPacket, diff --git a/azalea-protocol/src/packets/handshake/client_intention_packet.rs b/azalea-protocol/src/packets/handshake/client_intention_packet.rs index 6216ddc4..a92d65f6 100755 --- a/azalea-protocol/src/packets/handshake/client_intention_packet.rs +++ b/azalea-protocol/src/packets/handshake/client_intention_packet.rs @@ -1,7 +1,9 @@ -use crate::packets::ConnectionProtocol; +use crate::{mc_buf::Writable, packets::ConnectionProtocol}; use packet_macros::HandshakePacket; use std::hash::Hash; +use super::HandshakePacket; + #[derive(Hash, Clone, Debug, HandshakePacket)] pub struct ClientIntentionPacket { #[varint] @@ -10,3 +12,23 @@ pub struct ClientIntentionPacket { pub port: u16, pub intention: ConnectionProtocol, } + +// impl ClientIntentionPacket { +// pub fn get(self) -> HandshakePacket { +// HandshakePacket::ClientIntentionPacket(self) +// } + +// pub fn write(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { +// buf.write_varint(self.protocol_version as i32)?; +// buf.write_utf(&self.hostname)?; +// buf.write_short(self.port as i16)?; +// buf.write_varint(self.intention as i32)?; +// Ok(()) +// } + +// pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>( +// buf: &mut T, +// ) -> Result<HandshakePacket, String> { +// todo!() +// } +// } diff --git a/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs b/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs new file mode 100644 index 00000000..28d91c79 --- /dev/null +++ b/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs @@ -0,0 +1,7 @@ +use azalea_chat::component::Component; +use packet_macros::LoginPacket; + +#[derive(Clone, Debug, LoginPacket)] +pub struct ClientboundLoginDisconnectPacket { + pub reason: Component, +} diff --git a/azalea-protocol/src/packets/login/mod.rs b/azalea-protocol/src/packets/login/mod.rs index ef5f15c1..ab68518c 100755 --- a/azalea-protocol/src/packets/login/mod.rs +++ b/azalea-protocol/src/packets/login/mod.rs @@ -2,6 +2,7 @@ pub mod clientbound_custom_query_packet; pub mod clientbound_game_profile_packet; pub mod clientbound_hello_packet; pub mod clientbound_login_compression_packet; +pub mod clientbound_login_disconnect_packet; pub mod serverbound_hello_packet; use packet_macros::declare_state_packets; @@ -12,7 +13,9 @@ declare_state_packets!( 0x00: serverbound_hello_packet::ServerboundHelloPacket, }, Clientbound => { - 0x00: clientbound_hello_packet::ClientboundHelloPacket, + // 0x00: clientbound_login_disconnect_packet::ClientboundLoginDisconnectPacket, + 26: clientbound_login_disconnect_packet::ClientboundLoginDisconnectPacket, + 0x01: clientbound_hello_packet::ClientboundHelloPacket, 0x02: clientbound_game_profile_packet::ClientboundGameProfilePacket, 0x03: clientbound_login_compression_packet::ClientboundLoginCompressionPacket, 0x04: clientbound_custom_query_packet::ClientboundCustomQueryPacket, diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs index f35451c6..98741a75 100755 --- a/azalea-protocol/src/packets/mod.rs +++ b/azalea-protocol/src/packets/mod.rs @@ -12,9 +12,9 @@ use num_derive::FromPrimitive; use num_traits::FromPrimitive; use tokio::io::AsyncRead; -pub const PROTOCOL_VERSION: u32 = 757; +pub const PROTOCOL_VERSION: u32 = 758; -#[derive(Debug, Clone, PartialEq, Eq, Hash, FromPrimitive)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, FromPrimitive)] pub enum ConnectionProtocol { Handshake = -1, Game = 0, @@ -63,6 +63,6 @@ impl McBufReadable for ConnectionProtocol { impl McBufWritable for ConnectionProtocol { fn write_into(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { - buf.write_varint(self.clone() as i32) + buf.write_varint(*self as i32) } } |
