diff --git a/src/world/section.rs b/src/world/section.rs index 5d2781a..e11f40a 100644 --- a/src/world/section.rs +++ b/src/world/section.rs @@ -217,24 +217,22 @@ impl<'a> BiomesV1_18<'a> { } } -/// Pre-v1.18 section biome data +/// Pre-v1.18 section biome data variants /// /// There are a 3 formats for biome data that were used in /// different pre-v1.18 Minecraft versions #[derive(Debug)] -pub enum BiomesV0<'a> { - IntArrayV15 { - data: &'a fastnbt::IntArray, - biome_types: &'a BiomeTypes, - }, - IntArrayV0 { - data: &'a fastnbt::IntArray, - biome_types: &'a BiomeTypes, - }, - ByteArray { - data: &'a fastnbt::ByteArray, - biome_types: &'a BiomeTypes, - }, +enum BiomesV0Data<'a> { + IntArrayV15(&'a fastnbt::IntArray), + IntArrayV0(&'a fastnbt::IntArray), + ByteArray(&'a fastnbt::ByteArray), +} + +/// Pre-v1.18 section biome data +#[derive(Debug)] +pub struct BiomesV0<'a> { + data: BiomesV0Data<'a>, + biome_types: &'a BiomeTypes, } impl<'a> BiomesV0<'a> { @@ -245,18 +243,19 @@ impl<'a> BiomesV0<'a> { const BN: usize = N >> 2; const BMAXY: usize = MAXY >> 2; - Ok(match biomes { + let data = match biomes { Some(de::BiomesV0::IntArray(data)) if data.len() == BN * BN * BMAXY => { - BiomesV0::IntArrayV15 { data, biome_types } + BiomesV0Data::IntArrayV15(data) } Some(de::BiomesV0::IntArray(data)) if data.len() == N * N => { - BiomesV0::IntArrayV0 { data, biome_types } + BiomesV0Data::IntArrayV0(data) } Some(de::BiomesV0::ByteArray(data)) if data.len() == N * N => { - BiomesV0::ByteArray { data, biome_types } + BiomesV0Data::ByteArray(data) } _ => bail!("Invalid biome data"), - }) + }; + Ok(BiomesV0 { data, biome_types }) } }