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 --- azalea-protocol/src/mc_buf/write.rs | 128 +++++++++++++----------------------- 1 file changed, 45 insertions(+), 83 deletions(-) (limited to 'azalea-protocol/src/mc_buf/write.rs') diff --git a/azalea-protocol/src/mc_buf/write.rs b/azalea-protocol/src/mc_buf/write.rs index 57ec3a48..34bcafeb 100755 --- a/azalea-protocol/src/mc_buf/write.rs +++ b/azalea-protocol/src/mc_buf/write.rs @@ -8,49 +8,10 @@ use byteorder::{BigEndian, WriteBytesExt}; use std::io::Write; use uuid::Uuid; -pub trait Writable { +pub trait Writable: Write { fn write_list(&mut self, list: &[T], writer: F) -> Result<(), std::io::Error> where F: FnOnce(&mut Self, &T) -> Result<(), std::io::Error> + Copy, - T: Sized, - Self: Sized; - fn write_int_id_list(&mut self, list: &Vec) -> Result<(), std::io::Error>; - fn write_map( - &mut self, - map: Vec<(KT, VT)>, - key_writer: KF, - value_writer: VF, - ) -> Result<(), std::io::Error> - where - KF: Fn(&mut Self, KT) -> Result<(), std::io::Error> + Copy, - VF: Fn(&mut Self, VT) -> Result<(), std::io::Error> + Copy, - Self: Sized; - - fn write_byte(&mut self, n: u8) -> Result<(), std::io::Error>; - fn write_bytes(&mut self, bytes: &[u8]) -> Result<(), std::io::Error>; - fn write_varint(&mut self, value: i32) -> Result<(), std::io::Error>; - fn write_utf_with_len(&mut self, string: &str, len: usize) -> Result<(), std::io::Error>; - fn write_utf(&mut self, string: &str) -> Result<(), std::io::Error>; - fn write_short(&mut self, n: i16) -> Result<(), std::io::Error>; - fn write_byte_array(&mut self, bytes: &[u8]) -> Result<(), std::io::Error>; - fn write_int(&mut self, n: i32) -> Result<(), std::io::Error>; - fn write_boolean(&mut self, b: bool) -> Result<(), std::io::Error>; - fn write_nbt(&mut self, nbt: &azalea_nbt::Tag) -> Result<(), std::io::Error>; - fn write_long(&mut self, n: i64) -> Result<(), std::io::Error>; - fn write_resource_location( - &mut self, - location: &ResourceLocation, - ) -> Result<(), std::io::Error>; - fn write_float(&mut self, n: f32) -> Result<(), std::io::Error>; - fn write_double(&mut self, n: f64) -> Result<(), std::io::Error>; - fn write_uuid(&mut self, uuid: &Uuid) -> Result<(), std::io::Error>; -} - -impl Writable for Vec { - fn write_list(&mut self, list: &[T], writer: F) -> Result<(), std::io::Error> - where - F: FnOnce(&mut Self, &T) -> Result<(), std::io::Error> + Copy, - Self: Sized, { self.write_varint(list.len() as i32)?; for item in list { @@ -72,7 +33,6 @@ impl Writable for Vec { where KF: Fn(&mut Self, KT) -> Result<(), std::io::Error> + Copy, VF: Fn(&mut Self, VT) -> Result<(), std::io::Error> + Copy, - Self: Sized, { self.write_varint(map.len() as i32)?; for (key, value) in map { @@ -87,7 +47,7 @@ impl Writable for Vec { } fn write_bytes(&mut self, bytes: &[u8]) -> Result<(), std::io::Error> { - self.extend_from_slice(bytes); + self.write_all(bytes); Ok(()) } @@ -140,7 +100,10 @@ impl Writable for Vec { self.write_byte(if b { 1 } else { 0 }) } - fn write_nbt(&mut self, nbt: &azalea_nbt::Tag) -> Result<(), std::io::Error> { + fn write_nbt(&mut self, nbt: &azalea_nbt::Tag) -> Result<(), std::io::Error> + where + Self: Sized, + { nbt.write(self) .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string())) } @@ -164,7 +127,10 @@ impl Writable for Vec { self.write_utf(&location.to_string()) } - fn write_uuid(&mut self, uuid: &Uuid) -> Result<(), std::io::Error> { + fn write_uuid(&mut self, uuid: &Uuid) -> Result<(), std::io::Error> + where + Self: Sized, + { let [a, b, c, d] = uuid.to_int_array(); a.write_into(self)?; b.write_into(self)?; @@ -174,34 +140,30 @@ impl Writable for Vec { } } -pub trait McBufWritable -where - Self: Sized, -{ - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error>; +impl Writable for W {} + +pub trait McBufWritable { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error>; } -pub trait McBufVarintWritable -where - Self: Sized, -{ - fn varint_write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error>; +pub trait McBufVarintWritable { + fn varint_write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error>; } impl McBufWritable for i32 { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { Writable::write_int(buf, *self) } } impl McBufVarintWritable for i32 { - fn varint_write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn varint_write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_varint(*self) } } impl McBufWritable for UnsizedByteArray { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_bytes(self) } } @@ -209,132 +171,132 @@ impl McBufWritable for UnsizedByteArray { // TODO: use specialization when that gets stabilized into rust // to optimize for Vec byte arrays impl McBufWritable for Vec { - default fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + default fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_list(self, |buf, i| T::write_into(i, buf)) } } impl McBufWritable for Vec { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_byte_array(self) } } // string impl McBufWritable for String { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_utf(self) } } // ResourceLocation impl McBufWritable for ResourceLocation { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_resource_location(self) } } // u32 impl McBufWritable for u32 { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { i16::write_into(&(*self as i16), buf) } } // u32 varint impl McBufVarintWritable for u32 { - fn varint_write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn varint_write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { i32::varint_write_into(&(*self as i32), buf) } } // u16 impl McBufWritable for u16 { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { i16::write_into(&(*self as i16), buf) } } // u16 varint impl McBufVarintWritable for u16 { - fn varint_write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn varint_write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { i32::varint_write_into(&(*self as i32), buf) } } // u8 impl McBufWritable for u8 { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_byte(*self) } } // i16 impl McBufWritable for i16 { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { Writable::write_short(buf, *self) } } // i64 impl McBufWritable for i64 { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { Writable::write_long(buf, *self) } } // u64 impl McBufWritable for u64 { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { i64::write_into(&(*self as i64), buf) } } // bool impl McBufWritable for bool { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_boolean(*self) } } // i8 impl McBufWritable for i8 { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_byte(*self as u8) } } // f32 impl McBufWritable for f32 { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_float(*self) } } // f64 impl McBufWritable for f64 { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_double(*self) } } // GameType impl McBufWritable for GameType { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { u8::write_into(&self.to_id(), buf) } } // Option impl McBufWritable for Option { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_byte(GameType::to_optional_id(self) as u8) } } // Option impl McBufWritable for Option { - default fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + default fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { if let Some(s) = self { buf.write_boolean(true)?; s.write_into(buf)?; @@ -347,14 +309,14 @@ impl McBufWritable for Option { // azalea_nbt::Tag impl McBufWritable for azalea_nbt::Tag { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_nbt(self) } } // Difficulty impl McBufWritable for Difficulty { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { u8::write_into(&self.id(), buf) } } @@ -371,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 Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { // component doesn't have serialize implemented yet todo!() } @@ -379,7 +341,7 @@ impl McBufWritable for Component { // Slot impl McBufWritable for Slot { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { match self { Slot::Empty => buf.write_byte(0)?, Slot::Present(i) => { @@ -395,7 +357,7 @@ impl McBufWritable for Slot { // Slot impl McBufWritable for Uuid { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_uuid(self)?; Ok(()) @@ -404,7 +366,7 @@ impl McBufWritable for Uuid { // BlockPos impl McBufWritable for BlockPos { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_long( (((self.x & 0x3FFFFFF) as i64) << 38) | (((self.z & 0x3FFFFFF) as i64) << 12) @@ -415,7 +377,7 @@ impl McBufWritable for BlockPos { // Direction impl McBufWritable for Direction { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_varint(*self as i32) } } -- 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/mc_buf/write.rs') 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 4dac004635e50682d9ebe8812fdf654a0c1808f1 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 5 May 2022 22:12:54 -0500 Subject: Fix chunk decoding --- azalea-protocol/src/mc_buf/mod.rs | 2 ++ azalea-protocol/src/mc_buf/read.rs | 11 ++++++++ azalea-protocol/src/mc_buf/write.rs | 7 +++++ azalea-world/src/bit_storage.rs | 9 ++++--- azalea-world/src/lib.rs | 19 ++++++++++--- azalea-world/src/palette.rs | 54 ++++++++++++++++++++++++++++++------- bot/src/main.rs | 2 +- 7 files changed, 85 insertions(+), 19 deletions(-) (limited to 'azalea-protocol/src/mc_buf/write.rs') diff --git a/azalea-protocol/src/mc_buf/mod.rs b/azalea-protocol/src/mc_buf/mod.rs index a82334fb..debf2991 100755 --- a/azalea-protocol/src/mc_buf/mod.rs +++ b/azalea-protocol/src/mc_buf/mod.rs @@ -12,6 +12,8 @@ pub use write::{McBufVarintWritable, McBufWritable, Writable}; const MAX_STRING_LENGTH: u16 = 32767; // const MAX_COMPONENT_STRING_LENGTH: u32 = 262144; +// TODO: maybe get rid of the readable/writable traits so there's not two ways to do the same thing and improve McBufReadable/McBufWritable + // TODO: have a definitions.rs in mc_buf that contains UnsizedByteArray and BitSet /// A Vec that isn't prefixed by a VarInt with the size. diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs index e1ae321c..a8c44bdf 100755 --- a/azalea-protocol/src/mc_buf/read.rs +++ b/azalea-protocol/src/mc_buf/read.rs @@ -255,6 +255,17 @@ impl McBufVarintReadable for i32 { } } +impl McBufVarintReadable for Vec { + fn varint_read_into(buf: &mut impl Read) -> Result { + let length = u32::varint_read_into(buf)?; + let mut vec = Vec::with_capacity(length as usize); + for _ in 0..length { + vec.push(T::varint_read_into(buf)?); + } + Ok(vec) + } +} + impl McBufReadable for UnsizedByteArray { fn read_into(buf: &mut impl Read) -> Result { Ok(UnsizedByteArray(buf.read_bytes()?)) diff --git a/azalea-protocol/src/mc_buf/write.rs b/azalea-protocol/src/mc_buf/write.rs index 3a4a02f8..cc5f2284 100755 --- a/azalea-protocol/src/mc_buf/write.rs +++ b/azalea-protocol/src/mc_buf/write.rs @@ -210,6 +210,13 @@ impl McBufVarintWritable for u32 { } } +// Vec varint +impl McBufVarintWritable for Vec { + fn varint_write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + buf.write_list(self, |buf, i| i.varint_write_into(buf)) + } +} + // u16 impl McBufWritable for u16 { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { diff --git a/azalea-world/src/bit_storage.rs b/azalea-world/src/bit_storage.rs index 5ced67fe..9cc3a053 100644 --- a/azalea-world/src/bit_storage.rs +++ b/azalea-world/src/bit_storage.rs @@ -1,4 +1,4 @@ -use std::{error::Error, fmt, ops::Index}; +use std::{error::Error, fmt}; // this is from minecraft's code // yeah idk either @@ -70,6 +70,7 @@ const MAGIC: [(i32, i32, i32); 64] = [ ]; /// A compact list of integers with the given number of bits per entry. +#[derive(Clone)] pub struct BitStorage { data: Vec, bits: usize, @@ -135,7 +136,7 @@ impl BitStorage { pub fn cell_index(&self, index: u64) -> usize { let first = self.divide_mul as u64; - let second = self.divide_mul as u64; + let second = self.divide_add as u64; (index * first + second >> 32 >> self.divide_shift) .try_into() @@ -182,8 +183,8 @@ mod tests { let data = [ 1, 2, 2, 3, 4, 4, 5, 6, 6, 4, 8, 0, 7, 4, 3, 13, 15, 16, 9, 14, 10, 12, 0, 2, ]; - let expected_compact: [u64; 2] = [0x0020863148418841, 0x01018A7260F68C87]; - let storage = BitStorage::new(5, data.len(), Some(expected_compact.to_vec())).unwrap(); + let compact_data: [u64; 2] = [0x0020863148418841, 0x01018A7260F68C87]; + let storage = BitStorage::new(5, data.len(), Some(compact_data.to_vec())).unwrap(); for (i, expected) in data.iter().enumerate() { assert_eq!(storage.get(i), *expected); diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs index 54961401..abeac181 100644 --- a/azalea-world/src/lib.rs +++ b/azalea-world/src/lib.rs @@ -11,6 +11,8 @@ use std::{ sync::{Arc, Mutex}, }; +use crate::palette::PalettedContainerType; + #[cfg(test)] mod tests { #[test] @@ -43,7 +45,7 @@ impl World { // let existing_chunk = &self.storage[pos]; let chunk = Arc::new(Mutex::new(Chunk::read_with_world(data, self)?)); - println!("Loaded chunk {:?}", chunk); + println!("Loaded chunk {:?}", pos); self.storage[pos] = Some(chunk); Ok(()) @@ -121,7 +123,9 @@ impl Chunk { pub fn read_with_world_height(buf: &mut impl Read, world_height: u32) -> Result { let section_count = world_height / SECTION_HEIGHT; let mut sections = Vec::with_capacity(section_count as usize); - for _ in 0..section_count { + println!("\n\nreading {} sections", section_count); + for i in 0..section_count { + println!("reading section #{}", i); let section = Section::read_into(buf)?; sections.push(section); } @@ -148,8 +152,15 @@ pub struct Section { impl McBufReadable for Section { fn read_into(buf: &mut impl Read) -> Result { let block_count = u16::read_into(buf)?; - let states = PalettedContainer::read_into(buf)?; - let biomes = PalettedContainer::read_into(buf)?; + println!("block count: {}\n", block_count); + // assert!( + // block_count <= 16 * 16 * 16, + // "A section has more blocks than what should be possible. This is a bug!" + // ); + let states = PalettedContainer::read_with_type(buf, &PalettedContainerType::BlockStates)?; + println!("! read states, reading biomes next"); + let biomes = PalettedContainer::read_with_type(buf, &PalettedContainerType::Biomes)?; + println!(); Ok(Section { block_count, states, diff --git a/azalea-world/src/palette.rs b/azalea-world/src/palette.rs index 69900fe6..47354c94 100644 --- a/azalea-world/src/palette.rs +++ b/azalea-world/src/palette.rs @@ -1,20 +1,43 @@ +use azalea_protocol::mc_buf::{ + McBufReadable, McBufVarintReadable, McBufWritable, Readable, Writable, +}; use std::io::{Read, Write}; -use azalea_protocol::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; +#[derive(Clone, Debug, Copy)] +pub enum PalettedContainerType { + Biomes, + BlockStates, +} #[derive(Clone, Debug)] pub struct PalettedContainer { pub bits_per_entry: u8, pub palette: Palette, /// Compacted list of indices pointing to entry IDs in the Palette. - pub data: Vec, + pub data: Vec, } -impl McBufReadable for PalettedContainer { - fn read_into(buf: &mut impl Read) -> Result { +impl PalettedContainer { + pub fn read_with_type( + buf: &mut impl Read, + type_: &'static PalettedContainerType, + ) -> Result { let bits_per_entry = buf.read_byte()?; - let palette = Palette::read_with_bits_per_entry(buf, bits_per_entry)?; - let data = Vec::::read_into(buf)?; + let palette = match type_ { + PalettedContainerType::BlockStates => { + Palette::block_states_read_with_bits_per_entry(buf, bits_per_entry)? + } + PalettedContainerType::Biomes => { + Palette::biomes_read_with_bits_per_entry(buf, bits_per_entry)? + } + }; + + let data = Vec::::read_into(buf)?; + debug_assert!( + bits_per_entry != 0 || data.is_empty(), + "Bits per entry is 0 but data is not empty." + ); + Ok(PalettedContainer { bits_per_entry, palette, @@ -41,14 +64,25 @@ pub enum Palette { } impl Palette { - pub fn read_with_bits_per_entry( + pub fn block_states_read_with_bits_per_entry( + buf: &mut impl Read, + bits_per_entry: u8, + ) -> Result { + Ok(match bits_per_entry { + 0 => Palette::SingleValue(u32::varint_read_into(buf)?), + 1..=4 => Palette::Linear(Vec::::varint_read_into(buf)?), + 5..=8 => Palette::Hashmap(Vec::::varint_read_into(buf)?), + _ => Palette::Global, + }) + } + + pub fn biomes_read_with_bits_per_entry( buf: &mut impl Read, bits_per_entry: u8, ) -> Result { Ok(match bits_per_entry { - 0 => Palette::SingleValue(u32::read_into(buf)?), - 1..=4 => Palette::Linear(Vec::::read_into(buf)?), - 5..=8 => Palette::Hashmap(Vec::::read_into(buf)?), + 0 => Palette::SingleValue(u32::varint_read_into(buf)?), + 1..=3 => Palette::Linear(Vec::::varint_read_into(buf)?), _ => Palette::Global, }) } diff --git a/bot/src/main.rs b/bot/src/main.rs index 167f4edc..7cf056bf 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -5,7 +5,7 @@ async fn main() { println!("Hello, world!"); // let address = "95.111.249.143:10000"; - let address = "172.23.192.1:65111"; + let address = "172.23.192.1:62522"; // let response = azalea_client::ping::ping_server(&address.try_into().unwrap()) // .await // .unwrap(); -- cgit v1.2.3 From 42f86f73f256c0219a923c5ff67a509e7a8a898d Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 14 May 2022 19:14:34 -0500 Subject: add unhandled ClientboundSectionBlocksUpdatePacket --- azalea-client/src/connect.rs | 3 +++ azalea-protocol/src/mc_buf/read.rs | 14 +++++++++++++- azalea-protocol/src/mc_buf/write.rs | 13 ++++++++++++- .../game/clientbound_section_blocks_update_packet.rs | 10 ++++++++++ azalea-protocol/src/packets/game/mod.rs | 2 ++ bot/src/main.rs | 4 ++-- 6 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs (limited to 'azalea-protocol/src/mc_buf/write.rs') diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index 8d2e9dc1..48fd16f2 100755 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -373,6 +373,9 @@ impl Client { GamePacket::ClientboundAnimatePacket(p) => { println!("Got animate packet {:?}", p); } + GamePacket::ClientboundSectionBlocksUpdatePacket(p) => { + println!("Got section blocks update packet {:?}", p); + } _ => panic!("Unexpected packet {:?}", packet), } } diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs index ebafad92..1c4fbd6f 100644 --- a/azalea-protocol/src/mc_buf/read.rs +++ b/azalea-protocol/src/mc_buf/read.rs @@ -2,7 +2,7 @@ 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, + serializable_uuid::SerializableUuid, BlockPos, ChunkSectionPos, Direction, Slot, SlotData, }; use byteorder::{ReadBytesExt, BE}; use serde::Deserialize; @@ -518,3 +518,15 @@ impl McBufReadable for Direction { } } } + +// ChunkSectionPos +impl McBufReadable for ChunkSectionPos { + fn read_into(buf: &mut impl Read) -> Result { + let long = i64::read_into(buf)?; + Ok(ChunkSectionPos { + x: (long >> 42) as i32, + y: (long << 44 >> 44) as i32, + z: (long << 22 >> 42) as i32, + }) + } +} diff --git a/azalea-protocol/src/mc_buf/write.rs b/azalea-protocol/src/mc_buf/write.rs index 7fe61752..c46297a6 100644 --- a/azalea-protocol/src/mc_buf/write.rs +++ b/azalea-protocol/src/mc_buf/write.rs @@ -2,7 +2,7 @@ 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, + serializable_uuid::SerializableUuid, BlockPos, ChunkSectionPos, Direction, Slot, }; use byteorder::{BigEndian, WriteBytesExt}; use std::{collections::HashMap, io::Write}; @@ -425,3 +425,14 @@ impl McBufWritable for Direction { buf.write_varint(*self as i32) } } + +// ChunkSectionPos +impl McBufWritable for ChunkSectionPos { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + let long = (((self.x & 0x3FFFFF) as i64) << 42) + | (self.y & 0xFFFFF) as i64 + | (((self.z & 0x3FFFFF) as i64) << 20); + long.write_into(buf)?; + Ok(()) + } +} 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 new file mode 100644 index 00000000..f220b07f --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs @@ -0,0 +1,10 @@ +use azalea_core::ChunkSectionPos; +use packet_macros::GamePacket; + +#[derive(Clone, Debug, GamePacket)] +pub struct ClientboundSectionBlocksUpdatePacket { + pub section_pos: ChunkSectionPos, + pub suppress_light_updates: bool, + #[var] + pub states: Vec, +} diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs index 0391ee10..66c55cd2 100755 --- a/azalea-protocol/src/packets/game/mod.rs +++ b/azalea-protocol/src/packets/game/mod.rs @@ -26,6 +26,7 @@ pub mod clientbound_player_position_packet; pub mod clientbound_recipe_packet; pub mod clientbound_remove_entities_packet; pub mod clientbound_rotate_head_packet; +pub mod clientbound_section_blocks_update_packet; pub mod clientbound_set_carried_item_packet; pub mod clientbound_set_chunk_cache_center; pub mod clientbound_set_default_spawn_position_packet; @@ -80,6 +81,7 @@ declare_state_packets!( 0x39: clientbound_recipe_packet::ClientboundRecipePacket, 0x3a: clientbound_remove_entities_packet::ClientboundRemoveEntitiesPacket, 0x3e: clientbound_rotate_head_packet::ClientboundRotateHeadPacket, + 0x3f: clientbound_section_blocks_update_packet::ClientboundSectionBlocksUpdatePacket, 0x48: clientbound_set_carried_item_packet::ClientboundSetCarriedItemPacket, 0x49: clientbound_set_chunk_cache_center::ClientboundSetChunkCacheCenterPacket, 0x4a: clientbound_update_view_distance_packet::ClientboundUpdateViewDistancePacket, diff --git a/bot/src/main.rs b/bot/src/main.rs index 1f2cb6e1..76a5a15d 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -1,12 +1,12 @@ use azalea_client::{Account, Event}; -use azalea_core::{BlockPos, ChunkPos}; +use azalea_core::BlockPos; #[tokio::main] async fn main() { println!("Hello, world!"); // let address = "95.111.249.143:10000"; - let address = "192.168.2.234:62840"; + let address = "192.168.2.234:50736"; // let response = azalea_client::ping::ping_server(&address.try_into().unwrap()) // .await // .unwrap(); -- cgit v1.2.3