fix: SEmote packet

This commit is contained in:
Alexander Medvedev 2026-08-09 18:48:59 +02:00
parent 92658f5853
commit b18c26ccb4
3 changed files with 27 additions and 22 deletions

View File

@ -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<Self, Error> {
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<R: std::io::Read>(reader: &mut R) -> Result<Self, Error> {
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<W: 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)

View File

@ -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<Player>,
@ -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,

View File

@ -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<Player>,
// _server: &Server,
// packet: &SEmoteList,
// ) {
// debug!(
// "Player {} sent emote list: {:?}",
// player.gameprofile.name, packet.emote_pieces
// );
// }
pub fn handle_emote_list(&self, player: &Arc<Player>, _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(