use yog_core::{BlockPos, Server};
pub mod dimension {
pub const OVERWORLD: &str = "minecraft:overworld";
pub const THE_NETHER: &str = "minecraft:the_nether";
pub const THE_END: &str = "minecraft:the_end";
}
pub struct World<'a> {
server: &'a dyn Server,
dimension: String,
}
impl<'a> World<'a> {
pub fn new(server: &'a dyn Server, dimension: impl Into<String>) -> Self {
Self {
server,
dimension: dimension.into(),
}
}
pub fn get_block(&self, pos: BlockPos) -> Option<String> {
self.server.get_block(&self.dimension, pos)
}
pub fn set_block(&self, pos: BlockPos, block_id: &str) -> bool {
self.server.set_block(&self.dimension, pos, block_id)
}
pub fn time(&self) -> Option<i64> {
self.server.world_time(&self.dimension)
}
pub fn set_time(&self, time: i64) -> bool {
self.server.world_set_time(&self.dimension, time)
}
pub fn is_raining(&self) -> bool {
self.server.world_is_raining(&self.dimension)
}
pub fn set_weather(&self, raining: bool, duration_ticks: i32) -> bool {
self.server.world_set_weather(&self.dimension, raining, duration_ticks)
}
pub fn entity_count(&self, entity_type: &str) -> i32 {
self.server.world_entity_count(&self.dimension, entity_type)
}
}
pub fn overworld(server: &dyn Server) -> World<'_> {
World::new(server, dimension::OVERWORLD)
}