1use yog_core::{BlockPos, Server};
8
9pub mod dimension {
11 pub use yog_ids::game::{OVERWORLD, THE_END, THE_NETHER};
12}
13
14pub struct World<'a> {
16 server: &'a dyn Server,
17 dimension: String,
18}
19
20impl<'a> World<'a> {
21 pub fn new(server: &'a dyn Server, dimension: impl Into<String>) -> Self {
23 Self {
24 server,
25 dimension: dimension.into(),
26 }
27 }
28
29 pub fn get_block(&self, pos: BlockPos) -> Option<String> {
31 self.server.get_block(&self.dimension, pos)
32 }
33
34 pub fn set_block(&self, pos: BlockPos, block_id: &str) -> bool {
36 self.server.set_block(&self.dimension, pos, block_id)
37 }
38
39 pub fn time(&self) -> Option<i64> {
41 self.server.world_time(&self.dimension)
42 }
43
44 pub fn set_time(&self, time: i64) -> bool {
46 self.server.world_set_time(&self.dimension, time)
47 }
48
49 pub fn is_raining(&self) -> bool {
51 self.server.world_is_raining(&self.dimension)
52 }
53
54 pub fn set_weather(&self, raining: bool, duration_ticks: i32) -> bool {
56 self.server
57 .world_set_weather(&self.dimension, raining, duration_ticks)
58 }
59
60 pub fn entity_count(&self, entity_type: &str) -> i32 {
63 self.server.world_entity_count(&self.dimension, entity_type)
64 }
65}
66
67pub fn overworld(server: &dyn Server) -> World<'_> {
69 World::new(server, dimension::OVERWORLD)
70}