Skip to content

Commit

Permalink
Fix: Check is chunks Vec is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowiiii committed Nov 7, 2024
1 parent 16dabf1 commit 1667e1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions pumpkin/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ impl World {
}

#[expect(clippy::too_many_lines)]
/// IMPORTANT: Chunks have to be non-empty
fn spawn_world_chunks(&self, player: Arc<Player>, chunks: &[Vector2<i32>]) {
if player
.client
Expand Down
6 changes: 4 additions & 2 deletions pumpkin/src/world/player_chunker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ pub async fn player_join(world: &World, player: Arc<Player>) {

let new_cylindrical = Cylindrical::new(Vector2::new(chunk_pos.x, chunk_pos.z), view_distance);
let loading_chunks = new_cylindrical.all_chunks_within();

world.spawn_world_chunks(player, &loading_chunks);

if !loading_chunks.is_empty() {
world.spawn_world_chunks(player, &loading_chunks);
}
}

pub async fn update_position(player: &Arc<Player>) {
Expand Down

0 comments on commit 1667e1c

Please sign in to comment.