mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-30 20:14:23 +00:00
fix 1.21.5 player chat packet
fixes https://github.com/Pumpkin-MC/Pumpkin/issues/677
This commit is contained in:
@@ -9,6 +9,7 @@ use crate::{VarInt, codec::bit_set::BitSet};
|
||||
#[derive(Serialize)]
|
||||
#[packet(PLAY_PLAYER_CHAT)]
|
||||
pub struct CPlayerChatMessage {
|
||||
global_index: VarInt,
|
||||
#[serde(with = "uuid::serde::compact")]
|
||||
sender: uuid::Uuid,
|
||||
index: VarInt,
|
||||
@@ -29,6 +30,7 @@ pub struct CPlayerChatMessage {
|
||||
impl CPlayerChatMessage {
|
||||
#[expect(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
global_index: VarInt,
|
||||
sender: uuid::Uuid,
|
||||
index: VarInt,
|
||||
message_signature: Option<Box<[u8]>>,
|
||||
@@ -43,13 +45,14 @@ impl CPlayerChatMessage {
|
||||
target_name: Option<TextComponent>,
|
||||
) -> Self {
|
||||
Self {
|
||||
global_index,
|
||||
sender,
|
||||
index,
|
||||
message_signature,
|
||||
message,
|
||||
timestamp,
|
||||
salt,
|
||||
previous_messages_count: previous_messages.len().into(),
|
||||
previous_messages_count: VarInt(previous_messages.len() as i32),
|
||||
previous_messages,
|
||||
unsigned_content,
|
||||
filter_type,
|
||||
|
||||
@@ -233,6 +233,7 @@ pub struct Player {
|
||||
pub experience_pick_up_delay: Mutex<u32>,
|
||||
pub chunk_manager: Mutex<ChunkManager>,
|
||||
pub has_played_before: AtomicBool,
|
||||
pub global_chat_message_index: AtomicU32,
|
||||
}
|
||||
|
||||
impl Player {
|
||||
@@ -316,6 +317,7 @@ impl Player {
|
||||
last_sent_food: AtomicU32::new(0),
|
||||
last_food_saturation: AtomicBool::new(true),
|
||||
has_played_before: AtomicBool::new(false),
|
||||
global_chat_message_index: AtomicU32::new(0),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -680,6 +680,9 @@ impl Player {
|
||||
}
|
||||
|
||||
let gameprofile = &self.gameprofile;
|
||||
let global_index = self
|
||||
.global_chat_message_index
|
||||
.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
send_cancellable! {{
|
||||
PlayerChatEvent::new(self.clone(), message.clone(), vec![]);
|
||||
|
||||
@@ -691,6 +694,7 @@ impl Player {
|
||||
let world = &entity.world.read().await;
|
||||
world
|
||||
.broadcast_packet_all(&CPlayerChatMessage::new(
|
||||
VarInt(global_index as i32),
|
||||
gameprofile.id,
|
||||
1.into(),
|
||||
chat_message.signature,
|
||||
@@ -709,6 +713,7 @@ impl Player {
|
||||
} else {
|
||||
let packet =
|
||||
CPlayerChatMessage::new(
|
||||
VarInt(global_index as i32),
|
||||
gameprofile.id,
|
||||
1.into(),
|
||||
chat_message.signature,
|
||||
|
||||
Reference in New Issue
Block a user