pub struct GlobalBiomes { /* private fields */ }
Expand description
This is a global biomes palette, it is used in chunk storage to store biomes.
It allows you to register individual biomes in it as well as static biomes
arrays defined using the macro biomes!
.
Implementations§
Source§impl GlobalBiomes
impl GlobalBiomes
pub fn new() -> Self
Sourcepub fn with_all(slice: &[&'static Biome]) -> Result<Self, ()>
pub fn with_all(slice: &[&'static Biome]) -> Result<Self, ()>
A simple constructor to directly call register_all
with given biomes slice.
Sourcepub fn register(&mut self, biome: &'static Biome) -> Result<(), ()>
pub fn register(&mut self, biome: &'static Biome) -> Result<(), ()>
Register a single biome to this palette, returns Err
if no more save ID (SID) is
available, Ok
is returned if successful, if a biome was already in the palette
it also returns Ok
.
Sourcepub fn register_all(&mut self, slice: &[&'static Biome]) -> Result<(), ()>
pub fn register_all(&mut self, slice: &[&'static Biome]) -> Result<(), ()>
An optimized way to call register
multiple times for each given biome,
the returned follow the same rules as register
, if an error happens, it
return without and previous added biomes are kept.
pub fn get_sid_from(&self, biome: &'static Biome) -> Option<u16>
pub fn get_biome_from(&self, sid: u16) -> Option<&'static Biome>
pub fn get_biome_from_name(&self, name: &str) -> Option<&'static Biome>
pub fn get_biome_from_id(&self, id: i32) -> Option<&'static Biome>
pub fn has_biome(&self, biome: &'static Biome) -> bool
pub fn check_biome<E>( &self, biome: &'static Biome, err: impl FnOnce() -> E, ) -> Result<&'static Biome, E>
pub fn biomes_count(&self) -> usize
Auto Trait Implementations§
impl Freeze for GlobalBiomes
impl RefUnwindSafe for GlobalBiomes
impl Send for GlobalBiomes
impl Sync for GlobalBiomes
impl Unpin for GlobalBiomes
impl UnwindSafe for GlobalBiomes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more