aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--azalea-client/src/plugins/packet/relative_updates.rs2
-rw-r--r--azalea-entity/src/plugin/mod.rs1
-rw-r--r--azalea-world/src/bit_storage.rs2
-rw-r--r--azalea-world/src/chunk_storage.rs32
-rw-r--r--azalea-world/src/palette/container.rs11
-rw-r--r--azalea-world/src/palette/mod.rs2
6 files changed, 43 insertions, 7 deletions
diff --git a/azalea-client/src/plugins/packet/relative_updates.rs b/azalea-client/src/plugins/packet/relative_updates.rs
index d6367829..35218e7d 100644
--- a/azalea-client/src/plugins/packet/relative_updates.rs
+++ b/azalea-client/src/plugins/packet/relative_updates.rs
@@ -107,7 +107,7 @@ pub fn should_apply_entity_update(
let this_client_updates_received = partial_entity_infos
.updates_received
- .get(&minecraft_entity_id)
+ .get(minecraft_entity_id)
.copied();
let can_update = if let Some(updates_received) = updates_received {
diff --git a/azalea-entity/src/plugin/mod.rs b/azalea-entity/src/plugin/mod.rs
index 7c4f3ed4..bedb03b0 100644
--- a/azalea-entity/src/plugin/mod.rs
+++ b/azalea-entity/src/plugin/mod.rs
@@ -231,6 +231,7 @@ pub fn update_dimensions(
}
}
+#[allow(clippy::type_complexity)]
pub fn update_crouching(
query: Query<(&mut Crouching, &Pose), (Without<LocalEntity>, With<Player>)>,
) {
diff --git a/azalea-world/src/bit_storage.rs b/azalea-world/src/bit_storage.rs
index 44705f88..cefc0aeb 100644
--- a/azalea-world/src/bit_storage.rs
+++ b/azalea-world/src/bit_storage.rs
@@ -71,7 +71,7 @@ const MAGIC: [(i32, i32, u32); 64] = [
];
/// A compact list of integers with the given number of bits per entry.
-#[derive(Clone, Debug, Default)]
+#[derive(Clone, Debug, Default, PartialEq)]
pub struct BitStorage {
pub data: Box<[u64]>,
bits: usize,
diff --git a/azalea-world/src/chunk_storage.rs b/azalea-world/src/chunk_storage.rs
index 23da5af5..3f410773 100644
--- a/azalea-world/src/chunk_storage.rs
+++ b/azalea-world/src/chunk_storage.rs
@@ -79,7 +79,7 @@ pub struct Chunk {
}
/// A section of a chunk, i.e. a 16*16*16 block area.
-#[derive(Clone, Debug, Default)]
+#[derive(Clone, Debug, Default, PartialEq)]
pub struct Section {
/// The number of non-empty blocks in the section, as sent to us by the
/// server.
@@ -579,6 +579,7 @@ pub fn section_index(y: i32, min_y: i32) -> u32 {
#[cfg(test)]
mod tests {
use super::*;
+ use crate::palette::SectionPos;
#[test]
fn test_section_index() {
@@ -639,4 +640,33 @@ mod tests {
ChunkPos::new(2, -1),
);
}
+
+ #[test]
+ fn serialize_and_deserialize_section() {
+ let mut states = PalettedContainer::new();
+
+ states.set(
+ SectionPos::new(1, 2, 3),
+ BlockState::try_from(BlockState::MAX_STATE).unwrap(),
+ );
+ states.set(
+ SectionPos::new(4, 5, 6),
+ BlockState::try_from(BlockState::MAX_STATE).unwrap(),
+ );
+ let biomes = PalettedContainer::new();
+ let section = Section {
+ block_count: 2,
+ states,
+ biomes,
+ };
+
+ let mut buf = Vec::new();
+ section.azalea_write(&mut buf).unwrap();
+
+ let mut cur = Cursor::new(buf.as_slice());
+ let deserialized_section = Section::azalea_read(&mut cur).unwrap();
+ assert_eq!(cur.position(), buf.len() as u64);
+
+ assert_eq!(section, deserialized_section);
+ }
}
diff --git a/azalea-world/src/palette/container.rs b/azalea-world/src/palette/container.rs
index 4e4e5595..43262a3d 100644
--- a/azalea-world/src/palette/container.rs
+++ b/azalea-world/src/palette/container.rs
@@ -12,7 +12,7 @@ use tracing::{debug, warn};
use super::{Palette, PaletteKind};
use crate::BitStorage;
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, PartialEq)]
pub struct PalettedContainer<S: PalletedContainerKind> {
pub bits_per_entry: u8,
/// This is usually a list of unique values that appear in the container so
@@ -25,7 +25,9 @@ pub struct PalettedContainer<S: PalletedContainerKind> {
pub storage: BitStorage,
}
-pub trait PalletedContainerKind: Copy + Clone + Debug + Default + TryFrom<u32> + Into<u32> {
+pub trait PalletedContainerKind:
+ Copy + Clone + Debug + Default + PartialEq + TryFrom<u32> + Into<u32>
+{
type SectionPos: SectionPos;
fn size_bits() -> usize;
@@ -295,7 +297,10 @@ impl<S: PalletedContainerKind> PalettedContainer<S> {
pub fn write(&self, buf: &mut impl Write) -> io::Result<()> {
self.bits_per_entry.azalea_write(buf)?;
self.palette.write(buf)?;
- self.storage.data.azalea_write(buf)?;
+ for word in &self.storage.data {
+ word.azalea_write(buf)?;
+ }
+
Ok(())
}
}
diff --git a/azalea-world/src/palette/mod.rs b/azalea-world/src/palette/mod.rs
index 11b38f45..067c68c4 100644
--- a/azalea-world/src/palette/mod.rs
+++ b/azalea-world/src/palette/mod.rs
@@ -12,7 +12,7 @@ use azalea_buf::{AzBufVar, BufReadError};
pub use container::*;
/// A representation of the different types of chunk palettes Minecraft uses.
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, PartialEq)]
pub enum Palette<S: PalletedContainerKind> {
/// ID of the corresponding entry in its global palette
SingleValue(S),