aboutsummaryrefslogtreecommitdiff
path: root/azalea-world/src/heightmap.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-09-18 19:29:14 -0500
committermat <git@matdoes.dev>2023-09-18 19:29:14 -0500
commite6941b6a24deed617d09c6e08ba65278bb3bcf25 (patch)
treea647ca131cd87d7d6cdb463dd50f497f4320656b /azalea-world/src/heightmap.rs
parent856a3252f693421df519cbc4d9bc03cfc0f0c212 (diff)
downloadazalea-drasl-e6941b6a24deed617d09c6e08ba65278bb3bcf25.tar.xz
instanceloadedevent and a few fixes
Diffstat (limited to 'azalea-world/src/heightmap.rs')
-rw-r--r--azalea-world/src/heightmap.rs19
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 {