From b38e6af2f3c7c284b2bf81e5a731c00904522ac6 Mon Sep 17 00:00:00 2001 From: lukas0008 Date: Tue, 13 Aug 2024 23:57:30 +0200 Subject: [PATCH] Add s_player_action packet Note: this packet is currently only parsed, not handled. --- pumpkin-protocol/src/server/play/mod.rs | 2 ++ pumpkin-protocol/src/server/play/s_player_action.rs | 12 ++++++++++++ pumpkin/src/client/mod.rs | 8 +++++--- pumpkin/src/client/player_packet.rs | 4 +++- 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 pumpkin-protocol/src/server/play/s_player_action.rs diff --git a/pumpkin-protocol/src/server/play/mod.rs b/pumpkin-protocol/src/server/play/mod.rs index 8394c0d67..dc03c5175 100644 --- a/pumpkin-protocol/src/server/play/mod.rs +++ b/pumpkin-protocol/src/server/play/mod.rs @@ -8,6 +8,7 @@ mod s_player_position; mod s_player_position_rotation; mod s_player_rotation; mod s_swing_arm; +mod s_player_action; pub use c_client_information::*; pub use c_interact::*; @@ -19,3 +20,4 @@ pub use s_player_position::*; pub use s_player_position_rotation::*; pub use s_player_rotation::*; pub use s_swing_arm::*; +pub use s_player_action::*; diff --git a/pumpkin-protocol/src/server/play/s_player_action.rs b/pumpkin-protocol/src/server/play/s_player_action.rs new file mode 100644 index 000000000..6b4b40616 --- /dev/null +++ b/pumpkin-protocol/src/server/play/s_player_action.rs @@ -0,0 +1,12 @@ +use pumpkin_macros::packet; + +use crate::{position::WorldPosition, VarInt}; + +#[derive(serde::Deserialize)] +#[packet(0x24)] +pub struct SPlayerAction { + status: VarInt, + location: WorldPosition, + face: u8, + sequence: VarInt, +} \ No newline at end of file diff --git a/pumpkin/src/client/mod.rs b/pumpkin/src/client/mod.rs index caa70bb27..5bebd9c2c 100644 --- a/pumpkin/src/client/mod.rs +++ b/pumpkin/src/client/mod.rs @@ -28,7 +28,8 @@ use pumpkin_protocol::{ login::{SEncryptionResponse, SLoginAcknowledged, SLoginPluginResponse, SLoginStart}, play::{ SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract, - SPlayerCommand, SPlayerPosition, SPlayerPositionRotation, SPlayerRotation, SSwingArm, + SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation, + SPlayerRotation, SSwingArm, }, status::{SPingRequest, SStatusRequest}, }, @@ -286,8 +287,9 @@ impl Client { server, SClientInformationPlay::read(bytebuf).unwrap(), ), - SInteract::PACKET_ID => { - self.handle_interact(server, SInteract::read(bytebuf).unwrap()); + SInteract::PACKET_ID => self.handle_interact(server, SInteract::read(bytebuf).unwrap()), + SPlayerAction::PACKET_ID => { + self.handle_player_action(server, SPlayerAction::read(bytebuf).unwrap()) } _ => log::error!("Failed to handle player packet id {}", packet.id.0), } diff --git a/pumpkin/src/client/player_packet.rs b/pumpkin/src/client/player_packet.rs index 1142d7e0d..da5edb2d7 100644 --- a/pumpkin/src/client/player_packet.rs +++ b/pumpkin/src/client/player_packet.rs @@ -8,7 +8,8 @@ use pumpkin_protocol::{ }, server::play::{ SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract, - SPlayerCommand, SPlayerPosition, SPlayerPositionRotation, SPlayerRotation, SSwingArm, + SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation, SPlayerRotation, + SSwingArm, }, VarInt, }; @@ -277,4 +278,5 @@ impl Client { } } } + pub fn handle_player_action(&mut self, _server: &mut Server, player_action: SPlayerAction) {} }