-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor, moving chunks to another file and using it everywhere
- Loading branch information
1 parent
1bb5261
commit 1136eb4
Showing
2 changed files
with
29 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::fs::File; | ||
|
||
use fastanvil::{ChunkData, Region}; | ||
use itertools::iproduct; | ||
|
||
/// Used instead of Region.iter(), which skips over missing chunks | ||
pub fn chunks(region: &mut Region<File>) -> impl Iterator<Item = Option<ChunkData>> + '_ { | ||
// x should be the first-changing index - see header_pos in fastanvil | ||
iproduct!(0..32, 0..32).map(|(chunk_z, chunk_x)| { | ||
region | ||
.read_chunk(chunk_x, chunk_z) | ||
.unwrap() | ||
.map(|data| ChunkData { | ||
x: chunk_x, | ||
z: chunk_z, | ||
data, | ||
}) | ||
}) | ||
} |