Skip to main content

yog_event/world/
actions.rs

1//! The host's actions on a world.
2
3use yog_core::{BlockHit, BlockPos, PlacedBlock};
4use yog_ids as ids;
5
6use crate::Point;
7
8actions! {
9    /// The block at `pos` (`minecraft:stone`); `None` without the dimension.
10    GetBlock { dim: String, pos: BlockPos } -> Option<String> = ids::service_world::GET_BLOCK, "YogWorldActions.getBlock";
11    /// Sets the block at `pos`; whether it did.
12    SetBlock { dim: String, pos: BlockPos, block: String } -> bool = ids::service_world::SET_BLOCK, "YogWorldActions.setBlock";
13    /// The time of day of `dim`; `None` without the dimension.
14    Time { dim: String } -> Option<i64> = ids::service_world::TIME, "YogWorldActions.worldTime";
15    /// Sets the time of day (0 dawn, 6000 noon, 12000 dusk, 18000 midnight).
16    SetTime { dim: String, time: i64 } -> bool = ids::service_world::SET_TIME, "YogWorldActions.worldSetTime";
17    /// Whether it rains in `dim`.
18    IsRaining { dim: String } -> bool = ids::service_world::IS_RAINING, "YogWorldActions.worldIsRaining";
19    /// Starts or stops rain for `duration` ticks.
20    SetWeather { dim: String, raining: bool, duration: i32 } -> bool = ids::service_world::SET_WEATHER, "YogWorldActions.worldSetWeather";
21    /// Whether it thunders in `dim`.
22    IsThundering { dim: String } -> bool = ids::service_world::IS_THUNDERING, "YogWorldActions.worldIsThundering";
23    /// Starts or stops thunder.
24    SetThunder { dim: String, thundering: bool, duration: i32 } -> bool = ids::service_world::SET_THUNDER, "YogWorldActions.worldSetThunder";
25    /// Fills a box with `state`; how many blocks changed (`None`: failed).
26    FillRegion { dim: String, from: BlockPos, to: BlockPos, state: String } -> Option<u32> = ids::service_world::FILL_REGION, "YogQueries.fillRegion";
27    /// The non-air blocks in a box.
28    ScanRegion { dim: String, from: BlockPos, to: BlockPos } -> Vec<PlacedBlock> = ids::service_world::SCAN_REGION, "YogQueries.scanRegion";
29    /// Places a configured feature at `pos`.
30    PlaceFeature { dim: String, pos: BlockPos, feature: String } -> bool = ids::service_world::PLACE_FEATURE, "YogWorldActions.placeFeature";
31    /// Makes an explosion.
32    Explode { dim: String, pos: Point, power: f32, fire: bool, source: String } -> bool = ids::service_world::EXPLODE, "YogWorldActions.explode";
33    /// Rolls a loot table and drops its items at `pos`.
34    DropLoot { table: String, dim: String, pos: Point } -> bool = ids::service_world::DROP_LOOT, "YogWorldActions.dropLoot";
35    /// How many entities of `entity_type` are in `dim` (`None`: no such dimension or type).
36    EntityCount { dim: String, entity_type: String } -> Option<u32> = ids::service_world::ENTITY_COUNT, "YogQueries.worldEntityCount";
37    /// The uuids of the entities in a box.
38    EntitiesInBox { dim: String, min: Point, max: Point } -> Vec<String> = ids::service_world::ENTITIES_IN_BOX, "YogQueries.entitiesInBox";
39    /// The first block a ray hits.
40    RaycastBlock { dim: String, from: Point, to: Point } -> Option<BlockHit> = ids::service_world::RAYCAST_BLOCK, "YogQueries.raycastBlock";
41    /// The first entity a ray hits: its uuid.
42    RaycastEntity { dim: String, from: Point, to: Point, exclude: String } -> Option<String> = ids::service_world::RAYCAST_ENTITY, "YogWorldActions.raycastEntity";
43}