From 2211021105a7ce0ce9fcbc18f3b4f03b0f991a10 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 28 Jul 2022 23:50:58 -0500 Subject: 1.19.1 --- .../packets/game/clientbound_player_chat_packet.rs | 39 ++++++++++++++++++++-- azalea-protocol/src/packets/mod.rs | 2 +- 2 files changed, 38 insertions(+), 3 deletions(-) (limited to 'azalea-protocol/src') 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 { -- cgit v1.2.3