aboutsummaryrefslogtreecommitdiff
path: root/azalea-world/src
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-06-17 15:59:27 -0500
committermat <github@matdoes.dev>2022-06-17 15:59:27 -0500
commit69e1125ecbb3e695125b8e65deba3e3f7be41b70 (patch)
tree92821e0b3a1afc2145798757117478920bae3d10 /azalea-world/src
parent74c3ae52f84d988b8bf3f0affe143d2cd2d8143a (diff)
downloadazalea-drasl-69e1125ecbb3e695125b8e65deba3e3f7be41b70.tar.xz
Slightly improve bit storage
Diffstat (limited to 'azalea-world/src')
-rw-r--r--azalea-world/src/bit_storage.rs12
-rw-r--r--azalea-world/src/lib.rs4
2 files changed, 10 insertions, 6 deletions
diff --git a/azalea-world/src/bit_storage.rs b/azalea-world/src/bit_storage.rs
index c69cb216..0dc81f9a 100644
--- a/azalea-world/src/bit_storage.rs
+++ b/azalea-world/src/bit_storage.rs
@@ -77,8 +77,8 @@ pub struct BitStorage {
mask: u64,
size: usize,
values_per_long: u8,
- divide_mul: i32,
- divide_add: i32,
+ divide_mul: u64,
+ divide_add: u64,
divide_shift: i32,
}
@@ -138,16 +138,16 @@ impl BitStorage {
mask,
size,
values_per_long: values_per_long as u8,
- divide_mul,
- divide_add,
+ divide_mul: divide_mul as u32 as u64,
+ divide_add: divide_add as u32 as u64,
divide_shift,
})
}
pub fn cell_index(&self, index: u64) -> usize {
// as unsigned wrap
- let first = self.divide_mul as u32 as u64;
- let second = self.divide_add as u64;
+ let first = self.divide_mul;
+ let second = self.divide_add;
(((index * first) + second) >> 32 >> self.divide_shift)
.try_into()
diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs
index 8777c0a3..26566416 100644
--- a/azalea-world/src/lib.rs
+++ b/azalea-world/src/lib.rs
@@ -205,12 +205,15 @@ pub struct Section {
impl McBufReadable for Section {
fn read_into(buf: &mut impl Read) -> Result<Self, String> {
let block_count = u16::read_into(buf)?;
+
// this is commented out because the vanilla server is wrong
// assert!(
// block_count <= 16 * 16 * 16,
// "A section has more blocks than what should be possible. This is a bug!"
// );
+
let states = PalettedContainer::read_with_type(buf, &PalettedContainerType::BlockStates)?;
+
for i in 0..states.storage.size() {
if !BlockState::is_valid_state(states.storage.get(i) as u32) {
return Err(format!(
@@ -219,6 +222,7 @@ impl McBufReadable for Section {
));
}
}
+
let biomes = PalettedContainer::read_with_type(buf, &PalettedContainerType::Biomes)?;
Ok(Section {
block_count,