From 51602d5fc1d79987f7a9c011c84db452ea175e64 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 4 Mar 2023 17:32:58 +0100 Subject: [PATCH] world/chunk: add block light to section iterator items --- src/world/chunk.rs | 27 ++++++++++++++++++++++----- src/world/layer.rs | 1 + 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/world/chunk.rs b/src/world/chunk.rs index 6895ea7..984d8fe 100644 --- a/src/world/chunk.rs +++ b/src/world/chunk.rs @@ -203,6 +203,7 @@ impl<'a> Chunk<'a> { pub struct SectionIterItem<'a> { pub y: SectionY, pub section: &'a dyn Section, + pub block_light: BlockLight<'a>, } trait SectionIterTrait<'a>: @@ -224,14 +225,30 @@ impl<'a> SectionIter<'a> { F: FnOnce(&mut dyn SectionIterTrait<'a>) -> T, { match &mut self.inner { - SectionIterInner::V1_18 { iter } => { - f(&mut iter.map(|(&y, (section, _, _))| SectionIterItem { y, section })) - } + SectionIterInner::V1_18 { iter } => f(&mut iter.map( + |(&y, (section, _, block_light))| SectionIterItem { + y, + section, + block_light: *block_light, + }, + )), SectionIterInner::V1_13 { iter } => { - f(&mut iter.map(|(&y, (section, _))| SectionIterItem { y, section })) + f( + &mut iter.map(|(&y, (section, block_light))| SectionIterItem { + y, + section, + block_light: *block_light, + }), + ) } SectionIterInner::V0 { iter } => { - f(&mut iter.map(|(&y, (section, _))| SectionIterItem { y, section })) + f( + &mut iter.map(|(&y, (section, block_light))| SectionIterItem { + y, + section, + block_light: *block_light, + }), + ) } SectionIterInner::Empty => f(&mut iter::empty()), } diff --git a/src/world/layer.rs b/src/world/layer.rs index 5541e34..2fd879b 100644 --- a/src/world/layer.rs +++ b/src/world/layer.rs @@ -100,6 +100,7 @@ pub fn top_layer(chunk: &Chunk) -> Result> { for SectionIterItem { y: section_y, section, + block_light: _, } in chunk.sections().rev() { for y in BlockY::iter().rev() {