diff --git a/README.md b/README.md index c307bd77..1fcc3097 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A collection of Rust crates primarily for creating Minecraft bots.

-*Currently supported Minecraft version: `1.19.1-rc2`.* +*Currently supported Minecraft version: `1.19.1`.* I named this Azalea because it sounds like a cool word and this is a cool library. This project was heavily inspired by PrismarineJS. diff --git a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs index 1b71ccea..68f0ea21 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs @@ -1,7 +1,9 @@ -use azalea_buf::McBuf; +use azalea_buf::{BitSet, McBuf, McBufReadable, McBufVarWritable}; +use azalea_buf::{McBufVarReadable, McBufWritable}; use azalea_chat::component::Component; use azalea_crypto::{MessageSignature, SignedMessageHeader}; use packet_macros::GamePacket; +use std::io::{Read, Write}; use uuid::Uuid; #[derive(Clone, Debug, McBuf, GamePacket)] @@ -25,7 +27,7 @@ pub enum ChatType { pub struct ChatTypeBound { pub chat_type: ChatType, pub name: Component, - pub target_name: Component, + pub target_name: Option, } #[derive(Clone, Debug, McBuf)] @@ -34,6 +36,7 @@ pub struct PlayerChatMessage { pub header_signature: MessageSignature, pub signed_body: SignedMessageBody, pub unsigned_content: Option, + pub filter_mask: FilterMask, } #[derive(Clone, Debug, McBuf)] @@ -62,3 +65,35 @@ pub struct ChatMessageContent { /// Only sent if the decorated message is different than the plain. pub decorated: Option, } + +#[derive(Clone, Debug)] +pub enum FilterMask { + PassThrough, + FullyFiltered, + PartiallyFiltered(BitSet), +} + +impl McBufReadable for FilterMask { + fn read_from(buf: &mut impl Read) -> Result { + let filter_mask = u32::var_read_from(buf)?; + match filter_mask { + 0 => Ok(FilterMask::PassThrough), + 1 => Ok(FilterMask::FullyFiltered), + 2 => Ok(FilterMask::PartiallyFiltered(BitSet::read_from(buf)?)), + _ => Err("Invalid filter mask".to_string()), + } + } +} +impl McBufWritable for FilterMask { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + match self { + FilterMask::PassThrough => 0u32.var_write_into(buf)?, + FilterMask::FullyFiltered => 1u32.var_write_into(buf)?, + FilterMask::PartiallyFiltered(bits) => { + 2u32.var_write_into(buf)?; + bits.write_into(buf)?; + } + } + Ok(()) + } +} diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs index 2ea163af..fbccc087 100644 --- a/azalea-protocol/src/packets/mod.rs +++ b/azalea-protocol/src/packets/mod.rs @@ -7,7 +7,7 @@ use crate::connect::PacketFlow; use azalea_buf::{McBufWritable, Readable, Writable}; use std::io::{Read, Write}; -pub const PROTOCOL_VERSION: u32 = 1073741924; +pub const PROTOCOL_VERSION: u32 = 760; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ConnectionProtocol { diff --git a/bot/src/main.rs b/bot/src/main.rs index 3ff30908..0f3ea31a 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -6,7 +6,7 @@ async fn main() -> Result<(), Box> { println!("Hello, world!"); // let address = "95.111.249.143:10000"; - let address = "localhost:56150"; + let address = "localhost:25565"; // let response = azalea_client::ping::ping_server(&address.try_into().unwrap()) // .await // .unwrap();