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