mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-05 17:44:52 +01:00
world: resolve biome palette entries for v1.18 biome data
This commit is contained in:
parent
b8b0e0627f
commit
c6843cfb9c
1 changed files with 15 additions and 4 deletions
|
@ -5,7 +5,7 @@ use num_integer::div_rem;
|
||||||
|
|
||||||
use super::de;
|
use super::de;
|
||||||
use crate::{
|
use crate::{
|
||||||
resource::{BiomeTypes, BlockType, BlockTypes},
|
resource::{Biome, BiomeTypes, BlockType, BlockTypes},
|
||||||
types::*,
|
types::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ impl<'a> Section for SectionV0<'a> {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct BiomesV1_18<'a> {
|
pub struct BiomesV1_18<'a> {
|
||||||
_biomes: Option<&'a [i64]>,
|
_biomes: Option<&'a [i64]>,
|
||||||
_palette: &'a [String],
|
_palette: Vec<Option<&'a Biome>>,
|
||||||
_bits: u8,
|
_bits: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ impl<'a> BiomesV1_18<'a> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
biomes: Option<&'a [i64]>,
|
biomes: Option<&'a [i64]>,
|
||||||
palette: &'a [String],
|
palette: &'a [String],
|
||||||
_biome_types: &'a BiomeTypes,
|
biome_types: &'a BiomeTypes,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let bits = palette_bits(palette.len(), 1, 6).context("Unsupported block palette size")?;
|
let bits = palette_bits(palette.len(), 1, 6).context("Unsupported block palette size")?;
|
||||||
|
|
||||||
|
@ -198,9 +198,20 @@ impl<'a> BiomesV1_18<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let palette_types = palette
|
||||||
|
.iter()
|
||||||
|
.map(|entry| {
|
||||||
|
let biome_type = biome_types.get(entry);
|
||||||
|
if biome_type.is_none() {
|
||||||
|
eprintln!("Unknown biome type: {}", entry);
|
||||||
|
}
|
||||||
|
biome_type
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
Ok(BiomesV1_18 {
|
Ok(BiomesV1_18 {
|
||||||
_biomes: biomes,
|
_biomes: biomes,
|
||||||
_palette: palette,
|
_palette: palette_types,
|
||||||
_bits: bits,
|
_bits: bits,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue