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