diff options
| author | mat <github@matdoes.dev> | 2022-05-01 18:59:07 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-05-01 18:59:07 -0500 |
| commit | 4d75415130a008f83c3bd594ca4cefd01f3d53dd (patch) | |
| tree | e49084ef517a88bf8fd664459eb9634b647bb29e | |
| parent | c2262a212328e7a9e00091d7b41a8d8bfb5b3007 (diff) | |
| download | azalea-drasl-4d75415130a008f83c3bd594ca4cefd01f3d53dd.tar.xz | |
start adding azalea-world
| -rwxr-xr-x | Cargo.lock | 4 | ||||
| -rwxr-xr-x | Cargo.toml | 1 | ||||
| -rwxr-xr-x | azalea-client/src/connect.rs | 1 | ||||
| -rw-r--r-- | azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs | 4 | ||||
| -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 |
7 files changed, 63 insertions, 1 deletions
@@ -165,6 +165,10 @@ dependencies = [ ] [[package]] +name = "azalea-world" +version = "0.1.0" + +[[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -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<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, + } + } +} |
