steel_protocol/packets/game/s_player_command.rs
1use steel_macros::{ReadFrom, ServerPacket};
2
3/// Action types for the player command packet.
4///
5/// Maps to vanilla `ServerboundPlayerCommandPacket.Action` enum.
6/// Wire format: `VarInt` (0–6).
7#[derive(ReadFrom, Clone, Copy, Debug, PartialEq, Eq)]
8#[read(as = VarInt)]
9pub enum PlayerCommandAction {
10 /// Player leaves bed (only when clicking "Leave Bed" button).
11 LeaveBed = 0,
12 /// Player starts sprinting.
13 StartSprinting = 1,
14 /// Player stops sprinting.
15 StopSprinting = 2,
16 /// Player starts jumping while riding a horse (data = jump boost 0-100).
17 StartRidingJump = 3,
18 /// Player stops jumping while riding a horse.
19 StopRidingJump = 4,
20 /// Player opens vehicle inventory (horse/chest boat) via inventory key.
21 OpenVehicleInventory = 5,
22 /// Player starts flying with elytra.
23 StartFallFlying = 6,
24}
25
26/// Serverbound packet sent when a player performs a command action.
27///
28/// This handles actions like sprinting, sleeping, elytra, and horse riding.
29/// Packet ID 0x29 (play phase) — `player_command` in packets.json.
30#[derive(ReadFrom, ServerPacket, Clone, Debug)]
31pub struct SPlayerCommand {
32 /// The entity ID of the player (should match the player's ID).
33 #[read(as = VarInt)]
34 pub entity_id: i32,
35 /// The action being performed.
36 pub action: PlayerCommandAction,
37 /// Jump boost for `StartRidingJump` (0-100), otherwise 0.
38 #[read(as = VarInt)]
39 pub data: i32,
40}