From 4d75415130a008f83c3bd594ca4cefd01f3d53dd Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 1 May 2022 18:59:07 -0500 Subject: start adding azalea-world --- azalea-client/src/connect.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'azalea-client/src') 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); -- cgit v1.2.3 From 8e42e1c5dfc54314585b564696044780e0407c2f Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 2 May 2022 23:07:06 +0000 Subject: more chunk and readme stuff --- Cargo.lock | 1 + README.md | 10 +++++++--- azalea-client/Cargo.toml | 1 + azalea-client/src/connect.rs | 3 ++- azalea-protocol/src/mc_buf/mod.rs | 6 ------ .../packets/game/clientbound_level_chunk_with_light_packet.rs | 1 - azalea-world/src/lib.rs | 6 +++++- 7 files changed, 16 insertions(+), 12 deletions(-) (limited to 'azalea-client/src') diff --git a/Cargo.lock b/Cargo.lock index b0fe3c05..3633a1af 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -99,6 +99,7 @@ dependencies = [ "azalea-core", "azalea-crypto", "azalea-protocol", + "azalea-world", "tokio", ] diff --git a/README.md b/README.md index 909ae47e..4c90ba42 100755 --- a/README.md +++ b/README.md @@ -1,20 +1,24 @@ # Azalea -A Rust crate for creating Minecraft bots. -

Azalea

