From 22ea8c60fed17e48a591bcbb82808fed55509386 Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 23 Jul 2023 23:21:08 -0500 Subject: fix sometimes not receiving chunks --- azalea-world/src/chunk_storage.rs | 6 ++++++ azalea-world/src/lib.rs | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'azalea-world/src') diff --git a/azalea-world/src/chunk_storage.rs b/azalea-world/src/chunk_storage.rs index 3c8d3555..d831770c 100755 --- a/azalea-world/src/chunk_storage.rs +++ b/azalea-world/src/chunk_storage.rs @@ -53,6 +53,12 @@ pub struct Section { pub biomes: PalettedContainer, } +/// Get the actual stored view distance for the selected view distance. For some +/// reason Minecraft actually stores an extra 3 chunks. +pub fn calculate_chunk_storage_range(view_distance: u32) -> u32 { + u32::max(view_distance, 2) + 3 +} + impl Default for Section { fn default() -> Self { Section { diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs index be2c46c1..9c1f5ff5 100644 --- a/azalea-world/src/lib.rs +++ b/azalea-world/src/lib.rs @@ -13,7 +13,9 @@ mod world; use std::backtrace::Backtrace; pub use bit_storage::BitStorage; -pub use chunk_storage::{Chunk, ChunkStorage, PartialChunkStorage, Section}; +pub use chunk_storage::{ + calculate_chunk_storage_range, Chunk, ChunkStorage, PartialChunkStorage, Section, +}; pub use container::*; use thiserror::Error; pub use world::*; -- cgit v1.2.3