Pumpkin/pumpkin-protocol/src/server/play/s_player_action.rs
Snowiiii 1842e8e6b1 Parse Serverbound Packet IDs from JSON as well
Before only Clientbound Packet IDs where parsed from JSON, Now Serverbound Packet IDs are parsed from JSON as well. This makes porting to new minecraft version much easier
2024-11-03 12:25:10 +01:00

34 lines
1.7 KiB
Rust

use num_derive::FromPrimitive;
use pumpkin_core::math::position::WorldPosition;
use pumpkin_macros::server_packet;
use crate::VarInt;
#[derive(serde::Deserialize)]
#[server_packet("play:player_action")]
pub struct SPlayerAction {
pub status: VarInt,
pub location: WorldPosition,
pub face: u8,
pub sequence: VarInt,
}
#[derive(FromPrimitive)]
pub enum Status {
/// Sent when the player starts digging a block. If the block was instamined or the player is in creative mode, the client will not send Status = Finished digging, and will assume the server completed the destruction. To detect this, it is necessary to calculate the block destruction speed server-side.
StartedDigging = 0,
/// Sent when the player lets go of the Mine Block key (default: left click). Face is always set to -Y.
CancelledDigging,
/// Sent when the client thinks it is finished.
FinishedDigging,
/// Triggered by using the Drop Item key (default: Q) with the modifier to drop the entire selected stack (default: Control or Command, depending on OS). Location is always set to 0/0/0, Face is always set to -Y. Sequence is always set to 0.
DropItemStack,
/// Triggered by using the Drop Item key (default: Q). Location is always set to 0/0/0, Face is always set to -Y. Sequence is always set to 0.
DropItem,
/// I didn't make that up
/// Indicates that the currently held item should have its state updated such as eating food, pulling back bows, using buckets, etc. Location is always set to 0/0/0, Face is always set to -Y. Sequence is always set to 0.
ShootArrowOrFinishEating,
/// Used to swap or assign an item to the second hand. Location is always set to 0/0/0, Face is always set to -Y. Sequence is always set to 0.
SwapItem,
}