yog_event/block.rs
1//! What happens to blocks.
2
3use yog_core::BlockPos;
4use yog_data::Schema;
5
6/// Fired when a player breaks a block (server side).
7#[derive(Debug, Clone, Schema)]
8pub struct Break {
9 pub player_name: String,
10 /// Registry id of the block, e.g. `minecraft:stone`.
11 pub block_id: String,
12 pub pos: BlockPos,
13 /// Dimension the block was broken in, e.g. `minecraft:overworld`.
14 pub dimension: String,
15}
16
17/// Fired when a player places a block (server side).
18///
19/// Subscribed with `Registry::on` / `before` / `after`:
20/// - before — fires before placement; return `false` to cancel.
21/// - after — fires after the block has been placed.
22#[derive(Debug, Clone, Schema)]
23pub struct Place {
24 pub player_name: String,
25 /// Registry id of the block being placed, e.g. `minecraft:stone`.
26 pub block_id: String,
27 pub pos: BlockPos,
28 pub dimension: String,
29 /// Whether the player was sneaking (shift).
30 pub sneaking: bool,
31}
32
33/// Fired when a player right-clicks a block (server side).
34#[derive(Debug, Clone, Schema)]
35pub struct Use {
36 pub player_name: String,
37 /// Registry id of the targeted block, e.g. `minecraft:chest`.
38 pub block_id: String,
39 pub pos: BlockPos,
40 pub dimension: String,
41 /// Whether the player was sneaking (shift).
42 pub sneaking: bool,
43}
44
45/// A hopper or dropper offers an item to a block that accepts items
46/// (`block.accepts_items`): a service each such block provides (keyed by
47/// its id), answering whether it takes the item.
48#[derive(Debug, Clone, Schema)]
49pub struct Insert {
50 /// Registry id of the block.
51 pub block_id: String,
52 pub pos: BlockPos,
53 pub dimension: String,
54 pub item_id: String,
55 pub count: u32,
56 /// The item's data as SNBT (`{}` for none).
57 pub nbt: String,
58 /// Only whether it would take it — nothing changes yet; else it takes it.
59 pub simulate: bool,
60}
61
62mod actions;
63mod properties;
64pub use actions::*;
65pub use properties::{property, set_properties};