use crate::ident;
use crate::protocol::packets::s2c::play::DimensionType;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct DimensionId(pub(crate) u16);
impl Default for DimensionId {
fn default() -> Self {
Self(0)
}
}
#[derive(Clone, Debug)]
pub struct Dimension {
pub natural: bool,
pub ambient_light: f32,
pub fixed_time: Option<u16>,
pub effects: DimensionEffects,
pub min_y: i32,
pub height: i32,
}
impl Dimension {
pub(crate) fn to_dimension_registry_item(&self) -> DimensionType {
DimensionType {
piglin_safe: true,
has_raids: true,
monster_spawn_light_level: 0,
monster_spawn_block_light_limit: 0,
natural: self.natural,
ambient_light: self.ambient_light,
fixed_time: self.fixed_time.map(|t| t as i64),
infiniburn: "#minecraft:infiniburn_overworld".into(),
respawn_anchor_works: true,
has_skylight: true,
bed_works: true,
effects: match self.effects {
DimensionEffects::Overworld => ident!("overworld"),
DimensionEffects::TheNether => ident!("the_nether"),
DimensionEffects::TheEnd => ident!("the_end"),
},
min_y: self.min_y,
height: self.height,
logical_height: self.height,
coordinate_scale: 1.0,
ultrawarm: false,
has_ceiling: false,
}
}
}
impl Default for Dimension {
fn default() -> Self {
Self {
natural: true,
ambient_light: 1.0,
fixed_time: None,
effects: DimensionEffects::default(),
min_y: -64,
height: 384,
}
}
}
#[derive(Clone, Copy, PartialEq, Eq, Default, Debug)]
pub enum DimensionEffects {
#[default]
Overworld,
TheNether,
TheEnd,
}