1use std::io;
2
3use azalea_buf::BufReadError;
4use azalea_registry::{Registry, data::Biome, registry_holder::RegistryHolder};
5
6#[derive(PartialEq, Eq, Default, Debug, Clone, Copy)]
11pub struct BiomeId(pub u32);
12impl From<u32> for BiomeId {
13 fn from(id: u32) -> Self {
14 Self(id)
15 }
16}
17impl From<BiomeId> for u32 {
18 fn from(b: BiomeId) -> Self {
19 b.0
20 }
21}
22
23impl BiomeId {
24 pub fn into_biome(&self, registries: &RegistryHolder) -> Result<Biome, BufReadError> {
26 Biome::from_id(registries.into(), self.0)
27 }
28 pub fn from_biome(registries: &RegistryHolder, biome: Biome) -> io::Result<BiomeId> {
30 biome.to_id(registries.into()).map(BiomeId)
31 }
32}