diff options
| author | mat <git@matdoes.dev> | 2026-02-21 23:25:40 -0530 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-02-21 23:25:40 -0530 |
| commit | b4e4d2c001dddd530c6e416e841c571c7e127138 (patch) | |
| tree | ff45d9d1bae16be06a1a71651f7ad2f86182b0f9 | |
| parent | 2756eb419af2210eed3d0574e20a620918e4e577 (diff) | |
| download | azalea-drasl-b4e4d2c001dddd530c6e416e841c571c7e127138.tar.xz | |
enable threaded ecs and implement some micro-optimizations
| -rw-r--r-- | Cargo.toml | 4 | ||||
| -rw-r--r-- | azalea-entity/src/plugin/mod.rs | 12 |
2 files changed, 11 insertions, 5 deletions
@@ -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>(); + } } } } |
