aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/nearest_entity.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2026-01-13 10:51:30 -0600
committerGitHub <noreply@github.com>2026-01-13 10:51:30 -0600
commitd5fa5e32b37754b3b5c136e58821e48cd3b7c2ff (patch)
treeea04702f96ad170fb1d90e5ed2dc875ae8166495 /azalea/src/nearest_entity.rs
parentefb36d5fc0fe56a98f5795c53dfa109887cd5aae (diff)
downloadazalea-drasl-d5fa5e32b37754b3b5c136e58821e48cd3b7c2ff.tar.xz
Rename Instance to World (#304)
Diffstat (limited to 'azalea/src/nearest_entity.rs')
-rw-r--r--azalea/src/nearest_entity.rs46
1 files changed, 23 insertions, 23 deletions
diff --git a/azalea/src/nearest_entity.rs b/azalea/src/nearest_entity.rs
index bf3f2fdb..3dc32adc 100644
--- a/azalea/src/nearest_entity.rs
+++ b/azalea/src/nearest_entity.rs
@@ -1,6 +1,6 @@
use azalea_core::entity_id::MinecraftEntityId;
use azalea_entity::Position;
-use azalea_world::InstanceName;
+use azalea_world::WorldName;
use bevy_ecs::{
prelude::Entity,
query::{QueryFilter, With},
@@ -11,8 +11,8 @@ use bevy_ecs::{
/// entity, (or several) close to a given position.
///
/// This system parameter allows for additional filtering of entities based off
-/// of ECS marker components, such as `With<>`, `Without<>`, or `Added<>`, etc.
-/// All functions used by this system parameter instance will respect the
+/// of ECS marker components, such as `With<T>`, `Without<T>`, or `Added<T>`,
+/// etc. All functions used by this system parameter instance will respect the
/// applied filter.
///
/// ```
@@ -50,13 +50,12 @@ pub struct EntityFinder<'w, 's, F = ()>
where
F: QueryFilter + 'static,
{
- all_entities:
- Query<'w, 's, (&'static Position, &'static InstanceName), With<MinecraftEntityId>>,
+ all_entities: Query<'w, 's, (&'static Position, &'static WorldName), With<MinecraftEntityId>>,
filtered_entities: Query<
'w,
's,
- (Entity, &'static InstanceName, &'static Position),
+ (Entity, &'static WorldName, &'static Position),
(With<MinecraftEntityId>, F),
>,
}
@@ -65,21 +64,22 @@ impl<'a, F> EntityFinder<'_, '_, F>
where
F: QueryFilter + 'static,
{
- /// Gets the nearest entity to the given position and world instance name.
+ /// Gets the nearest entity to the given position and with the given world
+ /// name.
///
/// This method will return `None` if there are no entities within range. If
/// multiple entities are within range, only the closest one is returned.
pub fn nearest_to_position(
&'a self,
position: Position,
- instance_name: &InstanceName,
+ world_name: &WorldName,
max_distance: f64,
) -> Option<Entity> {
let mut nearest_entity = None;
let mut min_distance = max_distance;
- for (target_entity, e_instance, e_pos) in self.filtered_entities.iter() {
- if e_instance != instance_name {
+ for (target_entity, e_world, e_pos) in self.filtered_entities.iter() {
+ if e_world != world_name {
continue;
}
@@ -99,19 +99,19 @@ where
/// multiple entities are within range, only the closest one is
/// returned.
pub fn nearest_to_entity(&'a self, entity: Entity, max_distance: f64) -> Option<Entity> {
- let Ok((position, instance_name)) = self.all_entities.get(entity) else {
+ let Ok((position, world_name)) = self.all_entities.get(entity) else {
return None;
};
let mut nearest_entity = None;
let mut min_distance = max_distance;
- for (target_entity, e_instance, e_pos) in self.filtered_entities.iter() {
+ for (target_entity, e_world, e_pos) in self.filtered_entities.iter() {
if entity == target_entity {
continue;
};
- if e_instance != instance_name {
+ if e_world != world_name {
continue;
}
@@ -135,13 +135,13 @@ where
pub fn nearby_entities_to_position(
&'a self,
position: &'a Position,
- instance_name: &'a InstanceName,
+ world_name: &'a WorldName,
max_distance: f64,
) -> impl Iterator<Item = (Entity, f64)> + 'a {
self.filtered_entities
.iter()
- .filter_map(move |(target_entity, e_instance, e_pos)| {
- if e_instance != instance_name {
+ .filter_map(move |(target_entity, e_world, e_pos)| {
+ if e_world != world_name {
return None;
}
@@ -167,23 +167,23 @@ where
max_distance: f64,
) -> impl Iterator<Item = (Entity, f64)> + 'a {
let position;
- let instance_name;
- if let Ok((pos, instance)) = self.all_entities.get(entity) {
- position = *pos;
- instance_name = Some(instance);
+ let world_name;
+ if let Ok((p, w)) = self.all_entities.get(entity) {
+ position = *p;
+ world_name = Some(w);
} else {
position = Position::default();
- instance_name = None;
+ world_name = None;
};
self.filtered_entities
.iter()
- .filter_map(move |(target_entity, e_instance, e_pos)| {
+ .filter_map(move |(target_entity, e_world, e_pos)| {
if entity == target_entity {
return None;
}
- if Some(e_instance) != instance_name {
+ if Some(e_world) != world_name {
return None;
}