diff options
Diffstat (limited to 'azalea-world')
| -rw-r--r-- | azalea-world/Cargo.toml | 8 | ||||
| -rw-r--r-- | azalea-world/README.md | 3 | ||||
| -rw-r--r-- | azalea-world/src/lib.rs | 43 |
3 files changed, 54 insertions, 0 deletions
diff --git a/azalea-world/Cargo.toml b/azalea-world/Cargo.toml new file mode 100644 index 00000000..afae93a7 --- /dev/null +++ b/azalea-world/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "azalea-world" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/azalea-world/README.md b/azalea-world/README.md new file mode 100644 index 00000000..6f68ab42 --- /dev/null +++ b/azalea-world/README.md @@ -0,0 +1,3 @@ +# Azalea World + +The Minecraft world representation used in Azalea. diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs new file mode 100644 index 00000000..20043bbf --- /dev/null +++ b/azalea-world/src/lib.rs @@ -0,0 +1,43 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + let result = 2 + 2; + assert_eq!(result, 4); + } +} + +pub struct Chunk { + sections: Vec<Section>, +} + +pub struct Section { + states: PalettedContainer, + biomes: PalettedContainer, +} + +pub struct PalettedContainer { + bits_per_entry: u8, + palette: Palette, + /// Compacted list of indices pointing to entry IDs in the Palette. + data: Vec<i64>, +} + +pub enum Palette { + /// ID of the corresponding entry in its global palette + SingleValue(u32), + LinearPalette(Vec<u32>), + HashmapPalette(Vec<u32>), + GlobalPalette, +} + +impl Palette { + fn choose_palette_for_states(bits_per_entry: u8) -> &'static Palette { + match bits_per_entry { + 0 => &Palette::SingleValue, + 1..=4 => &Palette::LinearPalette, + 5..=8 => &Palette::HashmapPalette, + _ => &Palette::GlobalPalette, + } + } +} |
