Skip to main content

yog_event/client/
actions.rs

1//! This client's own actions: the host's (nothing on a dedicated server).
2
3use yog_core::{BlockPos, ScreenSlot, Stack};
4use yog_ids as ids;
5
6actions! {
7    /// Plays `sound` to this client's player; its handle (to stop it).
8    PlaySound { sound: String, volume: f32, pitch: f32, looping: bool } -> Option<i32> = ids::service_client::PLAY_SOUND, "YogClientApi.playSound";
9    /// Stops a sound `PlaySound` started.
10    StopSound { handle: i32 } -> bool = ids::service_client::STOP_SOUND, "YogClientApi.stopSound";
11    /// What this client's player holds.
12    HeldItem { off_hand: bool } -> Option<Stack> = ids::service_client::HELD_ITEM, "YogClientApi.heldItem";
13    /// Tints the block at `pos` on this client (`0xRRGGBB`; -1 clears it).
14    SetBlockTint { dim: String, pos: BlockPos, color: i32 } -> bool = ids::service_client::SET_BLOCK_TINT, "YogClientApi.setBlockTint";
15    /// The slots of the inventory screen this client has open (none when it has none).
16    ScreenSlots {  } -> Vec<ScreenSlot> = ids::service_client::SCREEN_SLOTS, "YogQueries.screenSlots";
17    /// Whether GLFW key `key` is held down.
18    KeyDown { key: i32 } -> bool = ids::service_client::KEY_DOWN, "YogClientApi.keyDown";
19    /// An attribute's value on this client's player.
20    AttributeValue { attribute: String } -> Option<f64> = ids::service_client::ATTRIBUTE_VALUE, "YogClientApi.attributeValue";
21    /// Whether this client's player has advancement `id`.
22    AdvancementDone { id: String } -> bool = ids::service_client::ADVANCEMENT_DONE, "YogClientApi.advancementDone";
23    /// Asks the mods about entity `uuid`'s body each frame (`on`) or not.
24    BodyTrack { uuid: String, on: bool } -> bool = ids::service_client::BODY_TRACK, "YogClientApi.bodyTrack";
25    /// The same for every entity of `entity_type`.
26    BodyTrackType { entity_type: String, on: bool } -> bool = ids::service_client::BODY_TRACK_TYPE, "YogClientApi.bodyTrackType";
27    /// This client's side of an entity's size (`width` < 0: vanilla's).
28    SetDimensions { uuid: String, width: f32, height: f32, eye: f32 } -> bool = ids::service_client::SET_DIMENSIONS, "YogClientApi.setDimensions";
29}
30
31/// What this client was told an entity keeps under `key` (the runtime keeps it).
32#[derive(Debug, Clone, yog_data::Schema)]
33pub struct EntityData {
34    pub uuid: String,
35    pub key: String,
36}