diff options
| author | mat <git@matdoes.dev> | 2023-09-18 19:29:14 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-09-18 19:29:14 -0500 |
| commit | e6941b6a24deed617d09c6e08ba65278bb3bcf25 (patch) | |
| tree | a647ca131cd87d7d6cdb463dd50f497f4320656b /azalea-world/src/heightmap.rs | |
| parent | 856a3252f693421df519cbc4d9bc03cfc0f0c212 (diff) | |
| download | azalea-drasl-e6941b6a24deed617d09c6e08ba65278bb3bcf25.tar.xz | |
instanceloadedevent and a few fixes
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 { |
