From af3affb467c01ee2880fbbc366ea0420c0580ab8 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 6 May 2025 09:28:28 -1030 Subject: fix chunk errors when joining a world with a same name but different height --- azalea-world/src/chunk_storage.rs | 2 +- azalea-world/src/world.rs | 6 ++++++ 2 files changed, 7 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 d8357a95..9e97a7a7 100644 --- a/azalea-world/src/chunk_storage.rs +++ b/azalea-world/src/chunk_storage.rs @@ -26,7 +26,7 @@ const SECTION_HEIGHT: u32 = 16; pub struct PartialChunkStorage { /// The center of the view, i.e. the chunk the player is currently in. view_center: ChunkPos, - chunk_radius: u32, + pub(crate) chunk_radius: u32, view_range: u32, // chunks is a list of size chunk_radius * chunk_radius chunks: Box<[Option>>]>, diff --git a/azalea-world/src/world.rs b/azalea-world/src/world.rs index a650f152..4b2b2a19 100644 --- a/azalea-world/src/world.rs +++ b/azalea-world/src/world.rs @@ -41,6 +41,12 @@ impl PartialInstance { entity_infos: PartialEntityInfos::new(owner_entity), } } + + /// Clears the internal references to chunks in the PartialInstance and + /// resets the view center. + pub fn reset(&mut self) { + self.chunks = PartialChunkStorage::new(self.chunks.chunk_radius); + } } /// An entity ID used by Minecraft. -- cgit v1.2.3