aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml4
-rw-r--r--azalea-entity/src/plugin/mod.rs12
2 files changed, 11 insertions, 5 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 9f050d7f..f866ba75 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -35,7 +35,9 @@ anyhow = "1.0.100"
async-compat = "0.2.5"
base64 = "0.22.1"
bevy_app = "0.18.0"
-bevy_ecs = { version = "0.18.0", default-features = false }
+bevy_ecs = { version = "0.18.0", default-features = false, features = [
+ "multi_threaded",
+] }
bevy_utils = { version = "0.18.0", default-features = false }
bevy_log = "0.18.0"
bevy_tasks = "0.18.0"
diff --git a/azalea-entity/src/plugin/mod.rs b/azalea-entity/src/plugin/mod.rs
index b86c6b7d..7c4f3ed4 100644
--- a/azalea-entity/src/plugin/mod.rs
+++ b/azalea-entity/src/plugin/mod.rs
@@ -254,10 +254,10 @@ pub struct InLoadedChunk;
/// Update the [`InLoadedChunk`] component for all entities in the world.
pub fn update_in_loaded_chunk(
mut commands: bevy_ecs::system::Commands,
- query: Query<(Entity, &WorldName, &Position)>,
+ query: Query<(Entity, &WorldName, &Position, Option<&InLoadedChunk>)>,
worlds: Res<Worlds>,
) {
- for (entity, world_name, position) in &query {
+ for (entity, world_name, position, last_in_loaded_chunk) in &query {
let player_chunk_pos = ChunkPos::from(position);
let Some(world_lock) = worlds.get(world_name) else {
commands.entity(entity).remove::<InLoadedChunk>();
@@ -266,9 +266,13 @@ pub fn update_in_loaded_chunk(
let in_loaded_chunk = world_lock.read().chunks.get(&player_chunk_pos).is_some();
if in_loaded_chunk {
- commands.entity(entity).insert(InLoadedChunk);
+ if last_in_loaded_chunk.is_none() {
+ commands.entity(entity).insert(InLoadedChunk);
+ }
} else {
- commands.entity(entity).remove::<InLoadedChunk>();
+ if last_in_loaded_chunk.is_some() {
+ commands.entity(entity).remove::<InLoadedChunk>();
+ }
}
}
}