diff options
| author | mat <git@matdoes.dev> | 2025-05-06 09:28:28 -1030 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-05-07 06:00:29 +1000 |
| commit | af3affb467c01ee2880fbbc366ea0420c0580ab8 (patch) | |
| tree | f8619a19b927f18cdf18445890f65cedb9773f58 /azalea-world/src | |
| parent | 68f657310bf7f69f7f9dd0476ca9c04da191ab33 (diff) | |
| download | azalea-drasl-af3affb467c01ee2880fbbc366ea0420c0580ab8.tar.xz | |
fix chunk errors when joining a world with a same name but different height
Diffstat (limited to 'azalea-world/src')
| -rw-r--r-- | azalea-world/src/chunk_storage.rs | 2 | ||||
| -rw-r--r-- | azalea-world/src/world.rs | 6 |
2 files changed, 7 insertions, 1 deletions
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<Arc<RwLock<Chunk>>>]>, 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. |
