Skip to main content

yog_api/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}