diff options
5 files changed, 5 insertions, 65 deletions
diff --git a/azalea-protocol/packet-macros/src/lib.rs b/azalea-protocol/packet-macros/src/lib.rs index 470ac4c1..11878abf 100644 --- a/azalea-protocol/packet-macros/src/lib.rs +++ b/azalea-protocol/packet-macros/src/lib.rs @@ -1,5 +1,5 @@ -use quote::{quote, quote_spanned, ToTokens}; -use syn::{self, parse_macro_input, spanned::Spanned, DeriveInput, FieldsNamed}; +use quote::{quote, ToTokens}; +use syn::{self, parse_macro_input, DeriveInput, FieldsNamed}; fn as_packet_derive( input: proc_macro::TokenStream, diff --git a/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs b/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs index 24220a83..4ee0ddf0 100644 --- a/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs @@ -1,5 +1,4 @@ use crate::mc_buf::{Readable, Writable}; -use crate::packets::game::GamePacket; use azalea_core::resource_location::ResourceLocation; use packet_macros::GamePacket; diff --git a/azalea-protocol/src/packets/game/clientbound_update_view_distance_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_view_distance_packet.rs index f6028e6c..cd48b304 100644 --- a/azalea-protocol/src/packets/game/clientbound_update_view_distance_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_view_distance_packet.rs @@ -1,6 +1,5 @@ // i don't know the actual name of this packet, i couldn't find it in the source code! -use super::GamePacket; use crate::mc_buf::{Readable, Writable}; use packet_macros::GamePacket; diff --git a/azalea-protocol/src/packets/handshake/client_intention_packet.rs b/azalea-protocol/src/packets/handshake/client_intention_packet.rs index b3eb8301..00d124a4 100644 --- a/azalea-protocol/src/packets/handshake/client_intention_packet.rs +++ b/azalea-protocol/src/packets/handshake/client_intention_packet.rs @@ -14,35 +14,3 @@ 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>) { -// buf.write_varint(self.protocol_version as i32).unwrap(); -// buf.write_utf(&self.hostname).unwrap(); -// buf.write_short(self.port).unwrap(); -// buf.write_varint(self.intention.clone() as i32).unwrap(); -// } - -// pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>( -// buf: &mut T, -// ) -> Result<HandshakePacket, String> { -// let protocol_version = buf.read_varint().await? as u32; -// let hostname = buf.read_utf().await?; -// let port = buf.read_short().await? as u16; -// let intention = buf.read_varint().await?; - -// Ok(HandshakePacket::ClientIntentionPacket( -// ClientIntentionPacket { -// protocol_version, -// hostname, -// port, -// intention: ConnectionProtocol::from_i32(intention) -// .ok_or_else(|| "Invalid intention".to_string())?, -// }, -// )) -// } -// } diff --git a/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs b/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs index 22e58b0d..77262c43 100644 --- a/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs @@ -1,38 +1,12 @@ -use super::LoginPacket; use crate::mc_buf::{Readable, Writable}; use azalea_core::resource_location::ResourceLocation; +use packet_macros::LoginPacket; use std::hash::Hash; -#[derive(Hash, Clone, Debug)] +#[derive(Hash, Clone, Debug, LoginPacket)] pub struct ClientboundCustomQueryPacket { + #[varint] pub transaction_id: u32, pub identifier: ResourceLocation, pub data: Vec<u8>, } - -impl ClientboundCustomQueryPacket { - pub fn get(self) -> LoginPacket { - LoginPacket::ClientboundCustomQueryPacket(self) - } - - pub fn write(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { - buf.write_varint(self.transaction_id as i32).unwrap(); - buf.write_utf(self.identifier.to_string().as_str()).unwrap(); - buf.write_bytes(&self.data).unwrap(); - Ok(()) - } - - pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>( - buf: &mut T, - ) -> Result<LoginPacket, String> { - let transaction_id = buf.read_varint().await? as u32; - let identifier = ResourceLocation::new(&buf.read_utf().await?)?; - let data = buf.read_bytes_with_len(1048576).await?; - Ok(ClientboundCustomQueryPacket { - transaction_id, - identifier, - data, - } - .get()) - } -} |
