aboutsummaryrefslogtreecommitdiff
path: root/azalea-world/src/lib.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-01 18:59:07 -0500
committermat <github@matdoes.dev>2022-05-01 18:59:07 -0500
commit4d75415130a008f83c3bd594ca4cefd01f3d53dd (patch)
treee49084ef517a88bf8fd664459eb9634b647bb29e /azalea-world/src/lib.rs
parentc2262a212328e7a9e00091d7b41a8d8bfb5b3007 (diff)
downloadazalea-drasl-4d75415130a008f83c3bd594ca4cefd01f3d53dd.tar.xz
start adding azalea-world
Diffstat (limited to 'azalea-world/src/lib.rs')
-rw-r--r--azalea-world/src/lib.rs43
1 files changed, 43 insertions, 0 deletions
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,
+ }
+ }
+}