yog_event/player/action.rs
1//! What players do with items, blocks and entities.
2
3use yog_data::Schema;
4
5/// Fired every time a player sends a movement packet (very high frequency).
6///
7/// Post-phase only. The fields reflect the *new* position the client claims.
8#[derive(Debug, Clone, Schema)]
9pub struct Move {
10 pub player_name: String,
11 pub player_uuid: String,
12 pub x: f64,
13 pub y: f64,
14 pub z: f64,
15 pub yaw: f32,
16 pub pitch: f32,
17 pub dimension: String,
18}
19
20/// Fired when a player right-clicks with an item (server side).
21#[derive(Debug, Clone, Schema)]
22pub struct UseItem {
23 pub player_name: String,
24 /// Registry id of the held item, e.g. `minecraft:stick`.
25 pub item_id: String,
26 /// Whether the player was sneaking (shift) during use.
27 pub sneaking: bool,
28 pub dimension: String,
29}
30
31/// Fired when a player attacks (left-clicks) an entity (server side).
32#[derive(Debug, Clone, Schema)]
33pub struct Attack {
34 pub player_name: String,
35 /// Registry id of the target, e.g. `minecraft:zombie`.
36 pub target_type: String,
37 /// Target entity UUID as a string.
38 pub target_uuid: String,
39 pub dimension: String,
40}
41
42/// Fired when a player right-clicks (interacts with) an entity (server side).
43///
44/// - `Pre` — fires before the interaction; return `false` to cancel.
45/// - `Post` — fires after the interaction.
46#[derive(Debug, Clone, Schema)]
47pub struct Interact {
48 pub player_name: String,
49 pub player_uuid: String,
50 /// Registry id of the interacted entity, e.g. `"minecraft:villager"`.
51 pub entity_type: String,
52 pub entity_uuid: String,
53 /// `"main_hand"` or `"off_hand"`.
54 pub hand: String,
55 pub dimension: String,
56}
57
58/// Fired when a player takes a crafted item from a crafting output slot (Post only).
59#[derive(Debug, Clone, Schema)]
60pub struct Craft {
61 pub player_name: String,
62 pub player_uuid: String,
63 /// Registry id of the crafted item, e.g. `"minecraft:stick"`.
64 pub result_item: String,
65 pub result_count: u32,
66 pub dimension: String,
67}
68
69/// Fired when a player picks up an item entity.
70///
71/// - `Pre` — return `false` to prevent the pickup.
72/// - `Post` — item was successfully picked up.
73#[derive(Debug, Clone, Schema)]
74pub struct Pickup {
75 pub player_name: String,
76 pub player_uuid: String,
77 /// Registry id of the item, e.g. `"minecraft:diamond"`.
78 pub item_id: String,
79 pub item_count: u32,
80 /// UUID of the item entity that was picked up.
81 pub entity_uuid: String,
82 pub dimension: String,
83}