+A Rust crate for creating Minecraft bots. + I named this Azalea because it sounds like a cool word and this is a cool library. This project was heavily inspired by PrismarineJS. +## Why + +I wanted a fun excuse to do something cool with Rust, and I also felt like I could do better than [Mineflayer](https://github.com/prismarinejs/mineflayer) in some areas. + ## Goals - Do everything a vanilla client can do - Be easy to use - Bypass most/all anticheats - Support the latest Minecraft version -- Be fast +- Be fast and memory efficient ## Example code diff --git a/azalea-client/Cargo.toml b/azalea-client/Cargo.toml index 55caadeb..1156f8de 100755 --- a/azalea-client/Cargo.toml +++ b/azalea-client/Cargo.toml @@ -10,4 +10,5 @@ azalea-auth = {path = "../azalea-auth"} azalea-core = {path = "../azalea-core"} azalea-crypto = {path = "../azalea-crypto"} azalea-protocol = {path = "../azalea-protocol"} +azalea-world = {path = "../azalea-world"} tokio = {version = "1.18.0", features = ["sync"]} diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index b628051a..be268eee 100755 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -13,6 +13,7 @@ use azalea_protocol::{ }, resolver, ServerAddress, }; +use azalea_world::Chunk; use std::sync::Arc; use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender}; use tokio::sync::Mutex; @@ -233,7 +234,7 @@ impl Client { } GamePacket::ClientboundLevelChunkWithLightPacket(p) => { println!("Got chunk with light packet {} {}", p.x, p.z); - // p.chunk_data + // let chunk = Chunk::read_with_world_height(&mut p.chunk_data); } GamePacket::ClientboundLightUpdatePacket(p) => { println!("Got light update packet {:?}", p); diff --git a/azalea-protocol/src/mc_buf/mod.rs b/azalea-protocol/src/mc_buf/mod.rs index 74d69441..a82334fb 100755 --- a/azalea-protocol/src/mc_buf/mod.rs +++ b/azalea-protocol/src/mc_buf/mod.rs @@ -1,11 +1,5 @@ //! Utilities for reading and writing for the Minecraft protocol -// TODO: have a separate azalea-protocol-definitions crate to house everything in mc_buf -// We need to do this to prevent cyclic dependencies. -// For example with azalea-protocol depending on azalea-world, -// it could be changed to azalea-protocol depending on azalea-world -// and azalea-world depending on azalea-protocol-definitions. - mod read; mod write; 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 0ab581ec..6810ceb2 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 @@ -27,4 +27,3 @@ pub struct BlockEntity { data: azalea_nbt::Tag, } -pub struct ChunkSection {} diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs index e6b90ad5..8e60a6d6 100644 --- a/azalea-world/src/lib.rs +++ b/azalea-world/src/lib.rs @@ -12,12 +12,16 @@ mod tests { const SECTION_HEIGHT: u32 = 16; +pub struct World { + +} + pub struct Chunk { pub sections: Vec
, } impl Chunk { - fn read_with_world_height(buf: &mut impl Read, world_height: u32) -> Result { + pub fn read_with_world_height(buf: &mut impl Read, world_height: u32) -> Result { let section_count = world_height / SECTION_HEIGHT; let mut sections = Vec::with_capacity(section_count as usize); for _ in 0..section_count { -- cgit v1.2.3 From 0bd798045c4328208667df37348e9affb37e384f Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 3 May 2022 00:33:32 -0500 Subject: more azalea-world stuff --- Cargo.lock | 2 + azalea-client/src/connect.rs | 48 +- azalea-client/src/player.rs | 1 + azalea-core/src/block_pos.rs | 6 - azalea-core/src/lib.rs | 4 +- azalea-core/src/position.rs | 24 + azalea-nbt/src/tag.rs | 6 + .../clientbound_level_chunk_with_light_packet.rs | 15 +- .../game/clientbound_set_chunk_cache_center.rs | 2 +- azalea-world/Cargo.toml | 2 + azalea-world/src/lib.rs | 189 +- azalea-world/src/palette.rs | 73 + bot/src/main.rs | 2 +- login.txt | 4245 ++++++++++++++++++++ 14 files changed, 4523 insertions(+), 96 deletions(-) delete mode 100644 azalea-core/src/block_pos.rs create mode 100644 azalea-core/src/position.rs create mode 100644 azalea-world/src/palette.rs create mode 100644 login.txt (limited to 'azalea-client/src') diff --git a/Cargo.lock b/Cargo.lock index 3633a1af..73a8dafd 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,6 +166,8 @@ dependencies = [ name = "azalea-world" version = "0.1.0" dependencies = [ + "azalea-core", + "azalea-nbt", "azalea-protocol", ] diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index be268eee..e4d7d7e5 100755 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -1,5 +1,5 @@ use crate::Player; -use azalea_core::resource_location::ResourceLocation; +use azalea_core::{resource_location::ResourceLocation, ChunkPos}; use azalea_protocol::{ connect::{GameConnection, HandshakeConnection}, packets::{ @@ -13,8 +13,8 @@ use azalea_protocol::{ }, resolver, ServerAddress, }; -use azalea_world::Chunk; -use std::sync::Arc; +use azalea_world::{Chunk, ChunkStorage, World}; +use std::{fmt::Debug, ops::Deref, sync::Arc}; use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender}; use tokio::sync::Mutex; @@ -27,8 +27,8 @@ pub struct Account { #[derive(Default)] pub struct ClientState { - // placeholder pub player: Player, + pub world: Option, } /// A player that you can control that is currently in a Minecraft server. @@ -173,8 +173,31 @@ impl Client { match packet { GamePacket::ClientboundLoginPacket(p) => { println!("Got login packet {:?}", p); + std::fs::write("login.txt", format!("{:#?}", p)).expect("Unable to write file"); + + let mut state = state.lock().await; + state.player.entity.id = p.player_id; + let dimension_type = p + .dimension_type + .as_compound() + .expect("Dimension type is not compound") + .get("") + .expect("No \"\" tag") + .as_compound() + .expect("\"\" tag is not compound"); + let height = (*dimension_type + .get("height") + .expect("No height tag") + .as_int() + .expect("height tag is not int")) + .try_into() + .expect("height is not a u32"); + + state.world = Some(World { + height, + storage: ChunkStorage::new(16), + }); - state.lock().await.player.entity.id = p.player_id; conn.lock() .await .write( @@ -231,10 +254,25 @@ impl Client { } GamePacket::ClientboundSetChunkCacheCenterPacket(p) => { println!("Got chunk cache center packet {:?}", p); + state + .lock() + .await + .world + .as_mut() + .unwrap() + .update_view_center(&ChunkPos::new(p.x, p.z)); } GamePacket::ClientboundLevelChunkWithLightPacket(p) => { println!("Got chunk with light packet {} {}", p.x, p.z); + let pos = ChunkPos::new(p.x, p.z); // let chunk = Chunk::read_with_world_height(&mut p.chunk_data); + // println("chunk {:?}") + state + .lock() + .await + .world + .replace_with_packet_data(&pos, &mut p.chunk_data.data.as_slice()) + .unwrap(); } GamePacket::ClientboundLightUpdatePacket(p) => { println!("Got light update packet {:?}", p); diff --git a/azalea-client/src/player.rs b/azalea-client/src/player.rs index fc54ff93..70ac1c76 100644 --- a/azalea-client/src/player.rs +++ b/azalea-client/src/player.rs @@ -1,4 +1,5 @@ use crate::Entity; +use azalea_world::World; #[derive(Default)] pub struct Player { diff --git a/azalea-core/src/block_pos.rs b/azalea-core/src/block_pos.rs deleted file mode 100644 index 96a234cb..00000000 --- a/azalea-core/src/block_pos.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[derive(Clone, Copy, Debug)] -pub struct BlockPos { - pub x: i32, - pub y: i32, - pub z: i32, -} diff --git a/azalea-core/src/lib.rs b/azalea-core/src/lib.rs index c6b51cb1..6f0c25cc 100755 --- a/azalea-core/src/lib.rs +++ b/azalea-core/src/lib.rs @@ -8,8 +8,8 @@ pub mod serializable_uuid; mod slot; pub use slot::{Slot, SlotData}; -mod block_pos; -pub use block_pos::BlockPos; +mod position; +pub use position::{BlockPos, ChunkPos}; mod direction; pub use direction::Direction; diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs new file mode 100644 index 00000000..aa82c1f9 --- /dev/null +++ b/azalea-core/src/position.rs @@ -0,0 +1,24 @@ +#[derive(Clone, Copy, Debug, Default)] +pub struct BlockPos { + pub x: i32, + pub y: i32, + pub z: i32, +} + +impl BlockPos { + pub fn new(x: i32, y: i32, z: i32) -> Self { + BlockPos { x, y, z } + } +} + +#[derive(Clone, Copy, Debug, Default)] +pub struct ChunkPos { + pub x: i32, + pub z: i32, +} + +impl ChunkPos { + pub fn new(x: i32, z: i32) -> Self { + ChunkPos { x, z } + } +} diff --git a/azalea-nbt/src/tag.rs b/azalea-nbt/src/tag.rs index 61bd15ba..e2df08f7 100755 --- a/azalea-nbt/src/tag.rs +++ b/azalea-nbt/src/tag.rs @@ -17,6 +17,12 @@ pub enum Tag { LongArray(Vec), // 12 } +impl Default for Tag { + fn default() -> Self { + Tag::End + } +} + impl Tag { #[inline] pub fn id(&self) -> u8 { 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 6810ceb2..1d4bf58c 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 @@ -12,18 +12,17 @@ pub struct ClientboundLevelChunkWithLightPacket { #[derive(Clone, Debug, McBufReadable, McBufWritable)] pub struct ClientboundLevelChunkPacketData { - heightmaps: azalea_nbt::Tag, + pub heightmaps: azalea_nbt::Tag, // we can't parse the data in azalea-protocol because it dependso on context from other packets - data: Vec, - block_entities: Vec, + pub data: Vec, + pub block_entities: Vec, } #[derive(Clone, Debug, McBufReadable, McBufWritable)] pub struct BlockEntity { - packed_xz: u8, - y: u16, + pub packed_xz: u8, + pub y: u16, #[varint] - type_: i32, - data: azalea_nbt::Tag, + pub type_: i32, + pub data: azalea_nbt::Tag, } - diff --git a/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center.rs b/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center.rs index 482dc0c7..5b6de0c9 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center.rs @@ -5,5 +5,5 @@ pub struct ClientboundSetChunkCacheCenterPacket { #[varint] pub x: i32, #[varint] - pub y: i32, + pub z: i32, } diff --git a/azalea-world/Cargo.toml b/azalea-world/Cargo.toml index 54326fb7..e8d81ac3 100644 --- a/azalea-world/Cargo.toml +++ b/azalea-world/Cargo.toml @@ -6,4 +6,6 @@ version = "0.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +azalea-core = {path = "../azalea-core"} +azalea-nbt = {path = "../azalea-nbt"} azalea-protocol = {path = "../azalea-protocol"} diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs index 8e60a6d6..51bc0764 100644 --- a/azalea-world/src/lib.rs +++ b/azalea-world/src/lib.rs @@ -1,5 +1,13 @@ -use azalea_protocol::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; -use std::io::{Read, Write}; +mod palette; + +use azalea_core::ChunkPos; +use azalea_protocol::mc_buf::{McBufReadable, McBufWritable}; +use palette::PalettedContainer; +use std::{ + io::{Read, Write}, + ops::{Index, IndexMut}, + sync::{Arc, Mutex}, +}; #[cfg(test)] mod tests { @@ -13,14 +21,107 @@ mod tests { const SECTION_HEIGHT: u32 = 16; pub struct World { - + pub storage: ChunkStorage, + pub height: u32, +} + +impl World { + pub fn replace_with_packet_data( + &mut self, + pos: &ChunkPos, + data: &mut impl Read, + ) -> Result<(), String> { + if !self.storage.in_range(pos) { + println!( + "Ignoring chunk since it's not in the view range: {}, {}", + pos.x, pos.z + ); + return Ok(()); + } + let existing_chunk = &self.storage[pos]; + if let Some(existing_chunk) = existing_chunk { + existing_chunk + .lock() + .expect("Couldn't get lock on existing chunk") + .replace_with_packet_data(data)?; + } else { + let chunk = Arc::new(Mutex::new(Chunk::read_with_world(data, self)?)); + println!("Loaded chunk {:?}", chunk); + self.storage[pos] = Some(chunk); + } + + Ok(()) + } + + pub fn update_view_center(&mut self, pos: &ChunkPos) { + self.storage.view_center = *pos; + } +} + +pub struct ChunkStorage { + view_center: ChunkPos, + chunk_radius: u32, + view_range: u32, + // chunks is a list of size chunk_radius * chunk_radius + chunks: Vec>>>, +} + +// java moment +// it might be possible to replace this with just a modulo, but i copied java's floorMod just in case +fn floor_mod(x: i32, y: u32) -> u32 { + if x < 0 { + y - ((-x) as u32 % y) + } else { + x as u32 % y + } +} + +impl ChunkStorage { + pub fn new(chunk_radius: u32) -> Self { + let view_range = chunk_radius * 2 + 1; + ChunkStorage { + view_center: ChunkPos::new(0, 0), + chunk_radius, + view_range, + chunks: vec![None; (view_range * view_range) as usize], + } + } + + fn get_index(&self, chunk_pos: &ChunkPos) -> usize { + (floor_mod(chunk_pos.x, self.view_range) * self.view_range + + floor_mod(chunk_pos.z, self.view_range)) as usize + } + + pub fn in_range(&self, chunk_pos: &ChunkPos) -> bool { + (chunk_pos.x - self.view_center.x).unsigned_abs() <= self.chunk_radius + && (chunk_pos.z - self.view_center.z).unsigned_abs() <= self.chunk_radius + } +} + +impl Index<&ChunkPos> for ChunkStorage { + type Output = Option>>; + + fn index(&self, pos: &ChunkPos) -> &Self::Output { + &self.chunks[self.get_index(pos)] + } +} +impl IndexMut<&ChunkPos> for ChunkStorage { + fn index_mut<'a>(&'a mut self, pos: &ChunkPos) -> &'a mut Self::Output { + let index = self.get_index(pos); + &mut self.chunks[index] + } } +#[derive(Debug)] pub struct Chunk { pub sections: Vec
, } impl Chunk { + pub fn read_with_world(buf: &mut impl Read, data: &World) -> Result { + Self::read_with_world_height(buf, data.height) + } + pub fn read_with_world_height(buf: &mut impl Read, world_height: u32) -> Result { let section_count = world_height / SECTION_HEIGHT; let mut sections = Vec::with_capacity(section_count as usize); @@ -30,6 +131,18 @@ impl Chunk { } Ok(Chunk { sections }) } + + fn replace_with_packet_data(&mut self, data: &mut impl Read) -> Result<(), String> { + let section_count = self.sections.len(); + + // this should also replace block entities and set the heightmap + + for i in 0..section_count { + self.sections[i] = Section::read_into(data)?; + } + + Ok(()) + } } impl McBufWritable for Chunk { @@ -69,73 +182,3 @@ impl McBufWritable for Section { Ok(()) } } - -#[derive(Clone, Debug)] -pub struct PalettedContainer { - pub bits_per_entry: u8, - pub palette: Palette, - /// Compacted list of indices pointing to entry IDs in the Palette. - pub data: Vec, -} - -impl McBufReadable for PalettedContainer { - fn read_into(buf: &mut impl Read) -> Result { - let bits_per_entry = buf.read_byte()?; - let palette = Palette::read_with_bits_per_entry(buf, bits_per_entry)?; - let data = Vec::::read_into(buf)?; - Ok(PalettedContainer { - bits_per_entry, - palette, - data, - }) - } -} -impl McBufWritable for PalettedContainer { - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { - buf.write_byte(self.bits_per_entry)?; - self.palette.write_into(buf)?; - self.data.write_into(buf)?; - Ok(()) - } -} - -#[derive(Clone, Debug)] -pub enum Palette { - /// ID of the corresponding entry in its global palette - SingleValue(u32), - LinearPalette(Vec), - HashmapPalette(Vec), - GlobalPalette, -} - -impl Palette { - pub fn read_with_bits_per_entry( - buf: &mut impl Read, - bits_per_entry: u8, - ) -> Result { - Ok(match bits_per_entry { - 0 => Palette::SingleValue(u32::read_into(buf)?), - 1..=4 => Palette::LinearPalette(Vec::::read_into(buf)?), - 5..=8 => Palette::HashmapPalette(Vec::::read_into(buf)?), - _ => Palette::GlobalPalette, - }) - } -} - -impl McBufWritable for Palette { - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { - match self { - Palette::SingleValue(value) => { - value.write_into(buf)?; - } - Palette::LinearPalette(values) => { - values.write_into(buf)?; - } - Palette::HashmapPalette(values) => { - values.write_into(buf)?; - } - Palette::GlobalPalette => {} - } - Ok(()) - } -} diff --git a/azalea-world/src/palette.rs b/azalea-world/src/palette.rs new file mode 100644 index 00000000..a8ec50c9 --- /dev/null +++ b/azalea-world/src/palette.rs @@ -0,0 +1,73 @@ +use std::io::{Read, Write}; + +use azalea_protocol::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; + +#[derive(Clone, Debug)] +pub struct PalettedContainer { + pub bits_per_entry: u8, + pub palette: Palette, + /// Compacted list of indices pointing to entry IDs in the Palette. + pub data: Vec, +} + +impl McBufReadable for PalettedContainer { + fn read_into(buf: &mut impl Read) -> Result { + let bits_per_entry = buf.read_byte()?; + let palette = Palette::read_with_bits_per_entry(buf, bits_per_entry)?; + let data = Vec::::read_into(buf)?; + Ok(PalettedContainer { + bits_per_entry, + palette, + data, + }) + } +} +impl McBufWritable for PalettedContainer { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + buf.write_byte(self.bits_per_entry)?; + self.palette.write_into(buf)?; + self.data.write_into(buf)?; + Ok(()) + } +} + +#[derive(Clone, Debug)] +pub enum Palette { + /// ID of the corresponding entry in its global palette + SingleValue(u32), + LinearPalette(Vec), + HashmapPalette(Vec), + GlobalPalette, +} + +impl Palette { + pub fn read_with_bits_per_entry( + buf: &mut impl Read, + bits_per_entry: u8, + ) -> Result { + Ok(match bits_per_entry { + 0 => Palette::SingleValue(u32::read_into(buf)?), + 1..=4 => Palette::LinearPalette(Vec::::read_into(buf)?), + 5..=8 => Palette::HashmapPalette(Vec::::read_into(buf)?), + _ => Palette::GlobalPalette, + }) + } +} + +impl McBufWritable for Palette { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + match self { + Palette::SingleValue(value) => { + value.write_into(buf)?; + } + Palette::LinearPalette(values) => { + values.write_into(buf)?; + } + Palette::HashmapPalette(values) => { + values.write_into(buf)?; + } + Palette::GlobalPalette => {} + } + Ok(()) + } +} diff --git a/bot/src/main.rs b/bot/src/main.rs index 8314eb5c..6a2d5959 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -5,7 +5,7 @@ async fn main() { println!("Hello, world!"); // let address = "95.111.249.143:10000"; - let address = "172.23.192.1:58024"; + let address = "172.23.192.1:59152"; // let response = azalea_client::ping::ping_server(&address.try_into().unwrap()) // .await // .unwrap(); diff --git a/login.txt b/login.txt new file mode 100644 index 00000000..15e011e3 --- /dev/null +++ b/login.txt @@ -0,0 +1,4245 @@ +ClientboundLoginPacket { + player_id: 26888, + hardcore: false, + game_type: CREATIVE, + previous_game_type: None, + levels: [ + minecraft:overworld, + minecraft:the_end, + minecraft:the_nether, + ], + registry_holder: Compound( + { + "": Compound( + { + "minecraft:worldgen/biome": Compound( + { + "type": String( + "minecraft:worldgen/biome", + ), + "value": List( + [ + Compound( + { + "element": Compound( + { + "precipitation": String( + "none", + ), + "temperature": Float( + 0.5, + ), + "category": String( + "none", + ), + "effects": Compound( + { + "sky_color": Int( + 8103167, + ), + "fog_color": Int( + 12638463, + ), + "water_fog_color": Int( + 329011, + ), + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + }, + ), + "water_color": Int( + 4159204, + ), + }, + ), + "downfall": Float( + 0.5, + ), + }, + ), + "name": String( + "minecraft:the_void", + ), + "id": Int( + 0, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:plains", + ), + "id": Int( + 1, + ), + "element": Compound( + { + "category": String( + "plains", + ), + "effects": Compound( + { + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "tick_delay": Int( + 6000, + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "sky_color": Int( + 7907327, + ), + "water_fog_color": Int( + 329011, + ), + "water_color": Int( + 4159204, + ), + }, + ), + "precipitation": String( + "rain", + ), + "temperature": Float( + 0.8, + ), + "downfall": Float( + 0.4, + ), + }, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:sunflower_plains", + ), + "id": Int( + 2, + ), + "element": Compound( + { + "precipitation": String( + "rain", + ), + "downfall": Float( + 0.4, + ), + "effects": Compound( + { + "fog_color": Int( + 12638463, + ), + "water_color": Int( + 4159204, + ), + "water_fog_color": Int( + 329011, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + "offset": Double( + 2.0, + ), + }, + ), + "sky_color": Int( + 7907327, + ), + }, + ), + "category": String( + "plains", + ), + "temperature": Float( + 0.8, + ), + }, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:snowy_plains", + ), + "element": Compound( + { + "category": String( + "icy", + ), + "temperature": Float( + 0.0, + ), + "precipitation": String( + "snow", + ), + "downfall": Float( + 0.5, + ), + "effects": Compound( + { + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "offset": Double( + 2.0, + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + "water_color": Int( + 4159204, + ), + "sky_color": Int( + 8364543, + ), + "fog_color": Int( + 12638463, + ), + }, + ), + }, + ), + "id": Int( + 3, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:ice_spikes", + ), + "element": Compound( + { + "precipitation": String( + "snow", + ), + "temperature": Float( + 0.0, + ), + "category": String( + "icy", + ), + "downfall": Float( + 0.5, + ), + "effects": Compound( + { + "water_fog_color": Int( + 329011, + ), + "sky_color": Int( + 8364543, + ), + "fog_color": Int( + 12638463, + ), + "water_color": Int( + 4159204, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "block_search_extent": Int( + 8, + ), + "sound": String( + "minecraft:ambient.cave", + ), + }, + ), + }, + ), + }, + ), + "id": Int( + 4, + ), + }, + ), + Compound( + { + "id": Int( + 5, + ), + "name": String( + "minecraft:desert", + ), + "element": Compound( + { + "category": String( + "desert", + ), + "temperature": Float( + 2.0, + ), + "downfall": Float( + 0.0, + ), + "precipitation": String( + "none", + ), + "effects": Compound( + { + "sky_color": Int( + 7254527, + ), + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.cave", + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + "water_color": Int( + 4159204, + ), + }, + ), + }, + ), + }, + ), + Compound( + { + "element": Compound( + { + "category": String( + "swamp", + ), + "effects": Compound( + { + "water_color": Int( + 6388580, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "sky_color": Int( + 7907327, + ), + "grass_color_modifier": String( + "swamp", + ), + "foliage_color": Int( + 6975545, + ), + "water_fog_color": Int( + 2302743, + ), + "fog_color": Int( + 12638463, + ), + }, + ), + "precipitation": String( + "rain", + ), + "temperature": Float( + 0.8, + ), + "downfall": Float( + 0.9, + ), + }, + ), + "id": Int( + 6, + ), + "name": String( + "minecraft:swamp", + ), + }, + ), + Compound( + { + "id": Int( + 7, + ), + "element": Compound( + { + "temperature": Float( + 0.7, + ), + "category": String( + "forest", + ), + "precipitation": String( + "rain", + ), + "downfall": Float( + 0.8, + ), + "effects": Compound( + { + "water_fog_color": Int( + 329011, + ), + "sky_color": Int( + 7972607, + ), + "water_color": Int( + 4159204, + ), + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "offset": Double( + 2.0, + ), + }, + ), + "fog_color": Int( + 12638463, + ), + }, + ), + }, + ), + "name": String( + "minecraft:forest", + ), + }, + ), + Compound( + { + "id": Int( + 8, + ), + "element": Compound( + { + "effects": Compound( + { + "sky_color": Int( + 7972607, + ), + "water_color": Int( + 4159204, + ), + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "block_search_extent": Int( + 8, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + }, + ), + "precipitation": String( + "rain", + ), + "category": String( + "forest", + ), + "temperature": Float( + 0.7, + ), + "downfall": Float( + 0.8, + ), + }, + ), + "name": String( + "minecraft:flower_forest", + ), + }, + ), + Compound( + { + "name": String( + "minecraft:birch_forest", + ), + "element": Compound( + { + "precipitation": String( + "rain", + ), + "effects": Compound( + { + "sky_color": Int( + 8037887, + ), + "water_fog_color": Int( + 329011, + ), + "water_color": Int( + 4159204, + ), + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + }, + ), + "fog_color": Int( + 12638463, + ), + }, + ), + "downfall": Float( + 0.6, + ), + "temperature": Float( + 0.6, + ), + "category": String( + "forest", + ), + }, + ), + "id": Int( + 9, + ), + }, + ), + Compound( + { + "id": Int( + 10, + ), + "element": Compound( + { + "downfall": Float( + 0.8, + ), + "precipitation": String( + "rain", + ), + "category": String( + "forest", + ), + "effects": Compound( + { + "water_color": Int( + 4159204, + ), + "grass_color_modifier": String( + "dark_forest", + ), + "sky_color": Int( + 7972607, + ), + "fog_color": Int( + 12638463, + ), + "water_fog_color": Int( + 329011, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + }, + ), + "temperature": Float( + 0.7, + ), + }, + ), + "name": String( + "minecraft:dark_forest", + ), + }, + ), + Compound( + { + "id": Int( + 11, + ), + "element": Compound( + { + "precipitation": String( + "rain", + ), + "downfall": Float( + 0.6, + ), + "temperature": Float( + 0.6, + ), + "effects": Compound( + { + "fog_color": Int( + 12638463, + ), + "sky_color": Int( + 8037887, + ), + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "tick_delay": Int( + 6000, + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + "water_color": Int( + 4159204, + ), + }, + ), + "category": String( + "forest", + ), + }, + ), + "name": String( + "minecraft:old_growth_birch_forest", + ), + }, + ), + Compound( + { + "name": String( + "minecraft:old_growth_pine_taiga", + ), + "element": Compound( + { + "precipitation": String( + "rain", + ), + "category": String( + "taiga", + ), + "effects": Compound( + { + "water_color": Int( + 4159204, + ), + "sky_color": Int( + 8168447, + ), + "water_fog_color": Int( + 329011, + ), + "mood_sound": Compound( + { + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + }, + ), + "fog_color": Int( + 12638463, + ), + }, + ), + "temperature": Float( + 0.3, + ), + "downfall": Float( + 0.8, + ), + }, + ), + "id": Int( + 12, + ), + }, + ), + Compound( + { + "id": Int( + 13, + ), + "name": String( + "minecraft:old_growth_spruce_taiga", + ), + "element": Compound( + { + "category": String( + "taiga", + ), + "downfall": Float( + 0.8, + ), + "precipitation": String( + "rain", + ), + "effects": Compound( + { + "sky_color": Int( + 8233983, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + "fog_color": Int( + 12638463, + ), + "water_color": Int( + 4159204, + ), + }, + ), + "temperature": Float( + 0.25, + ), + }, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:taiga", + ), + "id": Int( + 14, + ), + "element": Compound( + { + "temperature": Float( + 0.25, + ), + "downfall": Float( + 0.8, + ), + "precipitation": String( + "rain", + ), + "category": String( + "taiga", + ), + "effects": Compound( + { + "sky_color": Int( + 8233983, + ), + "water_fog_color": Int( + 329011, + ), + "water_color": Int( + 4159204, + ), + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.cave", + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "fog_color": Int( + 12638463, + ), + }, + ), + }, + ), + }, + ), + Compound( + { + "id": Int( + 15, + ), + "element": Compound( + { + "downfall": Float( + 0.4, + ), + "temperature": Float( + -0.5, + ), + "effects": Compound( + { + "water_color": Int( + 4020182, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "fog_color": Int( + 12638463, + ), + "sky_color": Int( + 8625919, + ), + "water_fog_color": Int( + 329011, + ), + }, + ), + "category": String( + "taiga", + ), + "precipitation": String( + "snow", + ), + }, + ), + "name": String( + "minecraft:snowy_taiga", + ), + }, + ), + Compound( + { + "element": Compound( + { + "temperature": Float( + 2.0, + ), + "downfall": Float( + 0.0, + ), + "effects": Compound( + { + "sky_color": Int( + 7254527, + ), + "water_fog_color": Int( + 329011, + ), + "water_color": Int( + 4159204, + ), + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "offset": Double( + 2.0, + ), + }, + ), + }, + ), + "precipitation": String( + "none", + ), + "category": String( + "savanna", + ), + }, + ), + "name": String( + "minecraft:savanna", + ), + "id": Int( + 16, + ), + }, + ), + Compound( + { + "id": Int( + 17, + ), + "name": String( + "minecraft:savanna_plateau", + ), + "element": Compound( + { + "downfall": Float( + 0.0, + ), + "category": String( + "savanna", + ), + "precipitation": String( + "none", + ), + "temperature": Float( + 2.0, + ), + "effects": Compound( + { + "mood_sound": Compound( + { + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + }, + ), + "water_color": Int( + 4159204, + ), + "fog_color": Int( + 12638463, + ), + "sky_color": Int( + 7254527, + ), + "water_fog_color": Int( + 329011, + ), + }, + ), + }, + ), + }, + ), + Compound( + { + "id": Int( + 18, + ), + "name": String( + "minecraft:windswept_hills", + ), + "element": Compound( + { + "temperature": Float( + 0.2, + ), + "precipitation": String( + "rain", + ), + "downfall": Float( + 0.3, + ), + "effects": Compound( + { + "fog_color": Int( + 12638463, + ), + "water_color": Int( + 4159204, + ), + "sky_color": Int( + 8233727, + ), + "water_fog_color": Int( + 329011, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + }, + ), + "category": String( + "extreme_hills", + ), + }, + ), + }, + ), + Compound( + { + "id": Int( + 19, + ), + "element": Compound( + { + "temperature": Float( + 0.2, + ), + "precipitation": String( + "rain", + ), + "category": String( + "extreme_hills", + ), + "effects": Compound( + { + "water_color": Int( + 4159204, + ), + "water_fog_color": Int( + 329011, + ), + "sky_color": Int( + 8233727, + ), + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + }, + ), + "downfall": Float( + 0.3, + ), + }, + ), + "name": String( + "minecraft:windswept_gravelly_hills", + ), + }, + ), + Compound( + { + "name": String( + "minecraft:windswept_forest", + ), + "id": Int( + 20, + ), + "element": Compound( + { + "category": String( + "extreme_hills", + ), + "effects": Compound( + { + "water_color": Int( + 4159204, + ), + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.cave", + ), + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + "sky_color": Int( + 8233727, + ), + }, + ), + "downfall": Float( + 0.3, + ), + "precipitation": String( + "rain", + ), + "temperature": Float( + 0.2, + ), + }, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:windswept_savanna", + ), + "element": Compound( + { + "temperature": Float( + 2.0, + ), + "downfall": Float( + 0.0, + ), + "category": String( + "savanna", + ), + "effects": Compound( + { + "water_color": Int( + 4159204, + ), + "water_fog_color": Int( + 329011, + ), + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + }, + ), + "sky_color": Int( + 7254527, + ), + "fog_color": Int( + 12638463, + ), + }, + ), + "precipitation": String( + "none", + ), + }, + ), + "id": Int( + 21, + ), + }, + ), + Compound( + { + "id": Int( + 22, + ), + "name": String( + "minecraft:jungle", + ), + "element": Compound( + { + "precipitation": String( + "rain", + ), + "temperature": Float( + 0.95, + ), + "downfall": Float( + 0.9, + ), + "category": String( + "jungle", + ), + "effects": Compound( + { + "sky_color": Int( + 7842047, + ), + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "water_color": Int( + 4159204, + ), + "water_fog_color": Int( + 329011, + ), + }, + ), + }, + ), + }, + ), + Compound( + { + "element": Compound( + { + "temperature": Float( + 0.95, + ), + "precipitation": String( + "rain", + ), + "effects": Compound( + { + "water_fog_color": Int( + 329011, + ), + "fog_color": Int( + 12638463, + ), + "water_color": Int( + 4159204, + ), + "mood_sound": Compound( + { + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "sky_color": Int( + 7842047, + ), + }, + ), + "category": String( + "jungle", + ), + "downfall": Float( + 0.8, + ), + }, + ), + "id": Int( + 23, + ), + "name": String( + "minecraft:sparse_jungle", + ), + }, + ), + Compound( + { + "name": String( + "minecraft:bamboo_jungle", + ), + "id": Int( + 24, + ), + "element": Compound( + { + "effects": Compound( + { + "water_fog_color": Int( + 329011, + ), + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.cave", + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "sky_color": Int( + 7842047, + ), + "water_color": Int( + 4159204, + ), + }, + ), + "downfall": Float( + 0.9, + ), + "temperature": Float( + 0.95, + ), + "precipitation": String( + "rain", + ), + "category": String( + "jungle", + ), + }, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:badlands", + ), + "id": Int( + 25, + ), + "element": Compound( + { + "effects": Compound( + { + "sky_color": Int( + 7254527, + ), + "foliage_color": Int( + 10387789, + ), + "water_fog_color": Int( + 329011, + ), + "fog_color": Int( + 12638463, + ), + "water_color": Int( + 4159204, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "block_search_extent": Int( + 8, + ), + "sound": String( + "minecraft:ambient.cave", + ), + }, + ), + "grass_color": Int( + 9470285, + ), + }, + ), + "category": String( + "mesa", + ), + "precipitation": String( + "none", + ), + "downfall": Float( + 0.0, + ), + "temperature": Float( + 2.0, + ), + }, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:eroded_badlands", + ), + "id": Int( + 26, + ), + "element": Compound( + { + "downfall": Float( + 0.0, + ), + "effects": Compound( + { + "fog_color": Int( + 12638463, + ), + "grass_color": Int( + 9470285, + ), + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + }, + ), + "foliage_color": Int( + 10387789, + ), + "sky_color": Int( + 7254527, + ), + "water_fog_color": Int( + 329011, + ), + "water_color": Int( + 4159204, + ), + }, + ), + "precipitation": String( + "none", + ), + "category": String( + "mesa", + ), + "temperature": Float( + 2.0, + ), + }, + ), + }, + ), + Compound( + { + "element": Compound( + { + "effects": Compound( + { + "sky_color": Int( + 7254527, + ), + "foliage_color": Int( + 10387789, + ), + "fog_color": Int( + 12638463, + ), + "water_color": Int( + 4159204, + ), + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.cave", + ), + "tick_delay": Int( + 6000, + ), + "block_search_extent": Int( + 8, + ), + "offset": Double( + 2.0, + ), + }, + ), + "grass_color": Int( + 9470285, + ), + "water_fog_color": Int( + 329011, + ), + }, + ), + "temperature": Float( + 2.0, + ), + "downfall": Float( + 0.0, + ), + "category": String( + "mesa", + ), + "precipitation": String( + "none", + ), + }, + ), + "name": String( + "minecraft:wooded_badlands", + ), + "id": Int( + 27, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:meadow", + ), + "id": Int( + 28, + ), + "element": Compound( + { + "precipitation": String( + "rain", + ), + "temperature": Float( + 0.5, + ), + "effects": Compound( + { + "sky_color": Int( + 8103167, + ), + "water_color": Int( + 937679, + ), + "water_fog_color": Int( + 329011, + ), + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + }, + ), + "music": Compound( + { + "sound": String( + "minecraft:music.overworld.meadow", + ), + "replace_current_music": Byte( + 0, + ), + "max_delay": Int( + 24000, + ), + "min_delay": Int( + 12000, + ), + }, + ), + }, + ), + "category": String( + "mountain", + ), + "downfall": Float( + 0.8, + ), + }, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:grove", + ), + "id": Int( + 29, + ), + "element": Compound( + { + "precipitation": String( + "snow", + ), + "effects": Compound( + { + "music": Compound( + { + "min_delay": Int( + 12000, + ), + "max_delay": Int( + 24000, + ), + "replace_current_music": Byte( + 0, + ), + "sound": String( + "minecraft:music.overworld.grove", + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + }, + ), + "sky_color": Int( + 8495359, + ), + "water_color": Int( + 4159204, + ), + }, + ), + "temperature": Float( + -0.2, + ), + "downfall": Float( + 0.8, + ), + "category": String( + "forest", + ), + }, + ), + }, + ), + Compound( + { + "element": Compound( + { + "temperature": Float( + -0.3, + ), + "precipitation": String( + "snow", + ), + "category": String( + "mountain", + ), + "effects": Compound( + { + "music": Compound( + { + "sound": String( + "minecraft:music.overworld.snowy_slopes", + ), + "min_delay": Int( + 12000, + ), + "max_delay": Int( + 24000, + ), + "replace_current_music": Byte( + 0, + ), + }, + ), + "sky_color": Int( + 8560639, + ), + "water_fog_color": Int( + 329011, + ), + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + }, + ), + "water_color": Int( + 4159204, + ), + }, + ), + "downfall": Float( + 0.9, + ), + }, + ), + "name": String( + "minecraft:snowy_slopes", + ), + "id": Int( + 30, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:frozen_peaks", + ), + "id": Int( + 31, + ), + "element": Compound( + { + "category": String( + "mountain", + ), + "precipitation": String( + "snow", + ), + "downfall": Float( + 0.9, + ), + "temperature": Float( + -0.7, + ), + "effects": Compound( + { + "sky_color": Int( + 8756735, + ), + "fog_color": Int( + 12638463, + ), + "water_color": Int( + 4159204, + ), + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + "music": Compound( + { + "sound": String( + "minecraft:music.overworld.frozen_peaks", + ), + "min_delay": Int( + 12000, + ), + "replace_current_music": Byte( + 0, + ), + "max_delay": Int( + 24000, + ), + }, + ), + }, + ), + }, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:jagged_peaks", + ), + "id": Int( + 32, + ), + "element": Compound( + { + "precipitation": String( + "snow", + ), + "effects": Compound( + { + "water_color": Int( + 4159204, + ), + "music": Compound( + { + "replace_current_music": Byte( + 0, + ), + "max_delay": Int( + 24000, + ), + "sound": String( + "minecraft:music.overworld.jagged_peaks", + ), + "min_delay": Int( + 12000, + ), + }, + ), + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.cave", + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "sky_color": Int( + 8756735, + ), + "water_fog_color": Int( + 329011, + ), + }, + ), + "temperature": Float( + -0.7, + ), + "downfall": Float( + 0.9, + ), + "category": String( + "mountain", + ), + }, + ), + }, + ), + Compound( + { + "id": Int( + 33, + ), + "element": Compound( + { + "precipitation": String( + "rain", + ), + "downfall": Float( + 0.3, + ), + "temperature": Float( + 1.0, + ), + "category": String( + "mountain", + ), + "effects": Compound( + { + "fog_color": Int( + 12638463, + ), + "water_fog_color": Int( + 329011, + ), + "music": Compound( + { + "sound": String( + "minecraft:music.overworld.stony_peaks", + ), + "replace_current_music": Byte( + 0, + ), + "max_delay": Int( + 24000, + ), + "min_delay": Int( + 12000, + ), + }, + ), + "mood_sound": Compound( + { + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "sky_color": Int( + 7776511, + ), + "water_color": Int( + 4159204, + ), + }, + ), + }, + ), + "name": String( + "minecraft:stony_peaks", + ), + }, + ), + Compound( + { + "id": Int( + 34, + ), + "element": Compound( + { + "temperature": Float( + 0.5, + ), + "effects": Compound( + { + "fog_color": Int( + 12638463, + ), + "water_color": Int( + 4159204, + ), + "sky_color": Int( + 8103167, + ), + "water_fog_color": Int( + 329011, + ), + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + }, + ), + }, + ), + "precipitation": String( + "rain", + ), + "downfall": Float( + 0.5, + ), + "category": String( + "river", + ), + }, + ), + "name": String( + "minecraft:river", + ), + }, + ), + Compound( + { + "element": Compound( + { + "category": String( + "river", + ), + "precipitation": String( + "snow", + ), + "effects": Compound( + { + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + }, + ), + "sky_color": Int( + 8364543, + ), + "fog_color": Int( + 12638463, + ), + "water_color": Int( + 3750089, + ), + "water_fog_color": Int( + 329011, + ), + }, + ), + "temperature": Float( + 0.0, + ), + "downfall": Float( + 0.5, + ), + }, + ), + "name": String( + "minecraft:frozen_river", + ), + "id": Int( + 35, + ), + }, + ), + Compound( + { + "id": Int( + 36, + ), + "name": String( + "minecraft:beach", + ), + "element": Compound( + { + "temperature": Float( + 0.8, + ), + "precipitation": String( + "rain", + ), + "downfall": Float( + 0.4, + ), + "category": String( + "beach", + ), + "effects": Compound( + { + "water_color": Int( + 4159204, + ), + "mood_sound": Compound( + { + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + "sky_color": Int( + 7907327, + ), + "fog_color": Int( + 12638463, + ), + }, + ), + }, + ), + }, + ), + Compound( + { + "element": Compound( + { + "downfall": Float( + 0.3, + ), + "category": String( + "beach", + ), + "precipitation": String( + "snow", + ), + "effects": Compound( + { + "fog_color": Int( + 12638463, + ), + "sky_color": Int( + 8364543, + ), + "water_fog_color": Int( + 329011, + ), + "water_color": Int( + 4020182, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "block_search_extent": Int( + 8, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + }, + ), + }, + ), + "temperature": Float( + 0.05, + ), + }, + ), + "id": Int( + 37, + ), + "name": String( + "minecraft:snowy_beach", + ), + }, + ), + Compound( + { + "name": String( + "minecraft:stony_shore", + ), + "element": Compound( + { + "temperature": Float( + 0.2, + ), + "category": String( + "beach", + ), + "downfall": Float( + 0.3, + ), + "precipitation": String( + "rain", + ), + "effects": Compound( + { + "water_color": Int( + 4159204, + ), + "fog_color": Int( + 12638463, + ), + "water_fog_color": Int( + 329011, + ), + "mood_sound": Compound( + { + "offset": Double( + 2.0, + ), + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.cave", + ), + }, + ), + "sky_color": Int( + 8233727, + ), + }, + ), + }, + ), + "id": Int( + 38, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:warm_ocean", + ), + "id": Int( + 39, + ), + "element": Compound( + { + "downfall": Float( + 0.5, + ), + "precipitation": String( + "rain", + ), + "temperature": Float( + 0.5, + ), + "category": String( + "ocean", + ), + "effects": Compound( + { + "sky_color": Int( + 8103167, + ), + "water_color": Int( + 4445678, + ), + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + }, + ), + "water_fog_color": Int( + 270131, + ), + "fog_color": Int( + 12638463, + ), + }, + ), + }, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:lukewarm_ocean", + ), + "element": Compound( + { + "effects": Compound( + { + "fog_color": Int( + 12638463, + ), + "water_color": Int( + 4566514, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "offset": Double( + 2.0, + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "sky_color": Int( + 8103167, + ), + "water_fog_color": Int( + 267827, + ), + }, + ), + "temperature": Float( + 0.5, + ), + "precipitation": String( + "rain", + ), + "downfall": Float( + 0.5, + ), + "category": String( + "ocean", + ), + }, + ), + "id": Int( + 40, + ), + }, + ), + Compound( + { + "id": Int( + 41, + ), + "element": Compound( + { + "temperature": Float( + 0.5, + ), + "downfall": Float( + 0.5, + ), + "effects": Compound( + { + "sky_color": Int( + 8103167, + ), + "water_fog_color": Int( + 267827, + ), + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "water_color": Int( + 4566514, + ), + }, + ), + "precipitation": String( + "rain", + ), + "category": String( + "ocean", + ), + }, + ), + "name": String( + "minecraft:deep_lukewarm_ocean", + ), + }, + ), + Compound( + { + "element": Compound( + { + "category": String( + "ocean", + ), + "temperature": Float( + 0.5, + ), + "effects": Compound( + { + "water_color": Int( + 4159204, + ), + "sky_color": Int( + 8103167, + ), + "fog_color": Int( + 12638463, + ), + "water_fog_color": Int( + 329011, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "offset": Double( + 2.0, + ), + "block_search_extent": Int( + 8, + ), + }, + ), + }, + ), + "precipitation": String( + "rain", + ), + "downfall": Float( + 0.5, + ), + }, + ), + "id": Int( + 42, + ), + "name": String( + "minecraft:ocean", + ), + }, + ), + Compound( + { + "name": String( + "minecraft:deep_ocean", + ), + "id": Int( + 43, + ), + "element": Compound( + { + "downfall": Float( + 0.5, + ), + "effects": Compound( + { + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + "water_color": Int( + 4159204, + ), + "fog_color": Int( + 12638463, + ), + "sky_color": Int( + 8103167, + ), + }, + ), + "category": String( + "ocean", + ), + "temperature": Float( + 0.5, + ), + "precipitation": String( + "rain", + ), + }, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:cold_ocean", + ), + "element": Compound( + { + "temperature": Float( + 0.5, + ), + "downfall": Float( + 0.5, + ), + "precipitation": String( + "rain", + ), + "category": String( + "ocean", + ), + "effects": Compound( + { + "water_fog_color": Int( + 329011, + ), + "fog_color": Int( + 12638463, + ), + "sky_color": Int( + 8103167, + ), + "water_color": Int( + 4020182, + ), + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.cave", + ), + }, + ), + }, + ), + }, + ), + "id": Int( + 44, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:deep_cold_ocean", + ), + "id": Int( + 45, + ), + "element": Compound( + { + "precipitation": String( + "rain", + ), + "downfall": Float( + 0.5, + ), + "temperature": Float( + 0.5, + ), + "category": String( + "ocean", + ), + "effects": Compound( + { + "water_fog_color": Int( + 329011, + ), + "sky_color": Int( + 8103167, + ), + "water_color": Int( + 4020182, + ), + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + }, + ), + }, + ), + }, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:frozen_ocean", + ), + "element": Compound( + { + "effects": Compound( + { + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + "fog_color": Int( + 12638463, + ), + "sky_color": Int( + 8364543, + ), + "water_color": Int( + 3750089, + ), + }, + ), + "precipitation": String( + "snow", + ), + "temperature": Float( + 0.0, + ), + "downfall": Float( + 0.5, + ), + "temperature_modifier": String( + "frozen", + ), + "category": String( + "ocean", + ), + }, + ), + "id": Int( + 46, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:deep_frozen_ocean", + ), + "id": Int( + 47, + ), + "element": Compound( + { + "temperature_modifier": String( + "frozen", + ), + "temperature": Float( + 0.5, + ), + "downfall": Float( + 0.5, + ), + "precipitation": String( + "rain", + ), + "effects": Compound( + { + "water_fog_color": Int( + 329011, + ), + "fog_color": Int( + 12638463, + ), + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.cave", + ), + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "water_color": Int( + 3750089, + ), + "sky_color": Int( + 8103167, + ), + }, + ), + "category": String( + "ocean", + ), + }, + ), + }, + ), + Compound( + { + "id": Int( + 48, + ), + "name": String( + "minecraft:mushroom_fields", + ), + "element": Compound( + { + "precipitation": String( + "rain", + ), + "effects": Compound( + { + "water_color": Int( + 4159204, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "sky_color": Int( + 7842047, + ), + "fog_color": Int( + 12638463, + ), + "water_fog_color": Int( + 329011, + ), + }, + ), + "downfall": Float( + 1.0, + ), + "temperature": Float( + 0.9, + ), + "category": String( + "mushroom", + ), + }, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:dripstone_caves", + ), + "id": Int( + 49, + ), + "element": Compound( + { + "precipitation": String( + "rain", + ), + "temperature": Float( + 0.8, + ), + "downfall": Float( + 0.4, + ), + "category": String( + "underground", + ), + "effects": Compound( + { + "sky_color": Int( + 7907327, + ), + "water_fog_color": Int( + 329011, + ), + "music": Compound( + { + "sound": String( + "minecraft:music.overworld.dripstone_caves", + ), + "max_delay": Int( + 24000, + ), + "min_delay": Int( + 12000, + ), + "replace_current_music": Byte( + 0, + ), + }, + ), + "fog_color": Int( + 12638463, + ), + "water_color": Int( + 4159204, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + }, + ), + }, + ), + }, + ), + Compound( + { + "element": Compound( + { + "downfall": Float( + 0.5, + ), + "temperature": Float( + 0.5, + ), + "category": String( + "underground", + ), + "effects": Compound( + { + "fog_color": Int( + 12638463, + ), + "water_color": Int( + 4159204, + ), + "sky_color": Int( + 8103167, + ), + "music": Compound( + { + "sound": String( + "minecraft:music.overworld.lush_caves", + ), + "min_delay": Int( + 12000, + ), + "max_delay": Int( + 24000, + ), + "replace_current_music": Byte( + 0, + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + }, + ), + }, + ), + "precipitation": String( + "rain", + ), + }, + ), + "id": Int( + 50, + ), + "name": String( + "minecraft:lush_caves", + ), + }, + ), + Compound( + { + "element": Compound( + { + "effects": Compound( + { + "music": Compound( + { + "max_delay": Int( + 24000, + ), + "sound": String( + "minecraft:music.nether.nether_wastes", + ), + "min_delay": Int( + 12000, + ), + "replace_current_music": Byte( + 0, + ), + }, + ), + "fog_color": Int( + 3344392, + ), + "sky_color": Int( + 7254527, + ), + "water_color": Int( + 4159204, + ), + "water_fog_color": Int( + 329011, + ), + "ambient_sound": String( + "minecraft:ambient.nether_wastes.loop", + ), + "additions_sound": Compound( + { + "sound": String( + "minecraft:ambient.nether_wastes.additions", + ), + "tick_chance": Double( + 0.0111, + ), + }, + ), + "mood_sound": Compound( + { + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + "block_search_extent": Int( + 8, + ), + "sound": String( + "minecraft:ambient.nether_wastes.mood", + ), + }, + ), + }, + ), + "temperature": Float( + 2.0, + ), + "precipitation": String( + "none", + ), + "category": String( + "nether", + ), + "downfall": Float( + 0.0, + ), + }, + ), + "id": Int( + 51, + ), + "name": String( + "minecraft:nether_wastes", + ), + }, + ), + Compound( + { + "element": Compound( + { + "downfall": Float( + 0.0, + ), + "category": String( + "nether", + ), + "effects": Compound( + { + "water_fog_color": Int( + 329011, + ), + "sky_color": Int( + 7254527, + ), + "fog_color": Int( + 1705242, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.warped_forest.mood", + ), + "block_search_extent": Int( + 8, + ), + "offset": Double( + 2.0, + ), + }, + ), + "music": Compound( + { + "sound": String( + "minecraft:music.nether.warped_forest", + ), + "replace_current_music": Byte( + 0, + ), + "min_delay": Int( + 12000, + ), + "max_delay": Int( + 24000, + ), + }, + ), + "water_color": Int( + 4159204, + ), + "additions_sound": Compound( + { + "sound": String( + "minecraft:ambient.warped_forest.additions", + ), + "tick_chance": Double( + 0.0111, + ), + }, + ), + "ambient_sound": String( + "minecraft:ambient.warped_forest.loop", + ), + "particle": Compound( + { + "options": Compound( + { + "type": String( + "minecraft:warped_spore", + ), + }, + ), + "probability": Float( + 0.01428, + ), + }, + ), + }, + ), + "temperature": Float( + 2.0, + ), + "precipitation": String( + "none", + ), + }, + ), + "id": Int( + 52, + ), + "name": String( + "minecraft:warped_forest", + ), + }, + ), + Compound( + { + "name": String( + "minecraft:crimson_forest", + ), + "id": Int( + 53, + ), + "element": Compound( + { + "precipitation": String( + "none", + ), + "downfall": Float( + 0.0, + ), + "temperature": Float( + 2.0, + ), + "effects": Compound( + { + "sky_color": Int( + 7254527, + ), + "water_color": Int( + 4159204, + ), + "particle": Compound( + { + "probability": Float( + 0.025, + ), + "options": Compound( + { + "type": String( + "minecraft:crimson_spore", + ), + }, + ), + }, + ), + "ambient_sound": String( + "minecraft:ambient.crimson_forest.loop", + ), + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.crimson_forest.mood", + ), + "offset": Double( + 2.0, + ), + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + "additions_sound": Compound( + { + "tick_chance": Double( + 0.0111, + ), + "sound": String( + "minecraft:ambient.crimson_forest.additions", + ), + }, + ), + "fog_color": Int( + 3343107, + ), + "music": Compound( + { + "max_delay": Int( + 24000, + ), + "sound": String( + "minecraft:music.nether.crimson_forest", + ), + "replace_current_music": Byte( + 0, + ), + "min_delay": Int( + 12000, + ), + }, + ), + }, + ), + "category": String( + "nether", + ), + }, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:soul_sand_valley", + ), + "id": Int( + 54, + ), + "element": Compound( + { + "category": String( + "nether", + ), + "effects": Compound( + { + "sky_color": Int( + 7254527, + ), + "additions_sound": Compound( + { + "tick_chance": Double( + 0.0111, + ), + "sound": String( + "minecraft:ambient.soul_sand_valley.additions", + ), + }, + ), + "particle": Compound( + { + "options": Compound( + { + "type": String( + "minecraft:ash", + ), + }, + ), + "probability": Float( + 0.00625, + ), + }, + ), + "water_color": Int( + 4159204, + ), + "music": Compound( + { + "min_delay": Int( + 12000, + ), + "replace_current_music": Byte( + 0, + ), + "max_delay": Int( + 24000, + ), + "sound": String( + "minecraft:music.nether.soul_sand_valley", + ), + }, + ), + "fog_color": Int( + 1787717, + ), + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.soul_sand_valley.mood", + ), + }, + ), + "ambient_sound": String( + "minecraft:ambient.soul_sand_valley.loop", + ), + "water_fog_color": Int( + 329011, + ), + }, + ), + "precipitation": String( + "none", + ), + "downfall": Float( + 0.0, + ), + "temperature": Float( + 2.0, + ), + }, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:basalt_deltas", + ), + "element": Compound( + { + "effects": Compound( + { + "water_color": Int( + 4159204, + ), + "music": Compound( + { + "replace_current_music": Byte( + 0, + ), + "min_delay": Int( + 12000, + ), + "sound": String( + "minecraft:music.nether.basalt_deltas", + ), + "max_delay": Int( + 24000, + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + "particle": Compound( + { + "probability": Float( + 0.118093334, + ), + "options": Compound( + { + "type": String( + "minecraft:white_ash", + ), + }, + ), + }, + ), + "sky_color": Int( + 7254527, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "block_search_extent": Int( + 8, + ), + "sound": String( + "minecraft:ambient.basalt_deltas.mood", + ), + }, + ), + "ambient_sound": String( + "minecraft:ambient.basalt_deltas.loop", + ), + "additions_sound": Compound( + { + "tick_chance": Double( + 0.0111, + ), + "sound": String( + "minecraft:ambient.basalt_deltas.additions", + ), + }, + ), + "fog_color": Int( + 6840176, + ), + }, + ), + "temperature": Float( + 2.0, + ), + "downfall": Float( + 0.0, + ), + "category": String( + "nether", + ), + "precipitation": String( + "none", + ), + }, + ), + "id": Int( + 55, + ), + }, + ), + Compound( + { + "id": Int( + 56, + ), + "element": Compound( + { + "precipitation": String( + "none", + ), + "temperature": Float( + 0.5, + ), + "effects": Compound( + { + "sky_color": Int( + 0, + ), + "water_fog_color": Int( + 329011, + ), + "water_color": Int( + 4159204, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "fog_color": Int( + 10518688, + ), + }, + ), + "category": String( + "the_end", + ), + "downfall": Float( + 0.5, + ), + }, + ), + "name": String( + "minecraft:the_end", + ), + }, + ), + Compound( + { + "element": Compound( + { + "temperature": Float( + 0.5, + ), + "downfall": Float( + 0.5, + ), + "precipitation": String( + "none", + ), + "category": String( + "the_end", + ), + "effects": Compound( + { + "water_fog_color": Int( + 329011, + ), + "water_color": Int( + 4159204, + ), + "fog_color": Int( + 10518688, + ), + "mood_sound": Compound( + { + "block_search_extent": Int( + 8, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + }, + ), + "sky_color": Int( + 0, + ), + }, + ), + }, + ), + "id": Int( + 57, + ), + "name": String( + "minecraft:end_highlands", + ), + }, + ), + Compound( + { + "name": String( + "minecraft:end_midlands", + ), + "id": Int( + 58, + ), + "element": Compound( + { + "temperature": Float( + 0.5, + ), + "effects": Compound( + { + "fog_color": Int( + 10518688, + ), + "water_color": Int( + 4159204, + ), + "water_fog_color": Int( + 329011, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "offset": Double( + 2.0, + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "sky_color": Int( + 0, + ), + }, + ), + "category": String( + "the_end", + ), + "precipitation": String( + "none", + ), + "downfall": Float( + 0.5, + ), + }, + ), + }, + ), + Compound( + { + "id": Int( + 59, + ), + "element": Compound( + { + "category": String( + "the_end", + ), + "precipitation": String( + "none", + ), + "downfall": Float( + 0.5, + ), + "effects": Compound( + { + "water_color": Int( + 4159204, + ), + "mood_sound": Compound( + { + "sound": String( + "minecraft:ambient.cave", + ), + "offset": Double( + 2.0, + ), + "tick_delay": Int( + 6000, + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "sky_color": Int( + 0, + ), + "water_fog_color": Int( + 329011, + ), + "fog_color": Int( + 10518688, + ), + }, + ), + "temperature": Float( + 0.5, + ), + }, + ), + "name": String( + "minecraft:small_end_islands", + ), + }, + ), + Compound( + { + "name": String( + "minecraft:end_barrens", + ), + "id": Int( + 60, + ), + "element": Compound( + { + "precipitation": String( + "none", + ), + "effects": Compound( + { + "fog_color": Int( + 10518688, + ), + "water_color": Int( + 4159204, + ), + "mood_sound": Compound( + { + "tick_delay": Int( + 6000, + ), + "offset": Double( + 2.0, + ), + "sound": String( + "minecraft:ambient.cave", + ), + "block_search_extent": Int( + 8, + ), + }, + ), + "water_fog_color": Int( + 329011, + ), + "sky_color": Int( + 0, + ), + }, + ), + "downfall": Float( + 0.5, + ), + "temperature": Float( + 0.5, + ), + "category": String( + "the_end", + ), + }, + ), + }, + ), + ], + ), + }, + ), + "minecraft:dimension_type": Compound( + { + "type": String( + "minecraft:dimension_type", + ), + "value": List( + [ + Compound( + { + "name": String( + "minecraft:overworld", + ), + "element": Compound( + { + "ambient_light": Float( + 0.0, + ), + "effects": String( + "minecraft:overworld", + ), + "min_y": Int( + -64, + ), + "bed_works": Byte( + 1, + ), + "has_raids": Byte( + 1, + ), + "height": Int( + 384, + ), + "natural": Byte( + 1, + ), + "has_ceiling": Byte( + 0, + ), + "has_skylight": Byte( + 1, + ), + "respawn_anchor_works": Byte( + 0, + ), + "coordinate_scale": Double( + 1.0, + ), + "ultrawarm": Byte( + 0, + ), + "piglin_safe": Byte( + 0, + ), + "infiniburn": String( + "#minecraft:infiniburn_overworld", + ), + "logical_height": Int( + 384, + ), + }, + ), + "id": Int( + 0, + ), + }, + ), + Compound( + { + "name": String( + "minecraft:overworld_caves", + ), + "element": Compound( + { + "piglin_safe": Byte( + 0, + ), + "has_ceiling": Byte( + 1, + ), + "has_raids": Byte( + 1, + ), + "effects": String( + "minecraft:overworld", + ), + "infiniburn": String( + "#minecraft:infiniburn_overworld", + ), + "min_y": Int( + -64, + ), + "has_skylight": Byte( + 1, + ), + "ultrawarm": Byte( + 0, + ), + "logical_height": Int( + 384, + ), + "coordinate_scale": Double( + 1.0, + ), + "ambient_light": Float( + 0.0, + ), + "respawn_anchor_works": Byte( + 0, + ), + "bed_works": Byte( + 1, + ), + "height": Int( + 384, + ), + "natural": Byte( + 1, + ), + }, + ), + "id": Int( + 1, + ), + }, + ), + Compound( + { + "id": Int( + 2, + ), + "element": Compound( + { + "respawn_anchor_works": Byte( + 1, + ), + "infiniburn": String( + "#minecraft:infiniburn_nether", + ), + "ambient_light": Float( + 0.1, + ), + "has_skylight": Byte( + 0, + ), + "fixed_time": Long( + 18000, + ), + "bed_works": Byte( + 0, + ), + "effects": String( + "minecraft:the_nether", + ), + "coordinate_scale": Double( + 8.0, + ), + "logical_height": Int( + 128, + ), + "has_raids": Byte( + 0, + ), + "height": Int( + 256, + ), + "min_y": Int( + 0, + ), + "natural": Byte( + 0, + ), + "has_ceiling": Byte( + 1, + ), + "piglin_safe": Byte( + 1, + ), + "ultrawarm": Byte( + 1, + ), + }, + ), + "name": String( + "minecraft:the_nether", + ), + }, + ), + Compound( + { + "id": Int( + 3, + ), + "name": String( + "minecraft:the_end", + ), + "element": Compound( + { + "height": Int( + 256, + ), + "logical_height": Int( + 256, + ), + "ambient_light": Float( + 0.0, + ), + "natural": Byte( + 0, + ), + "has_ceiling": Byte( + 0, + ), + "respawn_anchor_works": Byte( + 0, + ), + "min_y": Int( + 0, + ), + "piglin_safe": Byte( + 0, + ), + "has_skylight": Byte( + 0, + ), + "bed_works": Byte( + 0, + ), + "infiniburn": String( + "#minecraft:infiniburn_end", + ), + "effects": String( + "minecraft:the_end", + ), + "fixed_time": Long( + 6000, + ), + "has_raids": Byte( + 1, + ), + "coordinate_scale": Double( + 1.0, + ), + "ultrawarm": Byte( + 0, + ), + }, + ), + }, + ), + ], + ), + }, + ), + }, + ), + }, + ), + dimension_type: Compound( + { + "": Compound( + { + "coordinate_scale": Double( + 1.0, + ), + "ambient_light": Float( + 0.0, + ), + "effects": String( + "minecraft:overworld", + ), + "min_y": Int( + -64, + ), + "ultrawarm": Byte( + 0, + ), + "has_skylight": Byte( + 1, + ), + "bed_works": Byte( + 1, + ), + "logical_height": Int( + 384, + ), + "natural": Byte( + 1, + ), + "has_raids": Byte( + 1, + ), + "piglin_safe": Byte( + 0, + ), + "respawn_anchor_works": Byte( + 0, + ), + "has_ceiling": Byte( + 0, + ), + "infiniburn": String( + "#minecraft:infiniburn_overworld", + ), + "height": Int( + 384, + ), + }, + ), + }, + ), + dimension: minecraft:overworld, + seed: -8740116197493662413, + max_players: 8, + chunk_radius: 8, + simulation_distance: 5, + reduced_debug_info: false, + show_death_screen: true, + is_debug: false, + is_flat: false, +} \ No newline at end of file -- cgit v1.2.3 From 477c367fc44a2b5c139845f7e8307c6c276d95ee Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 3 May 2022 18:03:10 +0000 Subject: mor echunk stuff --- azalea-client/src/connect.rs | 2 ++ azalea-protocol/README.md | 4 ++-- azalea-world/src/lib.rs | 28 +++++----------------------- 3 files changed, 9 insertions(+), 25 deletions(-) (limited to 'azalea-client/src') diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index e4d7d7e5..984c5d86 100755 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -271,6 +271,8 @@ impl Client { .lock() .await .world + .as_mut() + .expect("World doesn't exist! We should've gotten a login packet by now.") .replace_with_packet_data(&pos, &mut p.chunk_data.data.as_slice()) .unwrap(); } diff --git a/azalea-protocol/README.md b/azalea-protocol/README.md index 99b8b8d2..0321c7a5 100755 --- a/azalea-protocol/README.md +++ b/azalea-protocol/README.md @@ -2,8 +2,8 @@ Sent and receive Minecraft packets. You should probably use `azalea` or `azalea-client` instead. -The goal is to **only** support the latest Minecraft version in order to ease development. +The goal is to only support the latest Minecraft version in order to ease development. This is not yet complete, search for `TODO` in the code for things that need to be done. -Unfortunately, compiling the crate requires Rust nightly because specialization is not stable yet. +Unfortunately, using azalea-protocol requires Rust nightly because [specialization](https://github.com/rust-lang/rust/issues/31844) is not stable yet. Use `rustup default nightly` to enable it. diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs index 51bc0764..ea7798f8 100644 --- a/azalea-world/src/lib.rs +++ b/azalea-world/src/lib.rs @@ -38,17 +38,11 @@ impl World { ); return Ok(()); } - let existing_chunk = &self.storage[pos]; - if let Some(existing_chunk) = existing_chunk { - existing_chunk - .lock() - .expect("Couldn't get lock on existing chunk") - .replace_with_packet_data(data)?; - } else { - let chunk = Arc::new(Mutex::new(Chunk::read_with_world(data, self)?)); - println!("Loaded chunk {:?}", chunk); - self.storage[pos] = Some(chunk); - } + // let existing_chunk = &self.storage[pos]; + + let chunk = Arc::new(Mutex::new(Chunk::read_with_world(data, self)?)); + println!("Loaded chunk {:?}", chunk); + self.storage[pos] = Some(chunk); Ok(()) } @@ -131,18 +125,6 @@ impl Chunk { } Ok(Chunk { sections }) } - - fn replace_with_packet_data(&mut self, data: &mut impl Read) -> Result<(), String> { - let section_count = self.sections.len(); - - // this should also replace block entities and set the heightmap - - for i in 0..section_count { - self.sections[i] = Section::read_into(data)?; - } - - Ok(()) - } } impl McBufWritable for Chunk { -- cgit v1.2.3 From c9878129274258a30dc3ee0ecbd064b4fcf9bc6e Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 3 May 2022 18:20:24 +0000 Subject: clippy --- azalea-client/src/connect.rs | 19 +++++++++---------- azalea-client/src/player.rs | 1 - azalea-crypto/src/lib.rs | 14 +++++--------- azalea-nbt/src/encode.rs | 2 +- azalea-protocol/packet-macros/src/lib.rs | 13 ++++++------- azalea-protocol/src/mc_buf/read.rs | 6 +++--- azalea-protocol/src/mc_buf/write.rs | 8 ++++---- .../game/clientbound_declare_commands_packet.rs | 18 ++++++++---------- .../packets/game/clientbound_light_update_packet.rs | 1 - .../game/clientbound_player_abilities_packet.rs | 8 ++++---- .../game/clientbound_player_position_packet.rs | 10 +++++----- .../src/packets/game/clientbound_recipe_packet.rs | 4 ++-- .../game/clientbound_set_entity_data_packet.rs | 4 ++-- .../packets/game/clientbound_update_recipes_packet.rs | 2 +- .../src/packets/login/serverbound_key_packet.rs | 2 -- azalea-protocol/src/write.rs | 5 +---- azalea-world/src/palette.rs | 18 +++++++++--------- 17 files changed, 60 insertions(+), 75 deletions(-) (limited to 'azalea-client/src') diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index 984c5d86..3b880ea3 100755 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -13,8 +13,8 @@ use azalea_protocol::{ }, resolver, ServerAddress, }; -use azalea_world::{Chunk, ChunkStorage, World}; -use std::{fmt::Debug, ops::Deref, sync::Arc}; +use azalea_world::{ChunkStorage, World}; +use std::{fmt::Debug, sync::Arc}; use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender}; use tokio::sync::Mutex; @@ -34,8 +34,8 @@ pub struct ClientState { /// A player that you can control that is currently in a Minecraft server. pub struct Client { event_receiver: UnboundedReceiver, - conn: Arc>, - state: Arc>, + pub conn: Arc>, + pub state: Arc>, // game_loop } @@ -133,10 +133,9 @@ impl Client { // just start up the game loop and we're ready! // tokio::spawn(Self::game_loop(conn, tx, handler, state)) - let game_loop_conn = conn.clone(); let game_loop_state = client.state.clone(); - tokio::spawn(Self::game_loop(game_loop_conn, tx, game_loop_state)); + tokio::spawn(Self::game_loop(conn, tx, game_loop_state)); Ok(client) } @@ -221,7 +220,7 @@ impl Client { GamePacket::ClientboundChangeDifficultyPacket(p) => { println!("Got difficulty packet {:?}", p); } - GamePacket::ClientboundDeclareCommandsPacket(p) => { + GamePacket::ClientboundDeclareCommandsPacket(_p) => { println!("Got declare commands packet"); } GamePacket::ClientboundPlayerAbilitiesPacket(p) => { @@ -230,19 +229,19 @@ impl Client { GamePacket::ClientboundSetCarriedItemPacket(p) => { println!("Got set carried item packet {:?}", p); } - GamePacket::ClientboundUpdateTagsPacket(p) => { + GamePacket::ClientboundUpdateTagsPacket(_p) => { println!("Got update tags packet"); } GamePacket::ClientboundDisconnectPacket(p) => { println!("Got disconnect packet {:?}", p); } - GamePacket::ClientboundUpdateRecipesPacket(p) => { + GamePacket::ClientboundUpdateRecipesPacket(_p) => { println!("Got update recipes packet"); } GamePacket::ClientboundEntityEventPacket(p) => { println!("Got entity event packet {:?}", p); } - GamePacket::ClientboundRecipePacket(p) => { + GamePacket::ClientboundRecipePacket(_p) => { println!("Got recipe packet"); } GamePacket::ClientboundPlayerPositionPacket(p) => { diff --git a/azalea-client/src/player.rs b/azalea-client/src/player.rs index 70ac1c76..fc54ff93 100644 --- a/azalea-client/src/player.rs +++ b/azalea-client/src/player.rs @@ -1,5 +1,4 @@ use crate::Entity; -use azalea_world::World; #[derive(Default)] pub struct Player { diff --git a/azalea-crypto/src/lib.rs b/azalea-crypto/src/lib.rs index dc2620cc..62a81de3 100644 --- a/azalea-crypto/src/lib.rs +++ b/azalea-crypto/src/lib.rs @@ -1,9 +1,6 @@ use aes::cipher::inout::InOutBuf; -use aes::cipher::BlockEncrypt; use aes::{ - cipher::{ - generic_array::GenericArray, AsyncStreamCipher, BlockDecryptMut, BlockEncryptMut, KeyIvInit, - }, + cipher::{BlockDecryptMut, BlockEncryptMut, KeyIvInit}, Aes128, }; use rand::{rngs::OsRng, RngCore}; @@ -15,7 +12,7 @@ fn generate_secret_key() -> [u8; 16] { key } -fn digest_data(server_id: &[u8], public_key: &[u8], private_key: &[u8]) -> Vec { +pub fn digest_data(server_id: &[u8], public_key: &[u8], private_key: &[u8]) -> Vec { let mut digest = Sha1::new(); digest.update(server_id); digest.update(public_key); @@ -23,7 +20,7 @@ fn digest_data(server_id: &[u8], public_key: &[u8], private_key: &[u8]) -> Vec String { +pub fn hex_digest(digest: &[u8]) -> String { // Note that the Sha1.hexdigest() method used by minecraft is non standard. // It doesn't match the digest method found in most programming languages // and libraries. It works by treating the sha1 output bytes as one large @@ -48,9 +45,8 @@ pub fn encrypt(public_key: &[u8], nonce: &[u8]) -> Result // this.keybytes = Crypt.encryptUsingKey(publicKey, secretKey.getEncoded()); // this.nonce = Crypt.encryptUsingKey(publicKey, arrby); - let encrypted_public_key: Vec = - rsa_public_encrypt_pkcs1::encrypt(&public_key, &secret_key)?; - let encrypted_nonce: Vec = rsa_public_encrypt_pkcs1::encrypt(&public_key, &nonce)?; + let encrypted_public_key: Vec = rsa_public_encrypt_pkcs1::encrypt(public_key, &secret_key)?; + let encrypted_nonce: Vec = rsa_public_encrypt_pkcs1::encrypt(public_key, nonce)?; Ok(EncryptResult { secret_key, diff --git a/azalea-nbt/src/encode.rs b/azalea-nbt/src/encode.rs index 20d13793..fb5585b3 100755 --- a/azalea-nbt/src/encode.rs +++ b/azalea-nbt/src/encode.rs @@ -98,7 +98,7 @@ fn write_compound( if end_tag { writer.write_u8(Tag::End.id())?; } - return Ok(()); + Ok(()) } #[inline] diff --git a/azalea-protocol/packet-macros/src/lib.rs b/azalea-protocol/packet-macros/src/lib.rs index 35abf642..dec153ec 100755 --- a/azalea-protocol/packet-macros/src/lib.rs +++ b/azalea-protocol/packet-macros/src/lib.rs @@ -232,13 +232,12 @@ struct PacketIdMap { impl Parse for PacketIdMap { fn parse(input: ParseStream) -> Result { let mut packets = vec![]; - loop { - // 0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket, - // 0x0e - let packet_id: LitInt = match input.parse() { - Ok(i) => i, - Err(_) => break, - }; + + // example: + // 0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket, + + // 0x0e + while let Ok(packet_id) = input.parse::() { let packet_id = packet_id.base10_parse::()?; // : input.parse::()?; diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs index 68c9cb3f..e1ae321c 100755 --- a/azalea-protocol/src/mc_buf/read.rs +++ b/azalea-protocol/src/mc_buf/read.rs @@ -1,10 +1,10 @@ -use super::{BitSet, UnsizedByteArray, MAX_STRING_LENGTH}; +use super::{UnsizedByteArray, MAX_STRING_LENGTH}; use azalea_chat::component::Component; use azalea_core::{ difficulty::Difficulty, game_type::GameType, resource_location::ResourceLocation, serializable_uuid::SerializableUuid, BlockPos, Direction, Slot, SlotData, }; -use byteorder::{ReadBytesExt, WriteBytesExt, BE}; +use byteorder::{ReadBytesExt, BE}; use serde::Deserialize; use std::io::Read; use tokio::io::{AsyncRead, AsyncReadExt}; @@ -421,7 +421,7 @@ impl McBufReadable for Component { fn read_into(buf: &mut impl Read) -> Result { let string = buf.read_utf()?; let json: serde_json::Value = serde_json::from_str(string.as_str()) - .map_err(|e| "Component isn't valid JSON".to_string())?; + .map_err(|_| "Component isn't valid JSON".to_string())?; let component = Component::deserialize(json).map_err(|e| e.to_string())?; Ok(component) } diff --git a/azalea-protocol/src/mc_buf/write.rs b/azalea-protocol/src/mc_buf/write.rs index 34bcafeb..3a4a02f8 100755 --- a/azalea-protocol/src/mc_buf/write.rs +++ b/azalea-protocol/src/mc_buf/write.rs @@ -20,8 +20,8 @@ pub trait Writable: Write { Ok(()) } - fn write_int_id_list(&mut self, list: &Vec) -> Result<(), std::io::Error> { - self.write_list(&list, |buf, n| buf.write_varint(*n)) + fn write_int_id_list(&mut self, list: &[i32]) -> Result<(), std::io::Error> { + self.write_list(list, |buf, n| buf.write_varint(*n)) } fn write_map( @@ -47,7 +47,7 @@ pub trait Writable: Write { } fn write_bytes(&mut self, bytes: &[u8]) -> Result<(), std::io::Error> { - self.write_all(bytes); + self.write_all(bytes)?; Ok(()) } @@ -333,7 +333,7 @@ impl McBufWritable for Component { // let component = Component::deserialize(json).map_err(|e| e.to_string())?; // Ok(component) // } - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> { // component doesn't have serialize implemented yet todo!() } diff --git a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs index 27f4fb16..6743c3af 100755 --- a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs @@ -281,7 +281,7 @@ impl McBufReadable for BrigadierParser { } } -// azalea_brigadier::tree::CommandNode +// TODO: BrigadierNodeStub should have more stuff impl McBufReadable for BrigadierNodeStub { fn read_into(buf: &mut impl Read) -> Result { let flags = u8::read_into(buf)?; @@ -292,20 +292,18 @@ impl McBufReadable for BrigadierNodeStub { } let node_type = flags & 0x03; - let is_executable = flags & 0x04 != 0; + let _is_executable = flags & 0x04 != 0; let has_redirect = flags & 0x08 != 0; let has_suggestions_type = flags & 0x10 != 0; - let children = buf.read_int_id_list()?; - let redirect_node = if has_redirect { buf.read_varint()? } else { 0 }; + let _children = buf.read_int_id_list()?; + let _redirect_node = if has_redirect { buf.read_varint()? } else { 0 }; // argument node if node_type == 2 { - let name = buf.read_utf()?; - - let parser = BrigadierParser::read_into(buf)?; - - let suggestions_type = if has_suggestions_type { + let _name = buf.read_utf()?; + let _parser = BrigadierParser::read_into(buf)?; + let _suggestions_type = if has_suggestions_type { Some(buf.read_resource_location()?) } else { None @@ -314,7 +312,7 @@ impl McBufReadable for BrigadierNodeStub { } // literal node if node_type == 1 { - let name = buf.read_utf()?; + let _name = buf.read_utf()?; return Ok(BrigadierNodeStub {}); } Ok(BrigadierNodeStub {}) diff --git a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs index c97eacff..e83d1e87 100644 --- a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs @@ -1,5 +1,4 @@ use crate::mc_buf::BitSet; -use azalea_core::{game_type::GameType, resource_location::ResourceLocation}; use packet_macros::{GamePacket, McBufReadable, McBufWritable}; #[derive(Clone, Debug, GamePacket)] diff --git a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs index cd645fe6..ed27ecf3 100755 --- a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs @@ -34,16 +34,16 @@ impl McBufWritable for PlayerAbilitiesFlags { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { let mut byte = 0; if self.invulnerable { - byte = byte | 1; + byte |= 0b1; } if self.flying { - byte = byte | 2; + byte |= 0b10; } if self.can_fly { - byte = byte | 4; + byte |= 0b100; } if self.instant_break { - byte = byte | 8; + byte |= 0b1000; } u8::write_into(&byte, buf) } diff --git a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs index cac4665d..c2bef8fa 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs @@ -43,19 +43,19 @@ impl McBufWritable for RelativeArguments { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { let mut byte = 0; if self.x { - byte = byte | 0b1; + byte |= 0b1; } if self.y { - byte = byte | 0b10; + byte |= 0b10; } if self.z { - byte = byte | 0b100; + byte |= 0b100; } if self.y_rot { - byte = byte | 0b1000; + byte |= 0b1000; } if self.x_rot { - byte = byte | 0b10000; + byte |= 0b10000; } u8::write_into(&byte, buf) } diff --git a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs index 543fb64c..fa0d58f0 100644 --- a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs @@ -1,5 +1,5 @@ use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; -use azalea_core::{resource_location::ResourceLocation, Slot}; +use azalea_core::resource_location::ResourceLocation; use packet_macros::{GamePacket, McBufReadable, McBufWritable}; use std::io::{Read, Write}; @@ -41,7 +41,7 @@ impl McBufWritable for State { } impl McBufReadable for State { fn read_into(buf: &mut impl Read) -> Result { - let state = buf.read_varint()?.try_into().unwrap(); + let state = buf.read_varint()?; Ok(match state { 0 => State::Init, 1 => State::Add, diff --git a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs index 5d288518..ca726c39 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs @@ -123,7 +123,7 @@ impl McBufReadable for EntityDataValue { } impl McBufWritable for EntityDataValue { - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> { todo!(); } } @@ -398,7 +398,7 @@ impl McBufReadable for ParticleData { } impl McBufWritable for ParticleData { - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> { todo!() } } diff --git a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs index d15e10c3..9bdea26e 100644 --- a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs @@ -122,7 +122,7 @@ pub struct Ingredient { } impl McBufWritable for Recipe { - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> { todo!() } } diff --git a/azalea-protocol/src/packets/login/serverbound_key_packet.rs b/azalea-protocol/src/packets/login/serverbound_key_packet.rs index f402d357..2ff8dda6 100644 --- a/azalea-protocol/src/packets/login/serverbound_key_packet.rs +++ b/azalea-protocol/src/packets/login/serverbound_key_packet.rs @@ -1,5 +1,3 @@ -use super::LoginPacket; -use crate::mc_buf::Writable; use packet_macros::LoginPacket; use std::hash::Hash; diff --git a/azalea-protocol/src/write.rs b/azalea-protocol/src/write.rs index 345829c5..9291681c 100755 --- a/azalea-protocol/src/write.rs +++ b/azalea-protocol/src/write.rs @@ -2,10 +2,7 @@ use crate::{mc_buf::Writable, packets::ProtocolPacket, read::MAXIMUM_UNCOMPRESSE use async_compression::tokio::bufread::ZlibEncoder; use azalea_crypto::Aes128CfbEnc; use std::fmt::Debug; -use tokio::{ - io::{AsyncReadExt, AsyncWrite, AsyncWriteExt}, - net::TcpStream, -}; +use tokio::io::{AsyncReadExt, AsyncWrite, AsyncWriteExt}; fn frame_prepender(data: &mut Vec) -> Result, String> { let mut buf = Vec::new(); diff --git a/azalea-world/src/palette.rs b/azalea-world/src/palette.rs index a8ec50c9..69900fe6 100644 --- a/azalea-world/src/palette.rs +++ b/azalea-world/src/palette.rs @@ -35,9 +35,9 @@ impl McBufWritable for PalettedContainer { pub enum Palette { /// ID of the corresponding entry in its global palette SingleValue(u32), - LinearPalette(Vec), - HashmapPalette(Vec), - GlobalPalette, + Linear(Vec), + Hashmap(Vec), + Global, } impl Palette { @@ -47,9 +47,9 @@ impl Palette { ) -> Result { Ok(match bits_per_entry { 0 => Palette::SingleValue(u32::read_into(buf)?), - 1..=4 => Palette::LinearPalette(Vec::::read_into(buf)?), - 5..=8 => Palette::HashmapPalette(Vec::::read_into(buf)?), - _ => Palette::GlobalPalette, + 1..=4 => Palette::Linear(Vec::::read_into(buf)?), + 5..=8 => Palette::Hashmap(Vec::::read_into(buf)?), + _ => Palette::Global, }) } } @@ -60,13 +60,13 @@ impl McBufWritable for Palette { Palette::SingleValue(value) => { value.write_into(buf)?; } - Palette::LinearPalette(values) => { + Palette::Linear(values) => { values.write_into(buf)?; } - Palette::HashmapPalette(values) => { + Palette::Hashmap(values) => { values.write_into(buf)?; } - Palette::GlobalPalette => {} + Palette::Global => {} } Ok(()) } -- cgit v1.2.3 From 345cecf7afa84df2d5ecf075ecfb499e3fd10a55 Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 8 May 2022 23:45:15 -0500 Subject: add more stuff --- .gitignore | 2 -- azalea-client/src/connect.rs | 1 - azalea-core/src/position.rs | 25 +++++++++++++++++++++++++ azalea-world/src/bit_storage.rs | 12 ++++++++++-- azalea-world/src/lib.rs | 9 +++++++++ azalea-world/src/palette.rs | 14 +++++++++++--- bot/src/main.rs | 23 ++++++++++++----------- 7 files changed, 67 insertions(+), 19 deletions(-) (limited to 'azalea-client/src') diff --git a/.gitignore b/.gitignore index dc2a59d1..53141060 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,6 @@ flamegraph.svg perf.data perf.data.old -# TODO: remove this after chunk-decoding is merged -/login.txt code-generator/Burger code-generator/client.jar diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index 2f38b305..522d7d48 100755 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -177,7 +177,6 @@ impl Client { match packet { GamePacket::ClientboundLoginPacket(p) => { println!("Got login packet {:?}", p); - std::fs::write("login.txt", format!("{:#?}", p)).expect("Unable to write file"); let mut state = state.lock().await; state.player.entity.id = p.player_id; diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs index a57f5c0b..a2292651 100644 --- a/azalea-core/src/position.rs +++ b/azalea-core/src/position.rs @@ -23,6 +23,15 @@ impl ChunkPos { } } +impl From for ChunkPos { + fn from(pos: BlockPos) -> Self { + ChunkPos { + x: pos.x / 16, + z: pos.z / 16, + } + } +} + #[derive(Clone, Copy, Debug, Default)] pub struct ChunkSectionPos { pub x: i32, @@ -35,3 +44,19 @@ impl ChunkSectionPos { ChunkSectionPos { x, y, z } } } + +impl From for ChunkSectionPos { + fn from(pos: BlockPos) -> Self { + ChunkSectionPos { + x: pos.x / 16, + y: pos.y / 16, + z: pos.z / 16, + } + } +} + +impl From for ChunkPos { + fn from(pos: ChunkSectionPos) -> Self { + ChunkPos { x: pos.x, z: pos.z } + } +} diff --git a/azalea-world/src/bit_storage.rs b/azalea-world/src/bit_storage.rs index 9cc3a053..211a4a04 100644 --- a/azalea-world/src/bit_storage.rs +++ b/azalea-world/src/bit_storage.rs @@ -70,9 +70,9 @@ const MAGIC: [(i32, i32, i32); 64] = [ ]; /// A compact list of integers with the given number of bits per entry. -#[derive(Clone)] +#[derive(Clone, Debug, Default)] pub struct BitStorage { - data: Vec, + pub data: Vec, bits: usize, mask: u64, size: usize, @@ -103,9 +103,17 @@ impl BitStorage { /// Create a new BitStorage with the given number of bits per entry. /// `size` is the number of entries in the BitStorage. pub fn new(bits: usize, size: usize, data: Option>) -> Result { + if let Some(data) = &data { + if data.len() == 0 { + // TODO: make 0 bit storage actually work + return Ok(BitStorage::default()); + } + } + let values_per_long = 64 / bits; let magic_index = values_per_long - 1; let (divide_mul, divide_add, divide_shift) = MAGIC[magic_index as usize]; + println!("values_per_long: {}, size: {}", values_per_long, size); let calculated_length = (size + values_per_long - 1) / values_per_long; let mask = (1 << bits) - 1; diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs index 4b8c21e9..4da2fb0f 100644 --- a/azalea-world/src/lib.rs +++ b/azalea-world/src/lib.rs @@ -67,6 +67,15 @@ impl IndexMut<&ChunkPos> for World { &mut self.storage[pos] } } +// impl Index<&BlockPos> for World { +// type Output = Option>>; + +// fn index(&self, pos: &BlockPos) -> &Self::Output { +// let chunk = &self[ChunkPos::from(pos)]; +// // chunk. + +// } +// } pub struct ChunkStorage { view_center: ChunkPos, diff --git a/azalea-world/src/palette.rs b/azalea-world/src/palette.rs index db722a5b..c33992b1 100644 --- a/azalea-world/src/palette.rs +++ b/azalea-world/src/palette.rs @@ -1,6 +1,8 @@ use azalea_protocol::mc_buf::{McBufReadable, McBufVarReadable, McBufWritable, Readable, Writable}; use std::io::{Read, Write}; +use crate::BitStorage; + #[derive(Clone, Debug, Copy)] pub enum PalettedContainerType { Biomes, @@ -12,7 +14,7 @@ pub struct PalettedContainer { pub bits_per_entry: u8, pub palette: Palette, /// Compacted list of indices pointing to entry IDs in the Palette. - pub data: Vec, + pub storage: BitStorage, } impl PalettedContainer { @@ -29,17 +31,23 @@ impl PalettedContainer { Palette::biomes_read_with_bits_per_entry(buf, bits_per_entry)? } }; + let size = match type_ { + PalettedContainerType::BlockStates => 4096, + PalettedContainerType::Biomes => 64, + }; let data = Vec::::read_into(buf)?; debug_assert!( bits_per_entry != 0 || data.is_empty(), "Bits per entry is 0 but data is not empty." ); + println!("data: {:?}", data); + let storage = BitStorage::new(bits_per_entry.into(), size, Some(data)).unwrap(); Ok(PalettedContainer { bits_per_entry, palette, - data, + storage, }) } } @@ -47,7 +55,7 @@ impl McBufWritable for PalettedContainer { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_byte(self.bits_per_entry)?; self.palette.write_into(buf)?; - self.data.write_into(buf)?; + self.storage.data.write_into(buf)?; Ok(()) } } diff --git a/bot/src/main.rs b/bot/src/main.rs index 075bfa44..2686636b 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -1,5 +1,5 @@ use azalea_client::{Account, Event}; -use azalea_core::ChunkPos; +use azalea_core::{BlockPos, ChunkPos}; #[tokio::main] async fn main() { @@ -19,18 +19,19 @@ async fn main() { while let Some(e) = client.next().await { match e { // TODO: have a "loaded" or "ready" event that fires when all chunks are loaded - Event::Login => { - // let state = client.state.lock().await; - // let world = state.world.as_ref().unwrap(); - // let c = world[&ChunkPos::new(-1, -4)] - // .as_ref() - // .unwrap() - // .lock() - // .unwrap(); - // println!("{:?}", c); - } + Event::Login => {} Event::Chat(p) => { println!("{}", p.message.to_ansi(None)); + if p.message.to_ansi(None) == " ok" { + let state = client.state.lock().await; + let world = state.world.as_ref().unwrap(); + // let c = world[&BlockPos::new(5, 78, -2)] + // .as_ref() + // .unwrap() + // .lock() + // .unwrap(); + // println!("{:?}", c); + } } } } -- cgit v1.2.3 From e58c9390a717517db0bf4366c55a3802c832b144 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 14 May 2022 15:02:13 -0500 Subject: get_block_state works --- azalea-client/src/connect.rs | 8 +++++ azalea-core/src/difficulty.rs | 1 - azalea-core/src/lib.rs | 4 ++- azalea-core/src/position.rs | 68 +++++++++++++++++++++++++++++++++++++---- azalea-world/src/bit_storage.rs | 1 - azalea-world/src/lib.rs | 24 +++++++++------ azalea-world/src/palette.rs | 5 +-- bot/src/main.rs | 2 +- 8 files changed, 90 insertions(+), 23 deletions(-) (limited to 'azalea-client/src') diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index 522d7d48..8d2e9dc1 100755 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -195,9 +195,17 @@ impl Client { .expect("height tag is not int")) .try_into() .expect("height is not a u32"); + let min_y = (*dimension_type + .get("min_y") + .expect("No min_y tag") + .as_int() + .expect("min_y tag is not int")) + .try_into() + .expect("min_y is not an i32"); state.world = Some(World { height, + min_y, storage: ChunkStorage::new(16), }); diff --git a/azalea-core/src/difficulty.rs b/azalea-core/src/difficulty.rs index 21e980ba..5d869325 100755 --- a/azalea-core/src/difficulty.rs +++ b/azalea-core/src/difficulty.rs @@ -83,7 +83,6 @@ mod tests { assert_eq!(1, Difficulty::EASY.id()); assert_eq!(2, Difficulty::NORMAL.id()); assert_eq!(3, Difficulty::HARD.id()); - assert_eq!(4, Difficulty::PEACEFUL.id()); } #[test] diff --git a/azalea-core/src/lib.rs b/azalea-core/src/lib.rs index 2b12db53..d2a2d558 100755 --- a/azalea-core/src/lib.rs +++ b/azalea-core/src/lib.rs @@ -1,5 +1,7 @@ //! Random miscellaneous things like UUIDs that don't deserve their own crate. +#![feature(int_roundings)] + pub mod difficulty; pub mod game_type; pub mod resource_location; @@ -9,7 +11,7 @@ mod slot; pub use slot::{Slot, SlotData}; mod position; -pub use position::{BlockPos, ChunkPos, ChunkSectionBlockPos, ChunkSectionPos}; +pub use position::{BlockPos, ChunkBlockPos, ChunkPos, ChunkSectionBlockPos, ChunkSectionPos}; mod direction; pub use direction::Direction; diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs index 1dd200ab..9c7cd132 100644 --- a/azalea-core/src/position.rs +++ b/azalea-core/src/position.rs @@ -25,7 +25,7 @@ impl Rem for BlockPos { } } -#[derive(Clone, Copy, Debug, Default)] +#[derive(Clone, Copy, Debug, Default, PartialEq)] pub struct ChunkPos { pub x: i32, pub z: i32, @@ -40,8 +40,8 @@ impl ChunkPos { impl From<&BlockPos> for ChunkPos { fn from(pos: &BlockPos) -> Self { ChunkPos { - x: pos.x / 16, - z: pos.z / 16, + x: pos.x.div_floor(16), + z: pos.z.div_floor(16), } } } @@ -63,9 +63,9 @@ impl ChunkSectionPos { impl From for ChunkSectionPos { fn from(pos: BlockPos) -> Self { ChunkSectionPos { - x: pos.x / 16, - y: pos.y / 16, - z: pos.z / 16, + x: pos.x.div_floor(16), + y: pos.y.div_floor(16), + z: pos.z.div_floor(16), } } } @@ -76,11 +76,38 @@ impl From for ChunkPos { } } +/// The coordinates of a block inside a chunk. +#[derive(Clone, Copy, Debug, Default, PartialEq)] +pub struct ChunkBlockPos { + pub x: u8, + pub y: i32, + pub z: u8, +} + +impl ChunkBlockPos { + pub fn new(x: u8, y: i32, z: u8) -> Self { + ChunkBlockPos { x, y, z } + } +} + +impl From<&BlockPos> for ChunkBlockPos { + fn from(pos: &BlockPos) -> Self { + ChunkBlockPos { + x: pos.x.rem_euclid(16).abs() as u8, + y: pos.y, + z: pos.z.rem_euclid(16).abs() as u8, + } + } +} + /// The coordinates of a block inside a chunk section. #[derive(Clone, Copy, Debug, Default)] pub struct ChunkSectionBlockPos { + /// A number between 0 and 16. pub x: u8, + /// A number between 0 and 16. pub y: u8, + /// A number between 0 and 16. pub z: u8, } @@ -99,3 +126,32 @@ impl From<&BlockPos> for ChunkSectionBlockPos { } } } + +impl From<&ChunkBlockPos> for ChunkSectionBlockPos { + fn from(pos: &ChunkBlockPos) -> Self { + ChunkSectionBlockPos { + x: pos.x, + y: pos.y.rem(16).abs() as u8, + z: pos.z, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_from_block_pos_to_chunk_pos() { + let block_pos = BlockPos::new(5, 78, -2); + let chunk_pos = ChunkPos::from(&block_pos); + assert_eq!(chunk_pos, ChunkPos::new(0, -1)); + } + + #[test] + fn test_from_block_pos_to_chunk_block_pos() { + let block_pos = BlockPos::new(5, 78, -2); + let chunk_block_pos = ChunkBlockPos::from(&block_pos); + assert_eq!(chunk_block_pos, ChunkBlockPos::new(5, 78, 14)); + } +} diff --git a/azalea-world/src/bit_storage.rs b/azalea-world/src/bit_storage.rs index f24a0514..aba52aef 100644 --- a/azalea-world/src/bit_storage.rs +++ b/azalea-world/src/bit_storage.rs @@ -148,7 +148,6 @@ impl BitStorage { // as unsigned wrap let first = self.divide_mul as u32 as u64; let second = self.divide_add as u64; - dbg!(first, second, index); (((index * first) + second) >> 32 >> self.divide_shift) .try_into() diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs index aa99a470..4641729c 100644 --- a/azalea-world/src/lib.rs +++ b/azalea-world/src/lib.rs @@ -1,8 +1,10 @@ +#![feature(int_roundings)] + mod bit_storage; mod palette; use crate::palette::PalettedContainerType; -use azalea_core::{BlockPos, ChunkPos, ChunkSectionBlockPos}; +use azalea_core::{BlockPos, ChunkBlockPos, ChunkPos, ChunkSectionBlockPos}; use azalea_protocol::mc_buf::{McBufReadable, McBufWritable}; pub use bit_storage::BitStorage; use palette::PalettedContainer; @@ -26,6 +28,7 @@ const SECTION_HEIGHT: u32 = 16; pub struct World { pub storage: ChunkStorage, pub height: u32, + pub min_y: i32, } impl World { @@ -55,7 +58,7 @@ impl World { } pub fn get_block_state(&self, pos: &BlockPos) -> Option { - self.storage.get_block_state(pos) + self.storage.get_block_state(pos, self.min_y) } } impl Index<&ChunkPos> for World { @@ -119,11 +122,12 @@ impl ChunkStorage { && (chunk_pos.z - self.view_center.z).unsigned_abs() <= self.chunk_radius } - pub fn get_block_state(&self, pos: &BlockPos) -> Option { + pub fn get_block_state(&self, pos: &BlockPos, min_y: i32) -> Option { let chunk_pos = ChunkPos::from(pos); + println!("chunk_pos {:?} block_pos {:?}", chunk_pos, pos); let chunk = &self[&chunk_pos]; match chunk { - Some(chunk) => Some(chunk.lock().unwrap().get(pos)), + Some(chunk) => Some(chunk.lock().unwrap().get(&ChunkBlockPos::from(pos), min_y)), None => None, } } @@ -156,26 +160,28 @@ impl Chunk { pub fn read_with_world_height(buf: &mut impl Read, world_height: u32) -> Result { let section_count = world_height / SECTION_HEIGHT; let mut sections = Vec::with_capacity(section_count as usize); - for i in 0..section_count { + for _ in 0..section_count { let section = Section::read_into(buf)?; sections.push(section); } Ok(Chunk { sections }) } - pub fn section_index(&self, y: i32) -> u32 { + pub fn section_index(&self, y: i32, min_y: i32) -> u32 { // TODO: check the build height and stuff, this code will be broken if the min build height is 0 // (LevelHeightAccessor.getMinSection in vanilla code) assert!(y >= 0); - (y as u32) / 16 + let min_section_index = min_y.div_floor(16); + (y.div_floor(16) - min_section_index) as u32 } - pub fn get(&self, pos: &BlockPos) -> u32 { - let section_index = self.section_index(pos.y); + pub fn get(&self, pos: &ChunkBlockPos, min_y: i32) -> u32 { + let section_index = self.section_index(pos.y, min_y); println!("section index: {}", section_index); // TODO: make sure the section exists let section = &self.sections[section_index as usize]; let chunk_section_pos = ChunkSectionBlockPos::from(pos); + println!("chunk section pos: {:?}", chunk_section_pos); let block_state = section.get(chunk_section_pos); block_state } diff --git a/azalea-world/src/palette.rs b/azalea-world/src/palette.rs index 6dc5e183..be6f022c 100644 --- a/azalea-world/src/palette.rs +++ b/azalea-world/src/palette.rs @@ -62,11 +62,8 @@ impl PalettedContainer { } pub fn get(&self, x: usize, y: usize, z: usize) -> u32 { - println!( - "get: {} {} {}, bits per entry: {}", - x, y, z, self.bits_per_entry - ); let paletted_value = self.storage.get(self.get_index(x, y, z)); + println!("palette: {:?}", self.palette); self.palette.value_for(paletted_value as usize) } } diff --git a/bot/src/main.rs b/bot/src/main.rs index 93d83be9..1f2cb6e1 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -26,7 +26,7 @@ async fn main() { let state = client.state.lock().await; let world = state.world.as_ref().unwrap(); let c = world.get_block_state(&BlockPos::new(5, 78, -2)).unwrap(); - println!("{:?}", c); + println!("block state: {:?}", c); } } } -- cgit v1.2.3 From 42f86f73f256c0219a923c5ff67a509e7a8a898d Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 14 May 2022 19:14:34 -0500 Subject: add unhandled ClientboundSectionBlocksUpdatePacket --- azalea-client/src/connect.rs | 3 +++ azalea-protocol/src/mc_buf/read.rs | 14 +++++++++++++- azalea-protocol/src/mc_buf/write.rs | 13 ++++++++++++- .../game/clientbound_section_blocks_update_packet.rs | 10 ++++++++++ azalea-protocol/src/packets/game/mod.rs | 2 ++ bot/src/main.rs | 4 ++-- 6 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs (limited to 'azalea-client/src') diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index 8d2e9dc1..48fd16f2 100755 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -373,6 +373,9 @@ impl Client { GamePacket::ClientboundAnimatePacket(p) => { println!("Got animate packet {:?}", p); } + GamePacket::ClientboundSectionBlocksUpdatePacket(p) => { + println!("Got section blocks update packet {:?}", p); + } _ => panic!("Unexpected packet {:?}", packet), } } diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs index ebafad92..1c4fbd6f 100644 --- a/azalea-protocol/src/mc_buf/read.rs +++ b/azalea-protocol/src/mc_buf/read.rs @@ -2,7 +2,7 @@ use super::{UnsizedByteArray, MAX_STRING_LENGTH}; use azalea_chat::component::Component; use azalea_core::{ difficulty::Difficulty, game_type::GameType, resource_location::ResourceLocation, - serializable_uuid::SerializableUuid, BlockPos, Direction, Slot, SlotData, + serializable_uuid::SerializableUuid, BlockPos, ChunkSectionPos, Direction, Slot, SlotData, }; use byteorder::{ReadBytesExt, BE}; use serde::Deserialize; @@ -518,3 +518,15 @@ impl McBufReadable for Direction { } } } + +// ChunkSectionPos +impl McBufReadable for ChunkSectionPos { + fn read_into(buf: &mut impl Read) -> Result { + let long = i64::read_into(buf)?; + Ok(ChunkSectionPos { + x: (long >> 42) as i32, + y: (long << 44 >> 44) as i32, + z: (long << 22 >> 42) as i32, + }) + } +} diff --git a/azalea-protocol/src/mc_buf/write.rs b/azalea-protocol/src/mc_buf/write.rs index 7fe61752..c46297a6 100644 --- a/azalea-protocol/src/mc_buf/write.rs +++ b/azalea-protocol/src/mc_buf/write.rs @@ -2,7 +2,7 @@ use super::{UnsizedByteArray, MAX_STRING_LENGTH}; use azalea_chat::component::Component; use azalea_core::{ difficulty::Difficulty, game_type::GameType, resource_location::ResourceLocation, - serializable_uuid::SerializableUuid, BlockPos, Direction, Slot, + serializable_uuid::SerializableUuid, BlockPos, ChunkSectionPos, Direction, Slot, }; use byteorder::{BigEndian, WriteBytesExt}; use std::{collections::HashMap, io::Write}; @@ -425,3 +425,14 @@ impl McBufWritable for Direction { buf.write_varint(*self as i32) } } + +// ChunkSectionPos +impl McBufWritable for ChunkSectionPos { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + let long = (((self.x & 0x3FFFFF) as i64) << 42) + | (self.y & 0xFFFFF) as i64 + | (((self.z & 0x3FFFFF) as i64) << 20); + long.write_into(buf)?; + Ok(()) + } +} diff --git a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs new file mode 100644 index 00000000..f220b07f --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs @@ -0,0 +1,10 @@ +use azalea_core::ChunkSectionPos; +use packet_macros::GamePacket; + +#[derive(Clone, Debug, GamePacket)] +pub struct ClientboundSectionBlocksUpdatePacket { + pub section_pos: ChunkSectionPos, + pub suppress_light_updates: bool, + #[var] + pub states: Vec, +} diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs index 0391ee10..66c55cd2 100755 --- a/azalea-protocol/src/packets/game/mod.rs +++ b/azalea-protocol/src/packets/game/mod.rs @@ -26,6 +26,7 @@ pub mod clientbound_player_position_packet; pub mod clientbound_recipe_packet; pub mod clientbound_remove_entities_packet; pub mod clientbound_rotate_head_packet; +pub mod clientbound_section_blocks_update_packet; pub mod clientbound_set_carried_item_packet; pub mod clientbound_set_chunk_cache_center; pub mod clientbound_set_default_spawn_position_packet; @@ -80,6 +81,7 @@ declare_state_packets!( 0x39: clientbound_recipe_packet::ClientboundRecipePacket, 0x3a: clientbound_remove_entities_packet::ClientboundRemoveEntitiesPacket, 0x3e: clientbound_rotate_head_packet::ClientboundRotateHeadPacket, + 0x3f: clientbound_section_blocks_update_packet::ClientboundSectionBlocksUpdatePacket, 0x48: clientbound_set_carried_item_packet::ClientboundSetCarriedItemPacket, 0x49: clientbound_set_chunk_cache_center::ClientboundSetChunkCacheCenterPacket, 0x4a: clientbound_update_view_distance_packet::ClientboundUpdateViewDistancePacket, diff --git a/bot/src/main.rs b/bot/src/main.rs index 1f2cb6e1..76a5a15d 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -1,12 +1,12 @@ use azalea_client::{Account, Event}; -use azalea_core::{BlockPos, ChunkPos}; +use azalea_core::BlockPos; #[tokio::main] async fn main() { println!("Hello, world!"); // let address = "95.111.249.143:10000"; - let address = "192.168.2.234:62840"; + let address = "192.168.2.234:50736"; // let response = azalea_client::ping::ping_server(&address.try_into().unwrap()) // .await // .unwrap(); -- cgit v1.2.3 From 2eaccf03eb8cc6227b287bb2da87fab14b16c94f Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 14 May 2022 19:31:34 -0500 Subject: actually do ClientboundSectionBlocksUpdatePacket --- azalea-client/src/connect.rs | 2 ++ .../clientbound_section_blocks_update_packet.rs | 39 ++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) (limited to 'azalea-client/src') diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index 48fd16f2..7f245746 100755 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -369,12 +369,14 @@ impl Client { } GamePacket::ClientboundBlockUpdatePacket(p) => { println!("Got block update packet {:?}", p); + // TODO: update world } GamePacket::ClientboundAnimatePacket(p) => { println!("Got animate packet {:?}", p); } GamePacket::ClientboundSectionBlocksUpdatePacket(p) => { println!("Got section blocks update packet {:?}", p); + // TODO: update world } _ => panic!("Unexpected packet {:?}", packet), } diff --git a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs index f220b07f..7f57a126 100644 --- a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs @@ -1,10 +1,43 @@ -use azalea_core::ChunkSectionPos; +use crate::mc_buf::{McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable}; +use azalea_core::{ChunkSectionBlockPos, ChunkSectionPos}; use packet_macros::GamePacket; +use std::io::{Read, Write}; #[derive(Clone, Debug, GamePacket)] pub struct ClientboundSectionBlocksUpdatePacket { pub section_pos: ChunkSectionPos, pub suppress_light_updates: bool, - #[var] - pub states: Vec, + pub states: Vec, +} + +#[derive(Clone, Debug)] +pub struct BlockStateWithPosition { + pub pos: ChunkSectionBlockPos, + pub state: u32, +} + +impl McBufReadable for BlockStateWithPosition { + fn read_into(buf: &mut impl Read) -> Result { + let data = u64::var_read_into(buf)?; + let position_part = data & 4095; + let state = (data >> 12) as u32; + let position = ChunkSectionBlockPos { + x: (position_part >> 8 & 15) as u8, + y: (position_part >> 0 & 15) as u8, + z: (position_part >> 4 & 15) as u8, + }; + Ok(BlockStateWithPosition { + pos: position, + state: state, + }) + } +} + +impl McBufWritable for BlockStateWithPosition { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + let data = (self.state as u64) << 12 + | ((self.pos.x as u64) << 8 | (self.pos.z as u64) << 4 | (self.pos.y as u64)); + u64::var_write_into(&data, buf); + Ok(()) + } } -- cgit v1.2.3 From 3f77390e2671045ed3ea45f24a9ade151eafe700 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 14 May 2022 19:40:00 -0500 Subject: ClientboundGameEventPacket --- azalea-client/src/connect.rs | 3 +++ .../packets/game/clientbound_game_event_packet.rs | 23 ++++++++++++++++++++++ azalea-protocol/src/packets/game/mod.rs | 2 ++ 3 files changed, 28 insertions(+) create mode 100644 azalea-protocol/src/packets/game/clientbound_game_event_packet.rs (limited to 'azalea-client/src') diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index 7f245746..d7788593 100755 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -378,6 +378,9 @@ impl Client { println!("Got section blocks update packet {:?}", p); // TODO: update world } + GamePacket::ClientboundGameEventPacket(p) => { + println!("Got game event packet {:?}", p); + } _ => panic!("Unexpected packet {:?}", packet), } } diff --git a/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs new file mode 100644 index 00000000..c3ae2299 --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs @@ -0,0 +1,23 @@ +use packet_macros::{GamePacket, McBufReadable, McBufWritable}; + +#[derive(Clone, Debug, GamePacket)] +pub struct ClientboundGameEventPacket { + pub event: EventType, + pub param: f32, +} + +#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)] +pub enum EventType { + NoRespawnBlockAvailable = 0, + StartRaining = 1, + StopRaining = 2, + ChangeGameMode = 3, + WinGame = 4, + DemoEvent = 5, + ArrowHitPlayer = 6, + RainLevelChange = 7, + ThunderLevelChange = 8, + PufferFishSting = 9, + GuardianElderEffect = 10, + ImmediateRespawn = 11, +} diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs index 66c55cd2..f8ead9d6 100755 --- a/azalea-protocol/src/packets/game/mod.rs +++ b/azalea-protocol/src/packets/game/mod.rs @@ -11,6 +11,7 @@ pub mod clientbound_declare_commands_packet; pub mod clientbound_disconnect_packet; pub mod clientbound_entity_event_packet; pub mod clientbound_entity_velocity_packet; +pub mod clientbound_game_event_packet; pub mod clientbound_initialize_border_packet; pub mod clientbound_keep_alive_packet; pub mod clientbound_level_chunk_with_light_packet; @@ -66,6 +67,7 @@ declare_state_packets!( 0x1a: clientbound_disconnect_packet::ClientboundDisconnectPacket, 0x1b: clientbound_entity_event_packet::ClientboundEntityEventPacket, 0x18: clientbound_custom_payload_packet::ClientboundCustomPayloadPacket, + 0x1e: clientbound_game_event_packet::ClientboundGameEventPacket, 0x20: clientbound_initialize_border_packet::ClientboundInitializeBorderPacket, 0x21: clientbound_keep_alive_packet::ClientboundKeepAlivePacket, 0x22: clientbound_level_chunk_with_light_packet::ClientboundLevelChunkWithLightPacket, -- cgit v1.2.3 From c16e958d0be671a17edf060aee9850faccbcfe14 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 14 May 2022 20:43:25 -0500 Subject: ClientboundLevelParticlesPacket works --- azalea-client/src/connect.rs | 3 ++ .../game/clientbound_level_particles_packet.rs | 45 ++++++++++++++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) (limited to 'azalea-client/src') diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index d7788593..b8b6e372 100755 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -381,6 +381,9 @@ impl Client { GamePacket::ClientboundGameEventPacket(p) => { println!("Got game event packet {:?}", p); } + GamePacket::ClientboundLevelParticlesPacket(p) => { + println!("Got level particles packet {:?}", p); + } _ => panic!("Unexpected packet {:?}", packet), } } diff --git a/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs index 43c3b31a..a3538598 100644 --- a/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs @@ -1,7 +1,9 @@ -use crate::mc_buf::ParticleData; -use packet_macros::{GamePacket, McBuf}; +use std::io::{Read, Write}; -#[derive(Clone, Debug, McBuf, GamePacket)] +use crate::mc_buf::{McBufReadable, McBufWritable, ParticleData}; +use packet_macros::GamePacket; + +#[derive(Clone, Debug, GamePacket)] pub struct ClientboundLevelParticlesPacket { pub particle_id: u32, pub override_limiter: bool, @@ -15,3 +17,40 @@ pub struct ClientboundLevelParticlesPacket { pub count: i32, pub data: ParticleData, } + +impl McBufReadable for ClientboundLevelParticlesPacket { + fn read_into(buf: &mut impl Read) -> Result { + let particle_id = u32::read_into(buf)?; + let override_limiter = bool::read_into(buf)?; + let x = f64::read_into(buf)?; + let y = f64::read_into(buf)?; + let z = f64::read_into(buf)?; + let x_dist = f32::read_into(buf)?; + let y_dist = f32::read_into(buf)?; + let z_dist = f32::read_into(buf)?; + let max_speed = f32::read_into(buf)?; + let count = i32::read_into(buf)?; + + let data = ParticleData::read_from_particle_id(buf, particle_id)?; + + Ok(Self { + particle_id, + override_limiter, + x, + y, + z, + x_dist, + y_dist, + z_dist, + max_speed, + count, + data, + }) + } +} + +impl McBufWritable for ClientboundLevelParticlesPacket { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + todo!(); + } +} -- cgit v1.2.3