mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
world/chunk: include biomes in section iterator item
This commit is contained in:
parent
ddc515a9d7
commit
0d2c99dacf
2 changed files with 36 additions and 25 deletions
|
@ -50,10 +50,12 @@ enum SectionIterInner<'a> {
|
|||
/// Iterator over sections of [Chunk::V1_13]
|
||||
V1_13 {
|
||||
iter: btree_map::Iter<'a, SectionY, (SectionV1_13<'a>, BlockLight<'a>)>,
|
||||
biomes: &'a BiomesV0<'a>,
|
||||
},
|
||||
/// Iterator over sections of [Chunk::V0]
|
||||
V0 {
|
||||
iter: btree_map::Iter<'a, SectionY, (SectionV0<'a>, BlockLight<'a>)>,
|
||||
biomes: &'a BiomesV0<'a>,
|
||||
},
|
||||
/// Empty iterator over an unpopulated chunk ([Chunk::Empty])
|
||||
Empty,
|
||||
|
@ -208,11 +210,19 @@ impl<'a> Chunk<'a> {
|
|||
Chunk::V1_18 { section_map } => V1_18 {
|
||||
iter: section_map.iter(),
|
||||
},
|
||||
Chunk::V1_13 { section_map, .. } => V1_13 {
|
||||
Chunk::V1_13 {
|
||||
section_map,
|
||||
biomes,
|
||||
} => V1_13 {
|
||||
iter: section_map.iter(),
|
||||
biomes,
|
||||
},
|
||||
Chunk::V0 { section_map, .. } => V0 {
|
||||
Chunk::V0 {
|
||||
section_map,
|
||||
biomes,
|
||||
} => V0 {
|
||||
iter: section_map.iter(),
|
||||
biomes,
|
||||
},
|
||||
Chunk::Empty => Empty,
|
||||
},
|
||||
|
@ -224,6 +234,7 @@ impl<'a> Chunk<'a> {
|
|||
pub struct SectionIterItem<'a> {
|
||||
pub y: SectionY,
|
||||
pub section: &'a dyn Section,
|
||||
pub biomes: &'a dyn Biomes,
|
||||
pub block_light: BlockLight<'a>,
|
||||
}
|
||||
|
||||
|
@ -247,30 +258,29 @@ impl<'a> SectionIter<'a> {
|
|||
{
|
||||
match &mut self.inner {
|
||||
SectionIterInner::V1_18 { iter } => f(&mut iter.map(
|
||||
|(&y, (section, _, block_light))| SectionIterItem {
|
||||
|(&y, (section, biomes, block_light))| SectionIterItem {
|
||||
y,
|
||||
section,
|
||||
biomes,
|
||||
block_light: *block_light,
|
||||
},
|
||||
)),
|
||||
SectionIterInner::V1_13 { iter, biomes } => f(&mut iter.map(
|
||||
|(&y, (section, block_light))| SectionIterItem {
|
||||
y,
|
||||
section,
|
||||
biomes: *biomes,
|
||||
block_light: *block_light,
|
||||
},
|
||||
)),
|
||||
SectionIterInner::V0 { iter, biomes } => f(&mut iter.map(
|
||||
|(&y, (section, block_light))| SectionIterItem {
|
||||
y,
|
||||
section,
|
||||
biomes: *biomes,
|
||||
block_light: *block_light,
|
||||
},
|
||||
)),
|
||||
SectionIterInner::V1_13 { iter } => {
|
||||
f(
|
||||
&mut iter.map(|(&y, (section, block_light))| SectionIterItem {
|
||||
y,
|
||||
section,
|
||||
block_light: *block_light,
|
||||
}),
|
||||
)
|
||||
}
|
||||
SectionIterInner::V0 { iter } => {
|
||||
f(
|
||||
&mut iter.map(|(&y, (section, block_light))| SectionIterItem {
|
||||
y,
|
||||
section,
|
||||
block_light: *block_light,
|
||||
}),
|
||||
)
|
||||
}
|
||||
SectionIterInner::Empty => f(&mut iter::empty()),
|
||||
}
|
||||
}
|
||||
|
@ -286,8 +296,8 @@ impl<'a> Iterator for SectionIter<'a> {
|
|||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
match &self.inner {
|
||||
SectionIterInner::V1_18 { iter } => iter.size_hint(),
|
||||
SectionIterInner::V1_13 { iter } => iter.size_hint(),
|
||||
SectionIterInner::V0 { iter } => iter.size_hint(),
|
||||
SectionIterInner::V1_13 { iter, .. } => iter.size_hint(),
|
||||
SectionIterInner::V0 { iter, .. } => iter.size_hint(),
|
||||
SectionIterInner::Empty => (0, Some(0)),
|
||||
}
|
||||
}
|
||||
|
@ -307,8 +317,8 @@ impl<'a> ExactSizeIterator for SectionIter<'a> {
|
|||
fn len(&self) -> usize {
|
||||
match &self.inner {
|
||||
SectionIterInner::V1_18 { iter } => iter.len(),
|
||||
SectionIterInner::V1_13 { iter } => iter.len(),
|
||||
SectionIterInner::V0 { iter } => iter.len(),
|
||||
SectionIterInner::V1_13 { iter, .. } => iter.len(),
|
||||
SectionIterInner::V0 { iter, .. } => iter.len(),
|
||||
SectionIterInner::Empty => 0,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,7 @@ pub fn top_layer(chunk: &Chunk) -> Result<Option<(Box<BlockInfoArray>, Box<Block
|
|||
for SectionIterItem {
|
||||
y: section_y,
|
||||
section,
|
||||
biomes: _,
|
||||
block_light,
|
||||
} in chunk.sections().rev()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue