From b18c26ccb4eb28cc92d28a17ebd868dbf236bd3e Mon Sep 17 00:00:00 2001 From: Alexander Medvedev Date: Sun, 9 Aug 2026 18:48:59 +0200 Subject: [PATCH] fix: SEmote packet --- .../src/bedrock/server/emote.rs | 10 +++---- crates/pumpkin/src/net/bedrock/mod.rs | 13 +++++----- crates/pumpkin/src/net/bedrock/play.rs | 26 +++++++++++-------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/crates/pumpkin-protocol/src/bedrock/server/emote.rs b/crates/pumpkin-protocol/src/bedrock/server/emote.rs index 14b9bb234..39c559fce 100644 --- a/crates/pumpkin-protocol/src/bedrock/server/emote.rs +++ b/crates/pumpkin-protocol/src/bedrock/server/emote.rs @@ -11,8 +11,8 @@ pub const EMOTE_FLAG_MUTE_CHAT: u8 = 1 << 1; #[packet(138)] pub struct SEmote<'a> { pub runtime_entity_id: VarULong, - pub emote_id: Cow<'a, str>, pub emote_length: VarUInt, + pub emote_id: Cow<'a, str>, pub xuid: Cow<'a, str>, pub platform_id: Cow<'a, str>, pub flags: u8, @@ -21,15 +21,15 @@ pub struct SEmote<'a> { impl<'a> PacketReadSlice<'a> for SEmote<'a> { fn read_slice(buf: &mut &'a [u8]) -> Result { let runtime_entity_id = VarULong::read_slice(buf)?; - let emote_id = Cow::Borrowed(read_str_slice(buf)?); let emote_length = VarUInt::read_slice(buf)?; + let emote_id = Cow::Borrowed(read_str_slice(buf)?); let xuid = Cow::Borrowed(read_str_slice(buf)?); let platform_id = Cow::Borrowed(read_str_slice(buf)?); let flags = u8::read_slice(buf)?; Ok(Self { runtime_entity_id, - emote_id, emote_length, + emote_id, xuid, platform_id, flags, @@ -41,8 +41,8 @@ impl PacketRead for SEmote<'static> { fn read(reader: &mut R) -> Result { Ok(Self { runtime_entity_id: VarULong::read(reader)?, - emote_id: Cow::Owned(String::read(reader)?), emote_length: VarUInt::read(reader)?, + emote_id: Cow::Owned(String::read(reader)?), xuid: Cow::Owned(String::read(reader)?), platform_id: Cow::Owned(String::read(reader)?), flags: u8::read(reader)?, @@ -53,8 +53,8 @@ impl PacketRead for SEmote<'static> { impl PacketWrite for SEmote<'_> { fn write(&self, writer: &mut W) -> Result<(), Error> { self.runtime_entity_id.write(writer)?; - self.emote_id.as_ref().write(writer)?; self.emote_length.write(writer)?; + self.emote_id.as_ref().write(writer)?; self.xuid.as_ref().write(writer)?; self.platform_id.as_ref().write(writer)?; self.flags.write(writer) diff --git a/crates/pumpkin/src/net/bedrock/mod.rs b/crates/pumpkin/src/net/bedrock/mod.rs index 9bceec227..69c65ca80 100644 --- a/crates/pumpkin/src/net/bedrock/mod.rs +++ b/crates/pumpkin/src/net/bedrock/mod.rs @@ -26,9 +26,9 @@ use pumpkin_protocol::{ server::{ animate::SAnimate, block_pick_request::SBlockPickRequest, client_cache_status::SClientCacheStatus, command_request::SCommandRequest, - container_close::SContainerClose, emote::SEmote, interaction::SInteraction, - inventory_transaction::SInventoryTransaction, loading_screen::SLoadingScreen, - login::SLogin, mob_equipment::SMobEquipment, + container_close::SContainerClose, emote::SEmote, emote_list::SEmoteList, + interaction::SInteraction, inventory_transaction::SInventoryTransaction, + loading_screen::SLoadingScreen, login::SLogin, mob_equipment::SMobEquipment, packet_violation_warning::SPacketViolationWarning, player_action::SPlayerAction, player_auth_input::SPlayerAuthInput, request_ability::SRequestAbility, request_chunk_radius::SRequestChunkRadius, @@ -624,6 +624,7 @@ impl BedrockClient { } } + #[allow(clippy::too_many_lines)] pub async fn handle_play_packet( &self, player: &Arc, @@ -690,9 +691,9 @@ impl BedrockClient { SEmote::PACKET_ID => { self.handle_emote(player, server, SEmote::read_slice(reader)?).await; } - // SEmoteList::PACKET_ID => { - // self.handle_emote_list(player, server, SEmoteList::read(reader)?); - // } + SEmoteList::PACKET_ID => { + self.handle_emote_list(player, server, &SEmoteList::read(reader)?); + } pumpkin_protocol::bedrock::server::modal_form_response::SModalFormResponse::PACKET_ID => { self.handle_modal_form_response( player, diff --git a/crates/pumpkin/src/net/bedrock/play.rs b/crates/pumpkin/src/net/bedrock/play.rs index 9a3bfa0a0..6aa57fb18 100644 --- a/crates/pumpkin/src/net/bedrock/play.rs +++ b/crates/pumpkin/src/net/bedrock/play.rs @@ -28,6 +28,7 @@ use pumpkin_protocol::{ command_request::SCommandRequest, container_close::SContainerClose, emote::SEmote, + emote_list::SEmoteList, interaction::{Action, SInteraction}, inventory_transaction::{SInventoryTransaction, TransactionData}, mob_equipment::SMobEquipment, @@ -463,10 +464,17 @@ impl BedrockClient { return; } + tracing::info!( + "handle_emote: player={} packet={:?}", + player.gameprofile.name, + packet + ); + let entity = &player.living_entity.entity; let world = entity.world.load(); let mut broadcast_packet = packet; + broadcast_packet.runtime_entity_id = VarULong(entity.entity_id as u64); broadcast_packet.flags |= pumpkin_protocol::bedrock::server::emote::EMOTE_FLAG_SERVER_SIDE; world @@ -481,17 +489,13 @@ impl BedrockClient { .await; } - // pub fn handle_emote_list( - // &self, - // player: &Arc, - // _server: &Server, - // packet: &SEmoteList, - // ) { - // debug!( - // "Player {} sent emote list: {:?}", - // player.gameprofile.name, packet.emote_pieces - // ); - // } + pub fn handle_emote_list(&self, player: &Arc, _server: &Server, packet: &SEmoteList) { + tracing::info!( + "handle_emote_list: player={} packet={:?}", + player.gameprofile.name, + packet + ); + } #[allow(clippy::too_many_lines, clippy::collapsible_if, clippy::unreachable)] pub async fn handle_inventory_action(