aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-07-28 23:50:58 -0500
committermat <github@matdoes.dev>2022-07-28 23:50:58 -0500
commit2211021105a7ce0ce9fcbc18f3b4f03b0f991a10 (patch)
tree8756a1aa11d04ba448c28705bd2c4af9dda39083 /azalea-protocol/src
parent3aa856b41325c3c184903aba8fb835557124131e (diff)
downloadazalea-drasl-2211021105a7ce0ce9fcbc18f3b4f03b0f991a10.tar.xz
1.19.1
Diffstat (limited to 'azalea-protocol/src')
-rw-r--r--azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs39
-rw-r--r--azalea-protocol/src/packets/mod.rs2
2 files changed, 38 insertions, 3 deletions
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<Component>,
}
#[derive(Clone, Debug, McBuf)]
@@ -34,6 +36,7 @@ pub struct PlayerChatMessage {
pub header_signature: MessageSignature,
pub signed_body: SignedMessageBody,
pub unsigned_content: Option<Component>,
+ 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<Component>,
}
+
+#[derive(Clone, Debug)]
+pub enum FilterMask {
+ PassThrough,
+ FullyFiltered,
+ PartiallyFiltered(BitSet),
+}
+
+impl McBufReadable for FilterMask {
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
+ 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 {