diff options
Diffstat (limited to 'azalea-world/src/heightmap.rs')
| -rw-r--r-- | azalea-world/src/heightmap.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/azalea-world/src/heightmap.rs b/azalea-world/src/heightmap.rs index ec73adf9..81aeb1e2 100644 --- a/azalea-world/src/heightmap.rs +++ b/azalea-world/src/heightmap.rs @@ -119,6 +119,25 @@ impl Heightmap { false } + + /// Get an iterator over the top available block positions in this + /// heightmap. + pub fn iter_first_available<'a>(&'a self) -> impl Iterator<Item = ChunkBlockPos> + 'a { + self.data.iter().enumerate().map(move |(index, height)| { + let x = (index % 16) as u8; + let z = (index / 16) as u8; + ChunkBlockPos::new(x, height as i32 + self.min_y, z) + }) + } + + /// Get an iterator over the top block positions in this heightmap. + pub fn iter_highest_taken<'a>(&'a self) -> impl Iterator<Item = ChunkBlockPos> + 'a { + self.data.iter().enumerate().map(move |(index, height)| { + let x = (index % 16) as u8; + let z = (index / 16) as u8; + ChunkBlockPos::new(x, height as i32 + self.min_y - 1, z) + }) + } } impl FromStr for HeightmapKind { |
