diff --git a/Cargo.lock b/Cargo.lock index 7d88a0fe..4a354c37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -209,7 +209,7 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "azalea" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "anyhow", "azalea-auth", @@ -249,7 +249,7 @@ dependencies = [ [[package]] name = "azalea-auth" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "azalea-buf", "azalea-crypto", @@ -269,7 +269,7 @@ dependencies = [ [[package]] name = "azalea-block" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "azalea-block-macros", "azalea-buf", @@ -278,7 +278,7 @@ dependencies = [ [[package]] name = "azalea-block-macros" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "proc-macro2", "quote", @@ -287,7 +287,7 @@ dependencies = [ [[package]] name = "azalea-brigadier" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "azalea-buf", "azalea-chat", @@ -298,7 +298,7 @@ dependencies = [ [[package]] name = "azalea-buf" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "azalea-buf-macros", "byteorder", @@ -311,7 +311,7 @@ dependencies = [ [[package]] name = "azalea-buf-macros" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "proc-macro2", "quote", @@ -320,7 +320,7 @@ dependencies = [ [[package]] name = "azalea-chat" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "azalea-buf", "azalea-language", @@ -333,7 +333,7 @@ dependencies = [ [[package]] name = "azalea-client" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "anyhow", "azalea-auth", @@ -368,7 +368,7 @@ dependencies = [ [[package]] name = "azalea-core" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "azalea-buf", "azalea-chat", @@ -384,7 +384,7 @@ dependencies = [ [[package]] name = "azalea-crypto" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "aes", "azalea-buf", @@ -401,7 +401,7 @@ dependencies = [ [[package]] name = "azalea-entity" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "azalea-block", "azalea-buf", @@ -424,7 +424,7 @@ dependencies = [ [[package]] name = "azalea-inventory" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "azalea-buf", "azalea-chat", @@ -439,7 +439,7 @@ dependencies = [ [[package]] name = "azalea-inventory-macros" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "proc-macro2", "quote", @@ -448,7 +448,7 @@ dependencies = [ [[package]] name = "azalea-language" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "compact_str", "serde", @@ -457,7 +457,7 @@ dependencies = [ [[package]] name = "azalea-physics" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "azalea-block", "azalea-core", @@ -475,7 +475,7 @@ dependencies = [ [[package]] name = "azalea-protocol" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "anyhow", "async-recursion", @@ -510,7 +510,7 @@ dependencies = [ [[package]] name = "azalea-protocol-macros" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "proc-macro2", "quote", @@ -519,7 +519,7 @@ dependencies = [ [[package]] name = "azalea-registry" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "azalea-buf", "azalea-registry-macros", @@ -529,7 +529,7 @@ dependencies = [ [[package]] name = "azalea-registry-macros" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "quote", "syn", @@ -537,7 +537,7 @@ dependencies = [ [[package]] name = "azalea-world" -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" dependencies = [ "azalea-block", "azalea-buf", diff --git a/Cargo.toml b/Cargo.toml index 04611f15..96f3301d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ resolver = "2" # --- Workspace Settings --- [workspace.package] -version = "0.11.0+mc25w09b" +version = "0.11.0+mc1.21.5-pre2" edition = "2024" license = "MIT" repository = "https://github.com/azalea-rs/azalea" diff --git a/README.md b/README.md index 667e49d5..c48d3a0e 100755 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A collection of Rust crates for making Minecraft bots, clients, and tools. -_Currently supported Minecraft version: `25w09b`._ +_Currently supported Minecraft version: `1.21.5-pre2`._ > [!WARNING] > Azalea is still unfinished, though most crates are in a useable state diff --git a/azalea-client/src/plugins/chunks.rs b/azalea-client/src/plugins/chunks.rs index cdda3eba..6c970db9 100644 --- a/azalea-client/src/plugins/chunks.rs +++ b/azalea-client/src/plugins/chunks.rs @@ -4,7 +4,6 @@ use std::{ io::Cursor, - ops::Deref, time::{Duration, Instant}, }; @@ -15,7 +14,6 @@ use azalea_protocol::packets::game::{ }; use bevy_app::{App, Plugin, Update}; use bevy_ecs::prelude::*; -use simdnbt::owned::BaseNbt; use tracing::{error, trace}; use super::packet::game::handle_outgoing_packets; @@ -98,10 +96,7 @@ pub fn handle_receive_chunk_events( } } - let heightmaps_nbt = &event.packet.chunk_data.heightmaps; - // necessary to make the unwrap_or work - let empty_nbt = BaseNbt::default(); - let heightmaps = heightmaps_nbt.unwrap_or(&empty_nbt).deref(); + let heightmaps = &event.packet.chunk_data.heightmaps; if let Err(e) = partial_instance.chunks.replace_with_packet_data( &pos, diff --git a/azalea-client/src/test_simulation.rs b/azalea-client/src/test_simulation.rs index 564db0cf..70da309e 100644 --- a/azalea-client/src/test_simulation.rs +++ b/azalea-client/src/test_simulation.rs @@ -22,7 +22,7 @@ use azalea_world::{Chunk, Instance, MinecraftEntityId, Section}; use bevy_app::App; use bevy_ecs::{prelude::*, schedule::ExecutorKind}; use parking_lot::{Mutex, RwLock}; -use simdnbt::owned::{Nbt, NbtCompound, NbtTag}; +use simdnbt::owned::{NbtCompound, NbtTag}; use tokio::task::JoinHandle; use tokio::{sync::mpsc, time::sleep}; use uuid::Uuid; @@ -294,7 +294,7 @@ pub fn make_basic_empty_chunk( x: pos.x, z: pos.z, chunk_data: ClientboundLevelChunkPacketData { - heightmaps: Nbt::None, + heightmaps: Default::default(), data: Arc::new(chunk_bytes.into()), block_entities: vec![], }, diff --git a/azalea-language/src/en_us.json b/azalea-language/src/en_us.json index c1e30ae6..8d11c8da 100755 --- a/azalea-language/src/en_us.json +++ b/azalea-language/src/en_us.json @@ -2211,6 +2211,7 @@ "block.minecraft.test_instance_block": "Test Instance Block", "block.minecraft.tinted_glass": "Tinted Glass", "block.minecraft.tnt": "TNT", + "block.minecraft.tnt.disabled": "TNT explosions are disabled", "block.minecraft.torch": "Torch", "block.minecraft.torchflower": "Torchflower", "block.minecraft.torchflower_crop": "Torchflower Crop", @@ -3680,6 +3681,7 @@ "gamerule.spawnRadius": "Respawn location radius", "gamerule.spawnRadius.description": "Controls the size of the area around the spawn point that players can spawn in.", "gamerule.spectatorsGenerateChunks": "Allow spectators to generate terrain", + "gamerule.tntExplodes": "Allow TNT to be activated and to explode", "gamerule.tntExplosionDropDecay": "In TNT explosions, some blocks won't drop their loot", "gamerule.tntExplosionDropDecay.description": "Some of the drops from blocks destroyed by explosions caused by TNT are lost in the explosion.", "gamerule.universalAnger": "Universal anger", @@ -5212,6 +5214,7 @@ "mount.onboard": "Press %1$s to Dismount", "multiplayer.applyingPack": "Applying resource pack", "multiplayer.disconnect.authservers_down": "Authentication servers are down. Please try again later, sorry!", + "multiplayer.disconnect.bad_chat_index": "Received missed or reordered chat message from server", "multiplayer.disconnect.banned": "You are banned from this server", "multiplayer.disconnect.banned_ip.expiration": "\nYour ban will be removed on %s", "multiplayer.disconnect.banned_ip.reason": "Your IP address is banned from this server.\nReason: %s", @@ -5926,12 +5929,17 @@ "snbt.parser.expected_hex_numeral": "Expected a hexadecimal number", "snbt.parser.expected_integer_type": "Expected an integer number", "snbt.parser.expected_non_negative_number": "Expected a non-negative number", + "snbt.parser.expected_number_or_boolean": "Expected a number or a boolean", + "snbt.parser.expected_string_uuid": "Expected a string representing a valid UUID", "snbt.parser.expected_unquoted_string": "Expected a valid unquoted string", + "snbt.parser.infinity_not_allowed": "Non-finite numbers are not allowed", "snbt.parser.invalid_array_element_type": "Invalid array element type", "snbt.parser.invalid_character_name": "Invalid Unicode character name", + "snbt.parser.invalid_codepoint": "Invalid Unicode character value: %s", "snbt.parser.invalid_string_contents": "Invalid string contents", "snbt.parser.invalid_unquoted_start": "Unquoted strings can't start with digits 0-9, + or -", "snbt.parser.leading_zero_not_allowed": "Decimal numbers can't start with 0", + "snbt.parser.no_such_operation": "No such operation: %s", "snbt.parser.number_parse_failure": "Failed to parse number: %s", "snbt.parser.undescore_not_allowed": "Underscore characters are not allowed at the start or end of a number", "soundCategory.ambient": "Ambient/Environment", diff --git a/azalea-protocol/src/packets/game/c_level_chunk_with_light.rs b/azalea-protocol/src/packets/game/c_level_chunk_with_light.rs index c27c24a9..143c5f6e 100755 --- a/azalea-protocol/src/packets/game/c_level_chunk_with_light.rs +++ b/azalea-protocol/src/packets/game/c_level_chunk_with_light.rs @@ -2,6 +2,7 @@ use std::sync::Arc; use azalea_buf::AzBuf; use azalea_protocol_macros::ClientboundGamePacket; +use azalea_world::heightmap::HeightmapKind; use simdnbt::owned::Nbt; use super::c_light_update::ClientboundLightUpdatePacketData; @@ -17,7 +18,7 @@ pub struct ClientboundLevelChunkWithLight { #[derive(Clone, Debug, AzBuf)] pub struct ClientboundLevelChunkPacketData { - pub heightmaps: Nbt, + pub heightmaps: Vec<(HeightmapKind, Box<[u64]>)>, /// The raw chunk sections. /// /// We can't parse the data in azalea-protocol because it depends on context diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs index 4a936336..1facc69a 100755 --- a/azalea-protocol/src/packets/mod.rs +++ b/azalea-protocol/src/packets/mod.rs @@ -11,8 +11,8 @@ use azalea_buf::{AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError}; use crate::read::ReadPacketError; -pub const PROTOCOL_VERSION: i32 = 1073742061; -pub const VERSION_NAME: &str = "25w09b"; +pub const PROTOCOL_VERSION: i32 = 1073742064; +pub const VERSION_NAME: &str = "1.21.5-pre2"; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ConnectionProtocol { diff --git a/azalea-registry/src/tags/blocks.rs b/azalea-registry/src/tags/blocks.rs index f8c4e170..ffabba8c 100644 --- a/azalea-registry/src/tags/blocks.rs +++ b/azalea-registry/src/tags/blocks.rs @@ -942,6 +942,7 @@ pub static ENDERMAN_HOLDABLE: LazyLock> = LazyLock::new(|| { Block::WarpedFungus, Block::WarpedNylium, Block::WarpedRoots, + Block::CactusFlower, Block::Dandelion, Block::OpenEyeblossom, Block::Poppy, @@ -1726,71 +1727,39 @@ pub static MANGROVE_ROOTS_CAN_GROW_THROUGH: LazyLock> = LazyLock: pub static MINEABLE_AXE: LazyLock> = LazyLock::new(|| { HashSet::from_iter(vec![ Block::NoteBlock, - Block::AttachedMelonStem, - Block::AttachedPumpkinStem, - Block::Azalea, Block::Bamboo, Block::Barrel, Block::BeeNest, Block::Beehive, - Block::Beetroots, Block::BigDripleafStem, Block::BigDripleaf, Block::Bookshelf, Block::BrownMushroomBlock, - Block::BrownMushroom, Block::Campfire, - Block::Carrots, Block::CartographyTable, Block::CarvedPumpkin, - Block::CaveVinesPlant, - Block::CaveVines, Block::Chest, Block::ChorusFlower, Block::ChorusPlant, Block::Cocoa, Block::Composter, Block::CraftingTable, - Block::CrimsonFungus, Block::DaylightDetector, - Block::DeadBush, - Block::Fern, Block::FletchingTable, Block::GlowLichen, - Block::ShortGrass, - Block::HangingRoots, Block::JackOLantern, Block::Jukebox, Block::Ladder, - Block::LargeFern, Block::Lectern, - Block::LilyPad, Block::Loom, - Block::MelonStem, Block::Melon, Block::MushroomStem, - Block::NetherWart, - Block::Potatoes, - Block::PumpkinStem, Block::Pumpkin, Block::RedMushroomBlock, - Block::RedMushroom, - Block::Scaffolding, - Block::SmallDripleaf, Block::SmithingTable, Block::SoulCampfire, - Block::SporeBlossom, - Block::SugarCane, - Block::SweetBerryBush, - Block::TallGrass, Block::TrappedChest, - Block::TwistingVinesPlant, - Block::TwistingVines, Block::Vine, - Block::WarpedFungus, - Block::WeepingVinesPlant, - Block::WeepingVines, - Block::Wheat, Block::MangroveRoots, Block::BambooMosaic, Block::BambooMosaicSlab, @@ -1853,17 +1822,6 @@ pub static MINEABLE_AXE: LazyLock> = LazyLock::new(|| { Block::MangrovePlanks, Block::BambooPlanks, Block::CherryPlanks, - Block::OakSapling, - Block::SpruceSapling, - Block::BirchSapling, - Block::JungleSapling, - Block::AcaciaSapling, - Block::DarkOakSapling, - Block::PaleOakSapling, - Block::Azalea, - Block::FloweringAzalea, - Block::MangrovePropagule, - Block::CherrySapling, Block::OakButton, Block::SpruceButton, Block::BirchButton, @@ -2054,16 +2012,6 @@ pub static MINEABLE_HOE: LazyLock> = LazyLock::new(|| { Block::Shroomlight, Block::Sponge, Block::WetSponge, - Block::JungleLeaves, - Block::OakLeaves, - Block::SpruceLeaves, - Block::PaleOakLeaves, - Block::DarkOakLeaves, - Block::AcaciaLeaves, - Block::BirchLeaves, - Block::AzaleaLeaves, - Block::FloweringAzaleaLeaves, - Block::MangroveLeaves, Block::SculkSensor, Block::CalibratedSculkSensor, Block::MossBlock, @@ -2074,7 +2022,16 @@ pub static MINEABLE_HOE: LazyLock> = LazyLock::new(|| { Block::SculkCatalyst, Block::SculkVein, Block::SculkShrieker, - Block::PinkPetals, + Block::JungleLeaves, + Block::OakLeaves, + Block::SpruceLeaves, + Block::PaleOakLeaves, + Block::DarkOakLeaves, + Block::AcaciaLeaves, + Block::BirchLeaves, + Block::AzaleaLeaves, + Block::FloweringAzaleaLeaves, + Block::MangroveLeaves, Block::CherryLeaves, ]) }); @@ -3606,49 +3563,15 @@ pub static STRIDER_WARM_BLOCKS: LazyLock> = LazyLock::new(|| HashSet::from_iter(vec![Block::Lava])); pub static SWORD_EFFICIENT: LazyLock> = LazyLock::new(|| { HashSet::from_iter(vec![ - Block::ShortGrass, - Block::Fern, - Block::DeadBush, Block::Vine, Block::GlowLichen, - Block::Sunflower, - Block::Lilac, - Block::RoseBush, - Block::Peony, - Block::TallGrass, - Block::LargeFern, - Block::HangingRoots, - Block::PitcherPlant, - Block::BrownMushroom, - Block::RedMushroom, - Block::SugarCane, Block::Pumpkin, Block::CarvedPumpkin, Block::JackOLantern, Block::Melon, - Block::AttachedPumpkinStem, - Block::AttachedMelonStem, - Block::LilyPad, Block::Cocoa, - Block::PitcherCrop, - Block::SweetBerryBush, - Block::CaveVines, - Block::CaveVinesPlant, - Block::SporeBlossom, - Block::PinkPetals, Block::BigDripleaf, Block::BigDripleafStem, - Block::SmallDripleaf, - Block::NetherWart, - Block::WarpedFungus, - Block::WarpedRoots, - Block::NetherSprouts, - Block::CrimsonFungus, - Block::WeepingVines, - Block::WeepingVinesPlant, - Block::TwistingVines, - Block::TwistingVinesPlant, - Block::CrimsonRoots, Block::ChorusPlant, Block::ChorusFlower, Block::JungleLeaves, @@ -3662,25 +3585,6 @@ pub static SWORD_EFFICIENT: LazyLock> = LazyLock::new(|| { Block::FloweringAzaleaLeaves, Block::MangroveLeaves, Block::CherryLeaves, - Block::OakSapling, - Block::SpruceSapling, - Block::BirchSapling, - Block::JungleSapling, - Block::AcaciaSapling, - Block::DarkOakSapling, - Block::PaleOakSapling, - Block::Azalea, - Block::FloweringAzalea, - Block::MangrovePropagule, - Block::CherrySapling, - Block::Beetroots, - Block::Carrots, - Block::Potatoes, - Block::Wheat, - Block::MelonStem, - Block::PumpkinStem, - Block::TorchflowerCrop, - Block::PitcherCrop, ]) }); pub static SWORD_INSTANTLY_MINES: LazyLock> = diff --git a/azalea-registry/src/tags/items.rs b/azalea-registry/src/tags/items.rs index 624eaafa..7e6758f4 100644 --- a/azalea-registry/src/tags/items.rs +++ b/azalea-registry/src/tags/items.rs @@ -991,6 +991,40 @@ pub static FISHES: LazyLock> = LazyLock::new(|| { Item::TropicalFish, ]) }); +pub static FLOWERS: LazyLock> = LazyLock::new(|| { + HashSet::from_iter(vec![ + Item::Sunflower, + Item::Lilac, + Item::Peony, + Item::RoseBush, + Item::PitcherPlant, + Item::FloweringAzaleaLeaves, + Item::FloweringAzalea, + Item::MangrovePropagule, + Item::CherryLeaves, + Item::PinkPetals, + Item::Wildflowers, + Item::ChorusFlower, + Item::SporeBlossom, + Item::CactusFlower, + Item::Dandelion, + Item::OpenEyeblossom, + Item::Poppy, + Item::BlueOrchid, + Item::Allium, + Item::AzureBluet, + Item::RedTulip, + Item::OrangeTulip, + Item::WhiteTulip, + Item::PinkTulip, + Item::OxeyeDaisy, + Item::Cornflower, + Item::LilyOfTheValley, + Item::WitherRose, + Item::Torchflower, + Item::ClosedEyeblossom, + ]) +}); pub static FOOT_ARMOR: LazyLock> = LazyLock::new(|| { HashSet::from_iter(vec![ Item::LeatherBoots, diff --git a/azalea-world/src/chunk_storage.rs b/azalea-world/src/chunk_storage.rs index db5ac877..d6243b87 100755 --- a/azalea-world/src/chunk_storage.rs +++ b/azalea-world/src/chunk_storage.rs @@ -1,5 +1,4 @@ use std::collections::hash_map::Entry; -use std::str::FromStr; use std::{ collections::HashMap, fmt::Debug, @@ -13,7 +12,6 @@ use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError}; use azalea_core::position::{BlockPos, ChunkBlockPos, ChunkPos, ChunkSectionBlockPos}; use nohash_hasher::IntMap; use parking_lot::RwLock; -use simdnbt::owned::NbtCompound; use tracing::{debug, trace, warn}; use crate::heightmap::Heightmap; @@ -177,7 +175,7 @@ impl PartialChunkStorage { &mut self, pos: &ChunkPos, data: &mut Cursor<&[u8]>, - heightmaps: &NbtCompound, + heightmaps: &[(HeightmapKind, Box<[u64]>)], chunk_storage: &mut ChunkStorage, ) -> Result<(), BufReadError> { debug!("Replacing chunk at {:?}", pos); @@ -333,7 +331,7 @@ impl Chunk { buf: &mut Cursor<&[u8]>, dimension_height: u32, min_y: i32, - heightmaps_nbt: &NbtCompound, + heightmaps_data: &[(HeightmapKind, Box<[u64]>)], ) -> Result { let section_count = dimension_height / SECTION_HEIGHT; let mut sections = Vec::with_capacity(section_count as usize); @@ -344,18 +342,10 @@ impl Chunk { let sections = sections.into_boxed_slice(); let mut heightmaps = HashMap::new(); - for (name, heightmap) in heightmaps_nbt.iter() { - let Ok(kind) = HeightmapKind::from_str(&name.to_str()) else { - warn!("Unknown heightmap kind: {name}"); - continue; - }; - let Some(data) = heightmap.long_array() else { - warn!("Heightmap {name} is not a long array"); - continue; - }; + for (kind, data) in heightmaps_data { let data: Box<[u64]> = data.iter().map(|x| *x as u64).collect(); - let heightmap = Heightmap::new(kind, dimension_height, min_y, data); - heightmaps.insert(kind, heightmap); + let heightmap = Heightmap::new(*kind, dimension_height, min_y, data); + heightmaps.insert(*kind, heightmap); } Ok(Chunk { @@ -449,7 +439,7 @@ impl AzaleaRead for Section { let block_count = u16::azalea_read(buf)?; // this is commented out because the vanilla server is wrong - // ^ this comment was written ages ago. needs more investigation. + // TODO: ^ this comment was written ages ago. needs more investigation. // assert!( // block_count <= 16 * 16 * 16, // "A section has more blocks than what should be possible. This is a bug!" diff --git a/azalea-world/src/heightmap.rs b/azalea-world/src/heightmap.rs index f1ef30d2..00ebad41 100644 --- a/azalea-world/src/heightmap.rs +++ b/azalea-world/src/heightmap.rs @@ -1,6 +1,7 @@ use std::{fmt::Display, str::FromStr}; use azalea_block::BlockState; +use azalea_buf::AzBuf; use azalea_core::{math, position::ChunkBlockPos}; use azalea_registry::tags::blocks::LEAVES; @@ -8,7 +9,7 @@ use crate::{BitStorage, Section, chunk_storage::get_block_state_from_sections}; // (wg stands for worldgen) -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, AzBuf)] pub enum HeightmapKind { WorldSurfaceWg, WorldSurface, diff --git a/azalea-world/src/palette.rs b/azalea-world/src/palette.rs index 97786e7c..699ee2d5 100755 --- a/azalea-world/src/palette.rs +++ b/azalea-world/src/palette.rs @@ -2,7 +2,6 @@ use std::io::{Cursor, Write}; use azalea_block::block_state::BlockStateIntegerRepr; use azalea_buf::{AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError}; -use azalea_core::math; use tracing::warn; use crate::BitStorage; @@ -45,37 +44,15 @@ impl PalettedContainer { buf: &mut Cursor<&[u8]>, container_type: &'static PalettedContainerKind, ) -> Result { - let server_bits_per_entry = u8::azalea_read(buf)?; - let palette_type = PaletteKind::from_bits_and_type(server_bits_per_entry, container_type); + let bits_per_entry = u8::azalea_read(buf)?; + let palette_type = PaletteKind::from_bits_and_type(bits_per_entry, container_type); let palette = palette_type.read(buf)?; let size = container_type.size(); - let data = Box::<[u64]>::azalea_read(buf)?; - - // we can only trust the bits per entry that we're sent if there's enough data - // that it'd be global. if it's not global, then we have to calculate it - // ourselves. - // this almost never matters, except on some custom servers like hypixel limbo - // TODO: this is incorrect. we should be getting the log2 of the max blockstate - // or biome instead of data.len(). this code might be causing wrong data to be - // read. ¯\_(ツ)_/¯ - let calculated_bits_per_entry = math::ceil_log2(data.len() as u32) as u8; - let calculated_bits_per_entry_palette_kind = - PaletteKind::from_bits_and_type(calculated_bits_per_entry, container_type); - let bits_per_entry = if calculated_bits_per_entry_palette_kind == PaletteKind::Global { - server_bits_per_entry - } else { - calculated_bits_per_entry - }; - - debug_assert!( - bits_per_entry != 0 || data.is_empty(), - "Bits per entry is 0 but data is not empty." - ); let mut storage = match BitStorage::new( - bits_per_entry.into(), + bits_per_entry as usize, size, - if data.is_empty() { + if bits_per_entry == 0 { Some(Box::new([])) } else { // we're going to update the data after creating the bitstorage @@ -90,9 +67,11 @@ impl PalettedContainer { )); } }; - // minecraft does this to allow the data to have extra padding bits. most - // servers don't use this, but it's notably used by hypixel. - storage.data = data; + + // now read the data + for i in 0..storage.data.len() { + storage.data[i] = u64::azalea_read(buf)?; + } Ok(PalettedContainer { bits_per_entry, diff --git a/codegen/migrate.py b/codegen/migrate.py index 3e64fa51..30e33812 100755 --- a/codegen/migrate.py +++ b/codegen/migrate.py @@ -49,7 +49,7 @@ new_block_states_report = lib.extract.get_block_states_report(new_version_id) new_registries = lib.extract.get_registries_report(new_version_id) new_ordered_blocks = lib.code.blocks.get_ordered_blocks(new_registries) lib.code.blocks.generate_blocks( - new_block_states_report, new_pixlyzer_block_datas, new_ordered_blocks) + new_block_states_report, new_pixlyzer_block_datas, new_ordered_blocks, new_burger_data) lib.code.shapes.generate_block_shapes( new_pixlyzer_block_datas, new_shape_datas['shapes'], new_shape_datas['aabbs'], new_block_states_report)