yog_api/reach/mirror/host.rs
1//! The game's own mirrors, typed: every entity and every player, as the
2//! host writes them (`yog_mirror::host` is their source).
3//!
4//! ```ignore
5//! let near = Entities::declare(Entities::POS | Entities::KIND, Rate::Every(1))?;
6//! for e in near.iter() { draw(e.pos(), e.kind()); }
7//! ```
8
9use yog_core::Point;
10use yog_data::Atom;
11
12use crate::yog_mirror;
13
14/// Every live entity, by network id.
15#[yog_mirror(host = yog_mirror::host::ENTITY)]
16pub struct Entities {
17 pub pos: Point,
18 /// Blocks a tick.
19 pub velocity: Point,
20 /// Yaw, pitch (degrees).
21 pub rotation: [f32; 2],
22 /// Its type.
23 pub kind: Option<Atom>,
24 pub dimension: Option<Atom>,
25 /// Living ones'; others 0.
26 pub health: f32,
27 /// `[high, low]`.
28 pub uuid: [u64; 2],
29}
30
31/// Every player (part of the entities: their facts read through it).
32#[yog_mirror(host = yog_mirror::host::PLAYER)]
33pub struct Players {
34 pub name: Option<Atom>,
35}
36
37/// The blocks of the areas asked for, a dimension each: declared with
38/// `Blocks::declare_in(dimension, Some(&BlockScope { min, max }), …)`.
39#[yog_mirror(host = yog_mirror::host::BLOCK)]
40pub struct Blocks {
41 /// Its state: `minecraft:oak_stairs[facing=north,…]`.
42 pub state: Option<Atom>,
43}
44
45/// The entities this client sees, by network id: written after its ticks,
46/// on any server.
47#[yog_mirror(host = yog_mirror::host::CLIENT_ENTITY)]
48pub struct ClientEntities {
49 pub pos: Point,
50 /// Blocks a tick.
51 pub velocity: Point,
52 /// Yaw, pitch (degrees).
53 pub rotation: [f32; 2],
54 /// Its type.
55 pub kind: Option<Atom>,
56 /// Living ones'; others 0.
57 pub health: f32,
58 /// `[high, low]`.
59 pub uuid: [u64; 2],
60 /// Its eyes' height over its feet.
61 pub eye_height: f32,
62 /// A monster (1) or not (0).
63 pub hostile: u8,
64 /// A player's name; others none.
65 pub name: Option<Atom>,
66}
67
68/// The blocks of the area asked for in this client's world, by packed
69/// position (`ClientBlocks::declare_scoped(&BlockScope { min, max }, …)`):
70/// each one's state and what a body meets there.
71#[yog_mirror(host = yog_mirror::host::CLIENT_BLOCK)]
72pub struct ClientBlocks {
73 pub state: Option<Atom>,
74 /// Its traits ([`crate::mirror::BlockTraits`]).
75 pub traits: u64,
76 /// How hard it is to break (negative: it can't be).
77 pub hardness: f32,
78}