From a24d00d99819166a147af77dc50ff61dff5cb04a Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 1 May 2022 23:35:30 -0500 Subject: impl Write instead of Vec for consistency --- .../src/packets/login/clientbound_game_profile_packet.rs | 4 ++-- azalea-protocol/src/packets/login/clientbound_hello_packet.rs | 9 ++++++--- .../src/packets/login/clientbound_login_compression_packet.rs | 9 ++++++--- 3 files changed, 14 insertions(+), 8 deletions(-) (limited to 'azalea-protocol/src/packets/login') diff --git a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs b/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs index bcdcd105..dd077ced 100755 --- a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs @@ -1,4 +1,4 @@ -use std::io::Read; +use std::io::{Read, Write}; use super::LoginPacket; use crate::mc_buf::{Readable, Writable}; @@ -17,7 +17,7 @@ impl ClientboundGameProfilePacket { LoginPacket::ClientboundGameProfilePacket(self) } - pub fn write(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + pub fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { for n in self.game_profile.uuid.to_int_array() { buf.write_int(n as i32).unwrap(); } diff --git a/azalea-protocol/src/packets/login/clientbound_hello_packet.rs b/azalea-protocol/src/packets/login/clientbound_hello_packet.rs index 06f346c2..f7de4c21 100755 --- a/azalea-protocol/src/packets/login/clientbound_hello_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_hello_packet.rs @@ -1,4 +1,7 @@ -use std::{hash::Hash, io::Read}; +use std::{ + hash::Hash, + io::{Read, Write}, +}; use super::LoginPacket; use crate::mc_buf::Readable; @@ -15,11 +18,11 @@ impl ClientboundHelloPacket { LoginPacket::ClientboundHelloPacket(self) } - pub fn write(&self, _buf: &mut Vec) -> Result<(), std::io::Error> { + pub fn write(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> { panic!("ClientboundHelloPacket::write not implemented") } - pub fn read(buf: &mut impl Read) -> Result { + pub fn read(buf: &mut impl Read) -> Result { let server_id = buf.read_utf_with_len(20)?; let public_key = buf.read_byte_array()?; let nonce = buf.read_byte_array()?; diff --git a/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs b/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs index a5ab78bb..b1323f50 100755 --- a/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs @@ -1,4 +1,7 @@ -use std::{hash::Hash, io::Read}; +use std::{ + hash::Hash, + io::{Read, Write}, +}; use crate::mc_buf::{Readable, Writable}; @@ -14,12 +17,12 @@ impl ClientboundLoginCompressionPacket { LoginPacket::ClientboundLoginCompressionPacket(self) } - pub fn write(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + pub fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_varint(self.compression_threshold).unwrap(); Ok(()) } - pub fn read(buf: &mut impl Read) -> Result { + pub fn read(buf: &mut impl Read) -> Result { let compression_threshold = buf.read_varint()?; Ok(ClientboundLoginCompressionPacket { -- cgit v1.2.3 From c9878129274258a30dc3ee0ecbd064b4fcf9bc6e Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 3 May 2022 18:20:24 +0000 Subject: clippy --- azalea-client/src/connect.rs | 19 +++++++++---------- azalea-client/src/player.rs | 1 - azalea-crypto/src/lib.rs | 14 +++++--------- azalea-nbt/src/encode.rs | 2 +- azalea-protocol/packet-macros/src/lib.rs | 13 ++++++------- azalea-protocol/src/mc_buf/read.rs | 6 +++--- azalea-protocol/src/mc_buf/write.rs | 8 ++++---- .../game/clientbound_declare_commands_packet.rs | 18 ++++++++---------- .../packets/game/clientbound_light_update_packet.rs | 1 - .../game/clientbound_player_abilities_packet.rs | 8 ++++---- .../game/clientbound_player_position_packet.rs | 10 +++++----- .../src/packets/game/clientbound_recipe_packet.rs | 4 ++-- .../game/clientbound_set_entity_data_packet.rs | 4 ++-- .../packets/game/clientbound_update_recipes_packet.rs | 2 +- .../src/packets/login/serverbound_key_packet.rs | 2 -- azalea-protocol/src/write.rs | 5 +---- azalea-world/src/palette.rs | 18 +++++++++--------- 17 files changed, 60 insertions(+), 75 deletions(-) (limited to 'azalea-protocol/src/packets/login') diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index 984c5d86..3b880ea3 100755 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -13,8 +13,8 @@ use azalea_protocol::{ }, resolver, ServerAddress, }; -use azalea_world::{Chunk, ChunkStorage, World}; -use std::{fmt::Debug, ops::Deref, sync::Arc}; +use azalea_world::{ChunkStorage, World}; +use std::{fmt::Debug, sync::Arc}; use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender}; use tokio::sync::Mutex; @@ -34,8 +34,8 @@ pub struct ClientState { /// A player that you can control that is currently in a Minecraft server. pub struct Client { event_receiver: UnboundedReceiver, - conn: Arc>, - state: Arc>, + pub conn: Arc>, + pub state: Arc>, // game_loop } @@ -133,10 +133,9 @@ impl Client { // just start up the game loop and we're ready! // tokio::spawn(Self::game_loop(conn, tx, handler, state)) - let game_loop_conn = conn.clone(); let game_loop_state = client.state.clone(); - tokio::spawn(Self::game_loop(game_loop_conn, tx, game_loop_state)); + tokio::spawn(Self::game_loop(conn, tx, game_loop_state)); Ok(client) } @@ -221,7 +220,7 @@ impl Client { GamePacket::ClientboundChangeDifficultyPacket(p) => { println!("Got difficulty packet {:?}", p); } - GamePacket::ClientboundDeclareCommandsPacket(p) => { + GamePacket::ClientboundDeclareCommandsPacket(_p) => { println!("Got declare commands packet"); } GamePacket::ClientboundPlayerAbilitiesPacket(p) => { @@ -230,19 +229,19 @@ impl Client { GamePacket::ClientboundSetCarriedItemPacket(p) => { println!("Got set carried item packet {:?}", p); } - GamePacket::ClientboundUpdateTagsPacket(p) => { + GamePacket::ClientboundUpdateTagsPacket(_p) => { println!("Got update tags packet"); } GamePacket::ClientboundDisconnectPacket(p) => { println!("Got disconnect packet {:?}", p); } - GamePacket::ClientboundUpdateRecipesPacket(p) => { + GamePacket::ClientboundUpdateRecipesPacket(_p) => { println!("Got update recipes packet"); } GamePacket::ClientboundEntityEventPacket(p) => { println!("Got entity event packet {:?}", p); } - GamePacket::ClientboundRecipePacket(p) => { + GamePacket::ClientboundRecipePacket(_p) => { println!("Got recipe packet"); } GamePacket::ClientboundPlayerPositionPacket(p) => { diff --git a/azalea-client/src/player.rs b/azalea-client/src/player.rs index 70ac1c76..fc54ff93 100644 --- a/azalea-client/src/player.rs +++ b/azalea-client/src/player.rs @@ -1,5 +1,4 @@ use crate::Entity; -use azalea_world::World; #[derive(Default)] pub struct Player { diff --git a/azalea-crypto/src/lib.rs b/azalea-crypto/src/lib.rs index dc2620cc..62a81de3 100644 --- a/azalea-crypto/src/lib.rs +++ b/azalea-crypto/src/lib.rs @@ -1,9 +1,6 @@ use aes::cipher::inout::InOutBuf; -use aes::cipher::BlockEncrypt; use aes::{ - cipher::{ - generic_array::GenericArray, AsyncStreamCipher, BlockDecryptMut, BlockEncryptMut, KeyIvInit, - }, + cipher::{BlockDecryptMut, BlockEncryptMut, KeyIvInit}, Aes128, }; use rand::{rngs::OsRng, RngCore}; @@ -15,7 +12,7 @@ fn generate_secret_key() -> [u8; 16] { key } -fn digest_data(server_id: &[u8], public_key: &[u8], private_key: &[u8]) -> Vec { +pub fn digest_data(server_id: &[u8], public_key: &[u8], private_key: &[u8]) -> Vec { let mut digest = Sha1::new(); digest.update(server_id); digest.update(public_key); @@ -23,7 +20,7 @@ fn digest_data(server_id: &[u8], public_key: &[u8], private_key: &[u8]) -> Vec String { +pub fn hex_digest(digest: &[u8]) -> String { // Note that the Sha1.hexdigest() method used by minecraft is non standard. // It doesn't match the digest method found in most programming languages // and libraries. It works by treating the sha1 output bytes as one large @@ -48,9 +45,8 @@ pub fn encrypt(public_key: &[u8], nonce: &[u8]) -> Result // this.keybytes = Crypt.encryptUsingKey(publicKey, secretKey.getEncoded()); // this.nonce = Crypt.encryptUsingKey(publicKey, arrby); - let encrypted_public_key: Vec = - rsa_public_encrypt_pkcs1::encrypt(&public_key, &secret_key)?; - let encrypted_nonce: Vec = rsa_public_encrypt_pkcs1::encrypt(&public_key, &nonce)?; + let encrypted_public_key: Vec = rsa_public_encrypt_pkcs1::encrypt(public_key, &secret_key)?; + let encrypted_nonce: Vec = rsa_public_encrypt_pkcs1::encrypt(public_key, nonce)?; Ok(EncryptResult { secret_key, diff --git a/azalea-nbt/src/encode.rs b/azalea-nbt/src/encode.rs index 20d13793..fb5585b3 100755 --- a/azalea-nbt/src/encode.rs +++ b/azalea-nbt/src/encode.rs @@ -98,7 +98,7 @@ fn write_compound( if end_tag { writer.write_u8(Tag::End.id())?; } - return Ok(()); + Ok(()) } #[inline] diff --git a/azalea-protocol/packet-macros/src/lib.rs b/azalea-protocol/packet-macros/src/lib.rs index 35abf642..dec153ec 100755 --- a/azalea-protocol/packet-macros/src/lib.rs +++ b/azalea-protocol/packet-macros/src/lib.rs @@ -232,13 +232,12 @@ struct PacketIdMap { impl Parse for PacketIdMap { fn parse(input: ParseStream) -> Result { let mut packets = vec![]; - loop { - // 0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket, - // 0x0e - let packet_id: LitInt = match input.parse() { - Ok(i) => i, - Err(_) => break, - }; + + // example: + // 0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket, + + // 0x0e + while let Ok(packet_id) = input.parse::() { let packet_id = packet_id.base10_parse::()?; // : input.parse::()?; diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs index 68c9cb3f..e1ae321c 100755 --- a/azalea-protocol/src/mc_buf/read.rs +++ b/azalea-protocol/src/mc_buf/read.rs @@ -1,10 +1,10 @@ -use super::{BitSet, UnsizedByteArray, MAX_STRING_LENGTH}; +use super::{UnsizedByteArray, MAX_STRING_LENGTH}; use azalea_chat::component::Component; use azalea_core::{ difficulty::Difficulty, game_type::GameType, resource_location::ResourceLocation, serializable_uuid::SerializableUuid, BlockPos, Direction, Slot, SlotData, }; -use byteorder::{ReadBytesExt, WriteBytesExt, BE}; +use byteorder::{ReadBytesExt, BE}; use serde::Deserialize; use std::io::Read; use tokio::io::{AsyncRead, AsyncReadExt}; @@ -421,7 +421,7 @@ impl McBufReadable for Component { fn read_into(buf: &mut impl Read) -> Result { let string = buf.read_utf()?; let json: serde_json::Value = serde_json::from_str(string.as_str()) - .map_err(|e| "Component isn't valid JSON".to_string())?; + .map_err(|_| "Component isn't valid JSON".to_string())?; let component = Component::deserialize(json).map_err(|e| e.to_string())?; Ok(component) } diff --git a/azalea-protocol/src/mc_buf/write.rs b/azalea-protocol/src/mc_buf/write.rs index 34bcafeb..3a4a02f8 100755 --- a/azalea-protocol/src/mc_buf/write.rs +++ b/azalea-protocol/src/mc_buf/write.rs @@ -20,8 +20,8 @@ pub trait Writable: Write { Ok(()) } - fn write_int_id_list(&mut self, list: &Vec) -> Result<(), std::io::Error> { - self.write_list(&list, |buf, n| buf.write_varint(*n)) + fn write_int_id_list(&mut self, list: &[i32]) -> Result<(), std::io::Error> { + self.write_list(list, |buf, n| buf.write_varint(*n)) } fn write_map( @@ -47,7 +47,7 @@ pub trait Writable: Write { } fn write_bytes(&mut self, bytes: &[u8]) -> Result<(), std::io::Error> { - self.write_all(bytes); + self.write_all(bytes)?; Ok(()) } @@ -333,7 +333,7 @@ impl McBufWritable for Component { // let component = Component::deserialize(json).map_err(|e| e.to_string())?; // Ok(component) // } - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> { // component doesn't have serialize implemented yet todo!() } diff --git a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs index 27f4fb16..6743c3af 100755 --- a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs @@ -281,7 +281,7 @@ impl McBufReadable for BrigadierParser { } } -// azalea_brigadier::tree::CommandNode +// TODO: BrigadierNodeStub should have more stuff impl McBufReadable for BrigadierNodeStub { fn read_into(buf: &mut impl Read) -> Result { let flags = u8::read_into(buf)?; @@ -292,20 +292,18 @@ impl McBufReadable for BrigadierNodeStub { } let node_type = flags & 0x03; - let is_executable = flags & 0x04 != 0; + let _is_executable = flags & 0x04 != 0; let has_redirect = flags & 0x08 != 0; let has_suggestions_type = flags & 0x10 != 0; - let children = buf.read_int_id_list()?; - let redirect_node = if has_redirect { buf.read_varint()? } else { 0 }; + let _children = buf.read_int_id_list()?; + let _redirect_node = if has_redirect { buf.read_varint()? } else { 0 }; // argument node if node_type == 2 { - let name = buf.read_utf()?; - - let parser = BrigadierParser::read_into(buf)?; - - let suggestions_type = if has_suggestions_type { + let _name = buf.read_utf()?; + let _parser = BrigadierParser::read_into(buf)?; + let _suggestions_type = if has_suggestions_type { Some(buf.read_resource_location()?) } else { None @@ -314,7 +312,7 @@ impl McBufReadable for BrigadierNodeStub { } // literal node if node_type == 1 { - let name = buf.read_utf()?; + let _name = buf.read_utf()?; return Ok(BrigadierNodeStub {}); } Ok(BrigadierNodeStub {}) diff --git a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs index c97eacff..e83d1e87 100644 --- a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs @@ -1,5 +1,4 @@ use crate::mc_buf::BitSet; -use azalea_core::{game_type::GameType, resource_location::ResourceLocation}; use packet_macros::{GamePacket, McBufReadable, McBufWritable}; #[derive(Clone, Debug, GamePacket)] diff --git a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs index cd645fe6..ed27ecf3 100755 --- a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs @@ -34,16 +34,16 @@ impl McBufWritable for PlayerAbilitiesFlags { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { let mut byte = 0; if self.invulnerable { - byte = byte | 1; + byte |= 0b1; } if self.flying { - byte = byte | 2; + byte |= 0b10; } if self.can_fly { - byte = byte | 4; + byte |= 0b100; } if self.instant_break { - byte = byte | 8; + byte |= 0b1000; } u8::write_into(&byte, buf) } diff --git a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs index cac4665d..c2bef8fa 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs @@ -43,19 +43,19 @@ impl McBufWritable for RelativeArguments { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { let mut byte = 0; if self.x { - byte = byte | 0b1; + byte |= 0b1; } if self.y { - byte = byte | 0b10; + byte |= 0b10; } if self.z { - byte = byte | 0b100; + byte |= 0b100; } if self.y_rot { - byte = byte | 0b1000; + byte |= 0b1000; } if self.x_rot { - byte = byte | 0b10000; + byte |= 0b10000; } u8::write_into(&byte, buf) } diff --git a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs index 543fb64c..fa0d58f0 100644 --- a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs @@ -1,5 +1,5 @@ use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; -use azalea_core::{resource_location::ResourceLocation, Slot}; +use azalea_core::resource_location::ResourceLocation; use packet_macros::{GamePacket, McBufReadable, McBufWritable}; use std::io::{Read, Write}; @@ -41,7 +41,7 @@ impl McBufWritable for State { } impl McBufReadable for State { fn read_into(buf: &mut impl Read) -> Result { - let state = buf.read_varint()?.try_into().unwrap(); + let state = buf.read_varint()?; Ok(match state { 0 => State::Init, 1 => State::Add, diff --git a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs index 5d288518..ca726c39 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs @@ -123,7 +123,7 @@ impl McBufReadable for EntityDataValue { } impl McBufWritable for EntityDataValue { - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> { todo!(); } } @@ -398,7 +398,7 @@ impl McBufReadable for ParticleData { } impl McBufWritable for ParticleData { - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> { todo!() } } diff --git a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs index d15e10c3..9bdea26e 100644 --- a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs @@ -122,7 +122,7 @@ pub struct Ingredient { } impl McBufWritable for Recipe { - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> { todo!() } } diff --git a/azalea-protocol/src/packets/login/serverbound_key_packet.rs b/azalea-protocol/src/packets/login/serverbound_key_packet.rs index f402d357..2ff8dda6 100644 --- a/azalea-protocol/src/packets/login/serverbound_key_packet.rs +++ b/azalea-protocol/src/packets/login/serverbound_key_packet.rs @@ -1,5 +1,3 @@ -use super::LoginPacket; -use crate::mc_buf::Writable; use packet_macros::LoginPacket; use std::hash::Hash; diff --git a/azalea-protocol/src/write.rs b/azalea-protocol/src/write.rs index 345829c5..9291681c 100755 --- a/azalea-protocol/src/write.rs +++ b/azalea-protocol/src/write.rs @@ -2,10 +2,7 @@ use crate::{mc_buf::Writable, packets::ProtocolPacket, read::MAXIMUM_UNCOMPRESSE use async_compression::tokio::bufread::ZlibEncoder; use azalea_crypto::Aes128CfbEnc; use std::fmt::Debug; -use tokio::{ - io::{AsyncReadExt, AsyncWrite, AsyncWriteExt}, - net::TcpStream, -}; +use tokio::io::{AsyncReadExt, AsyncWrite, AsyncWriteExt}; fn frame_prepender(data: &mut Vec) -> Result, String> { let mut buf = Vec::new(); diff --git a/azalea-world/src/palette.rs b/azalea-world/src/palette.rs index a8ec50c9..69900fe6 100644 --- a/azalea-world/src/palette.rs +++ b/azalea-world/src/palette.rs @@ -35,9 +35,9 @@ impl McBufWritable for PalettedContainer { pub enum Palette { /// ID of the corresponding entry in its global palette SingleValue(u32), - LinearPalette(Vec), - HashmapPalette(Vec), - GlobalPalette, + Linear(Vec), + Hashmap(Vec), + Global, } impl Palette { @@ -47,9 +47,9 @@ impl Palette { ) -> Result { Ok(match bits_per_entry { 0 => Palette::SingleValue(u32::read_into(buf)?), - 1..=4 => Palette::LinearPalette(Vec::::read_into(buf)?), - 5..=8 => Palette::HashmapPalette(Vec::::read_into(buf)?), - _ => Palette::GlobalPalette, + 1..=4 => Palette::Linear(Vec::::read_into(buf)?), + 5..=8 => Palette::Hashmap(Vec::::read_into(buf)?), + _ => Palette::Global, }) } } @@ -60,13 +60,13 @@ impl McBufWritable for Palette { Palette::SingleValue(value) => { value.write_into(buf)?; } - Palette::LinearPalette(values) => { + Palette::Linear(values) => { values.write_into(buf)?; } - Palette::HashmapPalette(values) => { + Palette::Hashmap(values) => { values.write_into(buf)?; } - Palette::GlobalPalette => {} + Palette::Global => {} } Ok(()) } -- cgit v1.2.3 From f0792f25bbbf4ab038b4c1a0cdb4294f3580b16c Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 14 May 2022 20:03:24 -0500 Subject: add derive McBuf to every packet --- azalea-protocol/packet-macros/src/lib.rs | 8 ++------ azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs | 4 ++-- azalea-protocol/src/packets/game/clientbound_add_mob_packet.rs | 4 ++-- azalea-protocol/src/packets/game/clientbound_add_player_packet.rs | 4 ++-- azalea-protocol/src/packets/game/clientbound_animate_packet.rs | 2 +- .../src/packets/game/clientbound_block_update_packet.rs | 4 ++-- .../src/packets/game/clientbound_change_difficulty_packet.rs | 4 ++-- azalea-protocol/src/packets/game/clientbound_chat_packet.rs | 2 +- .../src/packets/game/clientbound_container_set_content_packet.rs | 4 ++-- .../src/packets/game/clientbound_custom_payload_packet.rs | 4 ++-- azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs | 4 ++-- .../src/packets/game/clientbound_entity_event_packet.rs | 4 ++-- .../src/packets/game/clientbound_entity_velocity_packet.rs | 4 ++-- azalea-protocol/src/packets/game/clientbound_game_event_packet.rs | 2 +- .../src/packets/game/clientbound_initialize_border_packet.rs | 4 ++-- azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs | 4 ++-- .../src/packets/game/clientbound_level_chunk_with_light_packet.rs | 2 +- .../src/packets/game/clientbound_level_event_packet.rs | 4 ++-- .../src/packets/game/clientbound_level_particles_packet.rs | 4 ++-- .../src/packets/game/clientbound_light_update_packet.rs | 2 +- azalea-protocol/src/packets/game/clientbound_login_packet.rs | 4 ++-- .../src/packets/game/clientbound_move_entity_pos_packet.rs | 4 ++-- .../src/packets/game/clientbound_move_entity_posrot_packet.rs | 4 ++-- .../src/packets/game/clientbound_move_entity_rot_packet.rs | 4 ++-- .../src/packets/game/clientbound_player_abilities_packet.rs | 4 ++-- .../src/packets/game/clientbound_player_info_packet.rs | 2 +- .../src/packets/game/clientbound_player_position_packet.rs | 4 ++-- azalea-protocol/src/packets/game/clientbound_recipe_packet.rs | 2 +- .../src/packets/game/clientbound_remove_entities_packet.rs | 4 ++-- .../src/packets/game/clientbound_rotate_head_packet.rs | 4 ++-- .../src/packets/game/clientbound_section_blocks_update_packet.rs | 4 ++-- .../src/packets/game/clientbound_set_carried_item_packet.rs | 4 ++-- .../src/packets/game/clientbound_set_chunk_cache_center.rs | 4 ++-- .../packets/game/clientbound_set_default_spawn_position_packet.rs | 4 ++-- .../src/packets/game/clientbound_set_entity_data_packet.rs | 4 ++-- .../src/packets/game/clientbound_set_entity_link_packet.rs | 4 ++-- .../src/packets/game/clientbound_set_experience_packet.rs | 4 ++-- azalea-protocol/src/packets/game/clientbound_set_health_packet.rs | 4 ++-- azalea-protocol/src/packets/game/clientbound_set_time_packet.rs | 4 ++-- azalea-protocol/src/packets/game/clientbound_sound_packet.rs | 2 +- .../src/packets/game/clientbound_teleport_entity_packet.rs | 4 ++-- .../src/packets/game/clientbound_update_advancements_packet.rs | 2 +- .../src/packets/game/clientbound_update_attributes_packet.rs | 2 +- .../src/packets/game/clientbound_update_recipes_packet.rs | 2 +- .../src/packets/game/clientbound_update_tags_packet.rs | 4 ++-- .../src/packets/game/clientbound_update_view_distance_packet.rs | 4 ++-- .../src/packets/game/serverbound_custom_payload_packet.rs | 4 ++-- azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs | 4 ++-- azalea-protocol/src/packets/handshake/client_intention_packet.rs | 4 ++-- .../src/packets/login/clientbound_custom_query_packet.rs | 4 ++-- .../src/packets/login/clientbound_login_disconnect_packet.rs | 4 ++-- azalea-protocol/src/packets/login/serverbound_hello_packet.rs | 4 ++-- azalea-protocol/src/packets/login/serverbound_key_packet.rs | 4 ++-- .../src/packets/status/serverbound_status_request_packet.rs | 4 ++-- code-generator/packetcodegen.py | 4 ++-- 55 files changed, 99 insertions(+), 103 deletions(-) (limited to 'azalea-protocol/src/packets/login') diff --git a/azalea-protocol/packet-macros/src/lib.rs b/azalea-protocol/packet-macros/src/lib.rs index 59fb91eb..f3fe4e40 100755 --- a/azalea-protocol/packet-macros/src/lib.rs +++ b/azalea-protocol/packet-macros/src/lib.rs @@ -182,8 +182,8 @@ fn as_packet_derive(input: TokenStream, state: proc_macro2::TokenStream) -> Toke _ => panic!("#[derive(*Packet)] can only be used on structs with named fields"), }; - let mcbufreadable_impl = create_impl_mcbufreadable(&ident, &data); - let mcbufwritable_impl = create_impl_mcbufwritable(&ident, &data); + let _mcbufreadable_impl = create_impl_mcbufreadable(&ident, &data); + let _mcbufwritable_impl = create_impl_mcbufwritable(&ident, &data); let contents = quote! { impl #ident { @@ -202,10 +202,6 @@ fn as_packet_derive(input: TokenStream, state: proc_macro2::TokenStream) -> Toke Ok(Self::read_into(buf)?.get()) } } - - #mcbufreadable_impl - - #mcbufwritable_impl }; contents.into() diff --git a/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs index 55fbd2e1..9afd151b 100644 --- a/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs @@ -1,7 +1,7 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; use uuid::Uuid; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundAddEntityPacket { #[var] pub id: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_add_mob_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_mob_packet.rs index ab72eb59..bc0ddcef 100644 --- a/azalea-protocol/src/packets/game/clientbound_add_mob_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_add_mob_packet.rs @@ -1,7 +1,7 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; use uuid::Uuid; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundAddMobPacket { #[var] pub id: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs index 8f848c99..f1947d09 100644 --- a/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs @@ -1,7 +1,7 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; use uuid::Uuid; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundAddPlayerPacket { #[var] pub id: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_animate_packet.rs b/azalea-protocol/src/packets/game/clientbound_animate_packet.rs index 6ac4bd99..0bba1a25 100644 --- a/azalea-protocol/src/packets/game/clientbound_animate_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_animate_packet.rs @@ -1,6 +1,6 @@ use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundAnimatePacket { #[var] pub id: u32, diff --git a/azalea-protocol/src/packets/game/clientbound_block_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_block_update_packet.rs index 575b7f46..f068cc7d 100644 --- a/azalea-protocol/src/packets/game/clientbound_block_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_block_update_packet.rs @@ -1,7 +1,7 @@ use azalea_core::BlockPos; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundBlockUpdatePacket { pub pos: BlockPos, // TODO: in vanilla this is a BlockState, but here we just have it as a number. diff --git a/azalea-protocol/src/packets/game/clientbound_change_difficulty_packet.rs b/azalea-protocol/src/packets/game/clientbound_change_difficulty_packet.rs index e12cfff3..edda52d9 100755 --- a/azalea-protocol/src/packets/game/clientbound_change_difficulty_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_change_difficulty_packet.rs @@ -1,7 +1,7 @@ use azalea_core::difficulty::Difficulty; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundChangeDifficultyPacket { pub difficulty: Difficulty, pub locked: bool, diff --git a/azalea-protocol/src/packets/game/clientbound_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_chat_packet.rs index 7a52337e..77c5370c 100644 --- a/azalea-protocol/src/packets/game/clientbound_chat_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_chat_packet.rs @@ -2,7 +2,7 @@ use azalea_chat::component::Component; use packet_macros::{GamePacket, McBuf}; use uuid::Uuid; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundChatPacket { pub message: Component, pub type_: ChatType, diff --git a/azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs b/azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs index aea09e09..d38bbfda 100644 --- a/azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs @@ -1,7 +1,7 @@ use azalea_core::Slot; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundContainerSetContentPacket { pub container_id: u8, #[var] 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 2c56ea2b..b9ccbba4 100755 --- a/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs @@ -1,8 +1,8 @@ use crate::mc_buf::UnsizedByteArray; use azalea_core::resource_location::ResourceLocation; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundCustomPayloadPacket { pub identifier: ResourceLocation, pub data: UnsizedByteArray, diff --git a/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs b/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs index 2e72b19b..c030d512 100644 --- a/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs @@ -1,7 +1,7 @@ use azalea_chat::component::Component; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundDisconnectPacket { pub reason: Component, } diff --git a/azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs index 55e4d419..1b06bff7 100644 --- a/azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs @@ -1,7 +1,7 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; // we can't identify the status in azalea-protocol since they vary depending on the entity -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundEntityEventPacket { pub entity_id: i32, pub entity_status: i8, diff --git a/azalea-protocol/src/packets/game/clientbound_entity_velocity_packet.rs b/azalea-protocol/src/packets/game/clientbound_entity_velocity_packet.rs index 4fc8f86f..07218c4e 100644 --- a/azalea-protocol/src/packets/game/clientbound_entity_velocity_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_entity_velocity_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundEntityVelocityPacket { #[var] pub entity_id: u32, diff --git a/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs index faba0a6e..dd5f08f6 100644 --- a/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs @@ -1,6 +1,6 @@ use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundGameEventPacket { pub event: EventType, pub param: f32, 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 435e43cc..a522eba3 100644 --- a/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundInitializeBorderPacket { pub new_center_x: f64, pub new_center_z: f64, diff --git a/azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs b/azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs index d5dab9a9..18628c86 100644 --- a/azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundKeepAlivePacket { pub id: u64, } diff --git a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs index dab36050..43bda0b6 100644 --- a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs @@ -2,7 +2,7 @@ use packet_macros::{GamePacket, McBuf}; use super::clientbound_light_update_packet::ClientboundLightUpdatePacketData; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundLevelChunkWithLightPacket { pub x: i32, pub z: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_level_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_event_packet.rs index b8572a85..70926268 100644 --- a/azalea-protocol/src/packets/game/clientbound_level_event_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_level_event_packet.rs @@ -1,7 +1,7 @@ use azalea_core::BlockPos; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundLevelEventPacket { pub type_: i32, pub pos: BlockPos, 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 0194d08d..43c3b31a 100644 --- a/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs @@ -1,7 +1,7 @@ use crate::mc_buf::ParticleData; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundLevelParticlesPacket { pub particle_id: u32, pub override_limiter: bool, diff --git a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs index 0c75b356..f04987ac 100644 --- a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs @@ -1,7 +1,7 @@ use crate::mc_buf::BitSet; use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundLightUpdatePacket { pub x: i32, pub z: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_login_packet.rs b/azalea-protocol/src/packets/game/clientbound_login_packet.rs index 9c8b7df1..b4a1b8d4 100755 --- a/azalea-protocol/src/packets/game/clientbound_login_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_login_packet.rs @@ -1,7 +1,7 @@ use azalea_core::{game_type::GameType, resource_location::ResourceLocation}; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundLoginPacket { pub player_id: u32, pub hardcore: bool, diff --git a/azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs b/azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs index c9aff7cb..0fc0104a 100644 --- a/azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundMoveEntityPosPacket { #[var] pub entity_id: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_move_entity_posrot_packet.rs b/azalea-protocol/src/packets/game/clientbound_move_entity_posrot_packet.rs index 645912e7..5fde1b93 100644 --- a/azalea-protocol/src/packets/game/clientbound_move_entity_posrot_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_move_entity_posrot_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundMoveEntityPosRotPacket { #[var] pub entity_id: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs b/azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs index 6ce0faa9..c8d0170b 100644 --- a/azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundMoveEntityRotPacket { #[var] pub entity_id: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs index ed27ecf3..c3387f7f 100755 --- a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs @@ -1,8 +1,8 @@ use crate::mc_buf::{McBufReadable, McBufWritable, Readable}; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; use std::io::{Read, Write}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundPlayerAbilitiesPacket { pub flags: PlayerAbilitiesFlags, pub flying_speed: f32, diff --git a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs index db306ade..cb17f1f5 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs @@ -4,7 +4,7 @@ use packet_macros::{GamePacket, McBuf}; use std::io::{Read, Write}; use uuid::Uuid; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundPlayerInfoPacket { pub action: Action, } diff --git a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs index 796d8334..0457269a 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs @@ -1,8 +1,8 @@ use crate::mc_buf::{McBufReadable, McBufWritable, Readable}; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; use std::io::{Read, Write}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundPlayerPositionPacket { pub x: f64, pub y: f64, diff --git a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs index 9a9623ad..e76504cc 100644 --- a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs @@ -3,7 +3,7 @@ use azalea_core::resource_location::ResourceLocation; use packet_macros::{GamePacket, McBuf}; use std::io::{Read, Write}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundRecipePacket { pub action: State, pub settings: RecipeBookSettings, diff --git a/azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs b/azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs index 265d0c64..8f51596d 100644 --- a/azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundRemoveEntitiesPacket { #[var] pub entity_ids: Vec, diff --git a/azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs b/azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs index d423885d..71b485ae 100644 --- a/azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundRotateHeadPacket { #[var] pub entity_id: u32, diff --git a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs index 91d579a8..6c429edb 100644 --- a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs @@ -1,9 +1,9 @@ use crate::mc_buf::{McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable}; use azalea_core::{ChunkSectionBlockPos, ChunkSectionPos}; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; use std::io::{Read, Write}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSectionBlocksUpdatePacket { pub section_pos: ChunkSectionPos, pub suppress_light_updates: bool, diff --git a/azalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs index 4f0bf575..003b6ccc 100755 --- a/azalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs @@ -1,7 +1,7 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; /// Sent to change the player's slot selection. -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetCarriedItemPacket { pub slot: u8, } diff --git a/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center.rs b/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center.rs index 60f2ab94..7557c16b 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetChunkCacheCenterPacket { #[var] pub x: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs index dad050cc..7ac42c5c 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs @@ -1,7 +1,7 @@ use azalea_core::BlockPos; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetDefaultSpawnPositionPacket { pub pos: BlockPos, pub angle: f32, diff --git a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs index 752b7e6a..8a568689 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs @@ -1,7 +1,7 @@ use crate::mc_buf::EntityMetadata; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetEntityDataPacket { #[var] pub id: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs index 7ee4a43c..e6e3af67 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetEntityLinkPacket { pub source_id: u32, pub dest_id: u32, diff --git a/azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs index 88c306dc..bcb6393d 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetExperiencePacket { pub experience_progress: f32, #[var] diff --git a/azalea-protocol/src/packets/game/clientbound_set_health_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_health_packet.rs index 136ef475..6c75cf63 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_health_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_health_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetHealthPacket { pub health: f32, #[var] diff --git a/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs index 02bf88d7..4cad0693 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetTimePacket { pub game_time: u64, pub day_time: u64, diff --git a/azalea-protocol/src/packets/game/clientbound_sound_packet.rs b/azalea-protocol/src/packets/game/clientbound_sound_packet.rs index 8094227b..797f03de 100644 --- a/azalea-protocol/src/packets/game/clientbound_sound_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_sound_packet.rs @@ -1,6 +1,6 @@ use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSoundPacket { #[var] /// TODO: use the sound registry instead of just being a u32 diff --git a/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs b/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs index ea8788d6..c10db7b9 100644 --- a/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundTeleportEntityPacket { #[var] pub id: u32, diff --git a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs index 0bd18319..daa1ac93 100644 --- a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs @@ -7,7 +7,7 @@ use std::{ io::{Read, Write}, }; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundUpdateAdvancementsPacket { pub reset: bool, pub added: HashMap, diff --git a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs index 2b382c9f..d0e7c9ee 100644 --- a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs @@ -4,7 +4,7 @@ use packet_macros::{GamePacket, McBuf}; use std::io::{Read, Write}; use uuid::Uuid; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundUpdateAttributesPacket { #[var] pub entity_id: u32, diff --git a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs index e7756248..27839919 100644 --- a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs @@ -5,7 +5,7 @@ use packet_macros::{GamePacket, McBuf}; use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundUpdateRecipesPacket { pub recipes: Vec, } 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 f82a4177..60794f03 100755 --- a/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs @@ -1,12 +1,12 @@ use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; use azalea_core::resource_location::ResourceLocation; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; use std::{ collections::HashMap, io::{Read, Write}, }; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundUpdateTagsPacket { pub tags: HashMap>, } 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 fe65d048..8288bd73 100755 --- 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,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundUpdateViewDistancePacket { #[var] pub view_distance: i32, diff --git a/azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs b/azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs index eefafdd1..bef25b59 100644 --- a/azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs @@ -1,8 +1,8 @@ use crate::mc_buf::UnsizedByteArray; use azalea_core::resource_location::ResourceLocation; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ServerboundCustomPayloadPacket { pub identifier: ResourceLocation, pub data: UnsizedByteArray, diff --git a/azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs b/azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs index 740b18e3..c430499e 100644 --- a/azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ServerboundKeepAlivePacket { pub id: u64, } diff --git a/azalea-protocol/src/packets/handshake/client_intention_packet.rs b/azalea-protocol/src/packets/handshake/client_intention_packet.rs index 98caf34c..410c11ab 100755 --- a/azalea-protocol/src/packets/handshake/client_intention_packet.rs +++ b/azalea-protocol/src/packets/handshake/client_intention_packet.rs @@ -1,8 +1,8 @@ use crate::packets::ConnectionProtocol; -use packet_macros::HandshakePacket; +use packet_macros::{HandshakePacket, McBuf}; use std::hash::Hash; -#[derive(Hash, Clone, Debug, HandshakePacket)] +#[derive(Hash, Clone, Debug, McBuf, HandshakePacket)] pub struct ClientIntentionPacket { #[var] pub protocol_version: u32, 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 fc5dd1a2..1b1da87a 100755 --- a/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs @@ -1,9 +1,9 @@ use crate::mc_buf::UnsizedByteArray; use azalea_core::resource_location::ResourceLocation; -use packet_macros::LoginPacket; +use packet_macros::{LoginPacket, McBuf}; use std::hash::Hash; -#[derive(Hash, Clone, Debug, LoginPacket)] +#[derive(Hash, Clone, Debug, McBuf, LoginPacket)] pub struct ClientboundCustomQueryPacket { #[var] pub transaction_id: u32, diff --git a/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs b/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs index 28d91c79..9ab09e3b 100644 --- a/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs @@ -1,7 +1,7 @@ use azalea_chat::component::Component; -use packet_macros::LoginPacket; +use packet_macros::{LoginPacket, McBuf}; -#[derive(Clone, Debug, LoginPacket)] +#[derive(Clone, Debug, McBuf, LoginPacket)] pub struct ClientboundLoginDisconnectPacket { pub reason: Component, } diff --git a/azalea-protocol/src/packets/login/serverbound_hello_packet.rs b/azalea-protocol/src/packets/login/serverbound_hello_packet.rs index eb6a4065..5cb660ed 100755 --- a/azalea-protocol/src/packets/login/serverbound_hello_packet.rs +++ b/azalea-protocol/src/packets/login/serverbound_hello_packet.rs @@ -1,7 +1,7 @@ -use packet_macros::LoginPacket; +use packet_macros::{LoginPacket, McBuf}; use std::hash::Hash; -#[derive(Hash, Clone, Debug, LoginPacket)] +#[derive(Hash, Clone, Debug, McBuf, LoginPacket)] pub struct ServerboundHelloPacket { pub username: String, } diff --git a/azalea-protocol/src/packets/login/serverbound_key_packet.rs b/azalea-protocol/src/packets/login/serverbound_key_packet.rs index 2ff8dda6..9100823d 100644 --- a/azalea-protocol/src/packets/login/serverbound_key_packet.rs +++ b/azalea-protocol/src/packets/login/serverbound_key_packet.rs @@ -1,7 +1,7 @@ -use packet_macros::LoginPacket; +use packet_macros::{LoginPacket, McBuf}; use std::hash::Hash; -#[derive(Hash, Clone, Debug, LoginPacket)] +#[derive(Hash, Clone, Debug, McBuf, LoginPacket)] pub struct ServerboundKeyPacket { pub shared_secret: Vec, pub nonce: Vec, diff --git a/azalea-protocol/src/packets/status/serverbound_status_request_packet.rs b/azalea-protocol/src/packets/status/serverbound_status_request_packet.rs index c15673d9..3369e6a9 100755 --- a/azalea-protocol/src/packets/status/serverbound_status_request_packet.rs +++ b/azalea-protocol/src/packets/status/serverbound_status_request_packet.rs @@ -1,4 +1,4 @@ -use packet_macros::StatusPacket; +use packet_macros::{McBuf, StatusPacket}; -#[derive(Clone, Debug, StatusPacket)] +#[derive(Clone, Debug, McBuf, StatusPacket)] pub struct ServerboundStatusRequestPacket {} diff --git a/code-generator/packetcodegen.py b/code-generator/packetcodegen.py index fbb38eeb..b84877e4 100644 --- a/code-generator/packetcodegen.py +++ b/code-generator/packetcodegen.py @@ -84,8 +84,8 @@ def generate(burger_packets, mappings: Mappings, target_packet_id, target_packet generated_packet_code = [] uses = set() generated_packet_code.append( - f'#[derive(Clone, Debug, {to_camel_case(state)}Packet)]') - uses.add(f'packet_macros::{to_camel_case(state)}Packet') + f'#[derive(Clone, Debug, McBuf, {to_camel_case(state)}Packet)]') + uses.add(f'packet_macros::{{to_camel_case(state)}Packet, McBuf}') obfuscated_class_name = packet['class'].split('.')[0].split('$')[0] class_name = mappings.get_class( -- cgit v1.2.3