Skip to content

Commit

Permalink
Add s_player_action packet
Browse files Browse the repository at this point in the history
Note: this packet is currently only parsed, not handled.
  • Loading branch information
lukas0008 committed Aug 13, 2024
1 parent cce0161 commit b38e6af
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions pumpkin-protocol/src/server/play/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand All @@ -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::*;
12 changes: 12 additions & 0 deletions pumpkin-protocol/src/server/play/s_player_action.rs
Original file line number Diff line number Diff line change
@@ -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,
}
8 changes: 5 additions & 3 deletions pumpkin/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
},
Expand Down Expand Up @@ -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),
}
Expand Down
4 changes: 3 additions & 1 deletion pumpkin/src/client/player_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -277,4 +278,5 @@ impl Client {
}
}
}
pub fn handle_player_action(&mut self, _server: &mut Server, player_action: SPlayerAction) {}
}

0 comments on commit b38e6af

Please sign in to comment.