diff --git a/Cargo.lock b/Cargo.lock index 254dc5db..2e028643 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,6 +164,10 @@ dependencies = [ "uuid", ] +[[package]] +name = "azalea-world" +version = "0.1.0" + [[package]] name = "bitflags" version = "1.3.2" diff --git a/Cargo.toml b/Cargo.toml index f7272ff7..a7b0adb5 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ members = [ "azalea-nbt", "azalea-brigadier", "azalea-crypto", + "azalea-world", ] [profile.release] diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index 826bce3d..52ae1071 100755 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -233,6 +233,7 @@ impl Client { } GamePacket::ClientboundLevelChunkWithLightPacket(p) => { println!("Got chunk with light packet {} {}", p.x, p.z); + // p.chunk_data } GamePacket::ClientboundLightUpdatePacket(p) => { println!("Got light update packet {:?}", p); diff --git a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs index 1d017c2a..abd936dc 100644 --- a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs @@ -30,5 +30,7 @@ pub struct BlockEntity { pub struct ChunkSection {} impl ClientboundLevelChunkPacketData { - pub fn read(world_height: u32) {} + pub fn read(world_height: u32) { + // let section_count + } } 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
, +} + +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, +} + +pub enum Palette { + /// ID of the corresponding entry in its global palette + SingleValue(u32), + LinearPalette(Vec), + HashmapPalette(Vec), + 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, + } + } +}