diff options
| author | mat <github@matdoes.dev> | 2022-04-21 15:25:46 +0000 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-04-21 15:25:46 +0000 |
| commit | 2c848ebaa59781462aba6da428c8dfcc51dbacf8 (patch) | |
| tree | 5428faac33031b213094239ae60271f1d109eaa5 | |
| parent | 298d30ad08d5efe8c94f1865909bafc220a8cfac (diff) | |
| download | azalea-drasl-2c848ebaa59781462aba6da428c8dfcc51dbacf8.tar.xz | |
Set carried item and update tags packets
| -rw-r--r-- | azalea-client/src/connect.rs | 7 | ||||
| -rw-r--r-- | azalea-protocol/packet-macros/src/lib.rs | 7 | ||||
| -rw-r--r-- | azalea-protocol/src/mc_buf/write.rs | 4 | ||||
| -rw-r--r-- | azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs | 2 | ||||
| -rw-r--r-- | azalea-protocol/src/packets/game/mod.rs | 6 | ||||
| -rw-r--r-- | azalea-protocol/src/packets/status/serverbound_status_request_packet.rs | 21 | ||||
| -rw-r--r-- | bot/src/main.rs | 6 |
7 files changed, 22 insertions, 31 deletions
diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index f19c67c2..3f0a8560 100644 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -76,10 +76,15 @@ pub async fn join_server(address: &ServerAddress) -> Result<(), String> { GamePacket::ClientboundDeclareCommandsPacket(p) => { println!("Got declare commands packet {:?}", p); } - GamePacket::ClientboundPlayerAbilitiesPacket(p) => { println!("Got player abilities packet {:?}", p); } + GamePacket::ClientboundSetCarriedItemPacket(p) => { + println!("Got set carried item packet {:?}", p); + } + GamePacket::ClientboundUpdateTagsPacket(p) => { + println!("Got update tags packet {:?}", p); + } }, Err(e) => { println!("Error: {:?}", e); diff --git a/azalea-protocol/packet-macros/src/lib.rs b/azalea-protocol/packet-macros/src/lib.rs index bdb83871..45df7e81 100644 --- a/azalea-protocol/packet-macros/src/lib.rs +++ b/azalea-protocol/packet-macros/src/lib.rs @@ -75,7 +75,7 @@ fn as_packet_derive(input: TokenStream, state: proc_macro2::TokenStream) -> Toke .collect::<Vec<_>>(); let read_field_names = named.iter().map(|f| &f.ident).collect::<Vec<_>>(); - let gen = quote! { + quote! { impl #ident { pub fn get(self) -> #state { #state::#ident(self) @@ -95,9 +95,8 @@ fn as_packet_derive(input: TokenStream, state: proc_macro2::TokenStream) -> Toke }.get()) } } - }; - - gen.into() + } + .into() } #[proc_macro_derive(GamePacket, attributes(varint))] diff --git a/azalea-protocol/src/mc_buf/write.rs b/azalea-protocol/src/mc_buf/write.rs index 07605b16..9330dccb 100644 --- a/azalea-protocol/src/mc_buf/write.rs +++ b/azalea-protocol/src/mc_buf/write.rs @@ -14,7 +14,7 @@ pub trait Writable { F: FnOnce(&mut Self, &T) -> Result<(), std::io::Error> + Copy, T: Sized, Self: Sized; - fn write_int_id_list(&mut self, list: Vec<i32>) -> Result<(), std::io::Error>; + fn write_int_id_list(&mut self, list: &Vec<i32>) -> Result<(), std::io::Error>; fn write_map<KF, VF, KT, VT>( &mut self, map: Vec<(KT, VT)>, @@ -58,7 +58,7 @@ impl Writable for Vec<u8> { Ok(()) } - fn write_int_id_list(&mut self, list: Vec<i32>) -> Result<(), std::io::Error> { + fn write_int_id_list(&mut self, list: &Vec<i32>) -> Result<(), std::io::Error> { self.write_list(&list, |buf, n| buf.write_varint(*n)) } 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 402923c9..f4f528cf 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs @@ -21,7 +21,6 @@ pub struct PlayerAbilitiesFlags { pub instant_break: bool, } -// Difficulty #[async_trait] impl McBufReadable for PlayerAbilitiesFlags { async fn read_into<R>(buf: &mut R) -> Result<Self, String> @@ -38,7 +37,6 @@ impl McBufReadable for PlayerAbilitiesFlags { } } -// Difficulty impl McBufWritable for PlayerAbilitiesFlags { fn write_into(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { let mut byte = 0; diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs index 38630a0e..e150606c 100644 --- a/azalea-protocol/src/packets/game/mod.rs +++ b/azalea-protocol/src/packets/game/mod.rs @@ -3,6 +3,8 @@ pub mod clientbound_custom_payload_packet; pub mod clientbound_declare_commands_packet; pub mod clientbound_login_packet; pub mod clientbound_player_abilities_packet; +pub mod clientbound_set_carried_item_packet; +pub mod clientbound_update_tags_packet; pub mod clientbound_update_view_distance_packet; use packet_macros::declare_state_packets; @@ -16,6 +18,8 @@ declare_state_packets!( 0x18: clientbound_custom_payload_packet::ClientboundCustomPayloadPacket, 0x26: clientbound_login_packet::ClientboundLoginPacket, 0x32: clientbound_player_abilities_packet::ClientboundPlayerAbilitiesPacket, - 0x4a: clientbound_update_view_distance_packet::ClientboundUpdateViewDistancePacket + 0x48: clientbound_set_carried_item_packet::ClientboundSetCarriedItemPacket, + 0x4a: clientbound_update_view_distance_packet::ClientboundUpdateViewDistancePacket, + 0x67: clientbound_update_tags_packet::ClientboundUpdateTagsPacket } ); 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 af98f7cb..e77687ec 100644 --- a/azalea-protocol/src/packets/status/serverbound_status_request_packet.rs +++ b/azalea-protocol/src/packets/status/serverbound_status_request_packet.rs @@ -1,22 +1,5 @@ +use packet_macros::StatusPacket; use std::hash::Hash; -use super::StatusPacket; - -#[derive(Hash, Clone, Debug)] +#[derive(Clone, Debug, StatusPacket)] pub struct ServerboundStatusRequestPacket {} - -impl ServerboundStatusRequestPacket { - pub fn get(self) -> StatusPacket { - StatusPacket::ServerboundStatusRequestPacket(self) - } - - pub fn write(&self, _buf: &mut Vec<u8>) -> Result<(), std::io::Error> { - panic!("ServerboundStatusRequestPacket::write not implemented") - } - - pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>( - _buf: &mut T, - ) -> Result<StatusPacket, String> { - Err("ServerboundStatusRequestPacket::read not implemented".to_string()) - } -} diff --git a/bot/src/main.rs b/bot/src/main.rs index 1041e765..957b3cbc 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -1,4 +1,5 @@ use azalea_client::connect::join_server; +use azalea_client::ping::ping_server; #[tokio::main] async fn main() { @@ -6,7 +7,8 @@ async fn main() { let address = "95.111.249.143:10000"; // let address = "localhost:63482"; - let _response = join_server(&address.try_into().unwrap()).await.unwrap(); - // println!("{}", response.description.to_ansi(None)); + let response = ping_server(&address.try_into().unwrap()).await.unwrap(); + // let _response = join_server(&address.try_into().unwrap()).await.unwrap(); + println!("{}", response.description.to_ansi(None)); println!("connected"); } |
