Skip to main content

steel_protocol/packets/game/
s_player_action.rs

1use steel_macros::{ReadFrom, ServerPacket};
2use steel_registry::blocks::properties::Direction;
3use steel_utils::BlockPos;
4
5/// Action types for the player action packet.
6#[derive(ReadFrom, Clone, Copy, Debug, PartialEq, Eq)]
7#[read(as = VarInt)]
8pub enum PlayerAction {
9    StartDestroyBlock = 0,
10    AbortDestroyBlock = 1,
11    StopDestroyBlock = 2,
12    DropAllItems = 3,
13    DropItem = 4,
14    ReleaseUseItem = 5,
15    SwapItemWithOffhand = 6,
16    Stab = 7,
17}
18
19/// Serverbound packet sent when a player performs an action like mining a block.
20#[derive(ReadFrom, ServerPacket, Clone, Debug)]
21pub struct SPlayerAction {
22    pub action: PlayerAction,
23    pub pos: BlockPos,
24    pub direction: Direction,
25    #[read(as = VarInt)]
26    pub sequence: i32,
27}