1use yog_core::{BlockPos, Server};
8
9pub mod dimension {
11 pub const OVERWORLD: &str = "minecraft:overworld";
12 pub const THE_NETHER: &str = "minecraft:the_nether";
13 pub const THE_END: &str = "minecraft:the_end";
14}
15
16pub struct World<'a> {
18 server: &'a dyn Server,
19 dimension: String,
20}
21
22impl<'a> World<'a> {
23 pub fn new(server: &'a dyn Server, dimension: impl Into<String>) -> Self {
25 Self {
26 server,
27 dimension: dimension.into(),
28 }
29 }
30
31 pub fn get_block(&self, pos: BlockPos) -> Option<String> {
33 self.server.get_block(&self.dimension, pos)
34 }
35
36 pub fn set_block(&self, pos: BlockPos, block_id: &str) -> bool {
38 self.server.set_block(&self.dimension, pos, block_id)
39 }
40
41 pub fn time(&self) -> Option<i64> {
43 self.server.world_time(&self.dimension)
44 }
45
46 pub fn set_time(&self, time: i64) -> bool {
48 self.server.world_set_time(&self.dimension, time)
49 }
50
51 pub fn is_raining(&self) -> bool {
53 self.server.world_is_raining(&self.dimension)
54 }
55
56 pub fn set_weather(&self, raining: bool, duration_ticks: i32) -> bool {
58 self.server.world_set_weather(&self.dimension, raining, duration_ticks)
59 }
60
61 pub fn entity_count(&self, entity_type: &str) -> i32 {
64 self.server.world_entity_count(&self.dimension, entity_type)
65 }
66}
67
68pub fn overworld(server: &dyn Server) -> World<'_> {
70 World::new(server, dimension::OVERWORLD)
71}