feat(client): pass owner uuid to find_entities
This commit is contained in:
parent
29a8c9fcf2
commit
663873ba59
@ -6,7 +6,7 @@ use azalea::{
|
|||||||
ecs::query::{With, Without},
|
ecs::query::{With, Without},
|
||||||
entity::{
|
entity::{
|
||||||
Dead, EntityKind, EntityUuid, LookDirection, Pose, Position as AzaleaPosition,
|
Dead, EntityKind, EntityUuid, LookDirection, Pose, Position as AzaleaPosition,
|
||||||
metadata::{CustomName, Player},
|
metadata::{CustomName, Owneruuid, Player},
|
||||||
},
|
},
|
||||||
world::{InstanceName, MinecraftEntityId},
|
world::{InstanceName, MinecraftEntityId},
|
||||||
};
|
};
|
||||||
@ -56,38 +56,45 @@ pub async fn find_entities(
|
|||||||
let entities = {
|
let entities = {
|
||||||
let mut ecs = client.ecs.lock();
|
let mut ecs = client.ecs.lock();
|
||||||
ecs.query_filtered::<(
|
ecs.query_filtered::<(
|
||||||
&MinecraftEntityId,
|
|
||||||
&EntityUuid,
|
|
||||||
&EntityKind,
|
|
||||||
&CustomName,
|
|
||||||
&AzaleaPosition,
|
&AzaleaPosition,
|
||||||
|
&CustomName,
|
||||||
|
&EntityKind,
|
||||||
|
&EntityUuid,
|
||||||
&LookDirection,
|
&LookDirection,
|
||||||
|
&MinecraftEntityId,
|
||||||
|
&Owneruuid,
|
||||||
&Pose,
|
&Pose,
|
||||||
), Without<Dead>>()
|
), Without<Dead>>()
|
||||||
.iter(&ecs)
|
.iter(&ecs)
|
||||||
.map(|(id, uuid, kind, custom_name, position, direction, pose)| {
|
.map(
|
||||||
(
|
|(position, custom_name, kind, uuid, direction, id, owner_uuid, pose)| {
|
||||||
id.0,
|
(
|
||||||
uuid.to_string(),
|
Vec3::from(position),
|
||||||
kind.to_string(),
|
custom_name.as_ref().map(ToString::to_string),
|
||||||
custom_name.as_ref().map(ToString::to_string),
|
kind.to_string(),
|
||||||
Vec3::from(position),
|
uuid.to_string(),
|
||||||
Direction::from(direction),
|
Direction::from(direction),
|
||||||
*pose as u8,
|
id.0,
|
||||||
)
|
owner_uuid.to_owned(),
|
||||||
})
|
*pose as u8,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut matched = Vec::new();
|
let mut matched = Vec::new();
|
||||||
for (id, uuid, kind, custom_name, position, direction, pose) in entities {
|
for (position, custom_name, kind, uuid, direction, id, owner_uuid, pose) in entities {
|
||||||
let entity = lua.create_table()?;
|
let entity = lua.create_table()?;
|
||||||
entity.set("id", id)?;
|
|
||||||
entity.set("uuid", uuid)?;
|
|
||||||
entity.set("kind", kind)?;
|
|
||||||
entity.set("custom_name", custom_name)?;
|
|
||||||
entity.set("position", position)?;
|
entity.set("position", position)?;
|
||||||
|
entity.set("custom_name", custom_name)?;
|
||||||
|
entity.set("kind", kind)?;
|
||||||
|
entity.set("uuid", uuid)?;
|
||||||
entity.set("direction", direction)?;
|
entity.set("direction", direction)?;
|
||||||
|
entity.set("id", id)?;
|
||||||
|
if let Some(uuid) = *owner_uuid {
|
||||||
|
entity.set("owner_uuid", uuid.to_string())?;
|
||||||
|
}
|
||||||
entity.set("pose", pose)?;
|
entity.set("pose", pose)?;
|
||||||
if filter_fn.call_async::<bool>(&entity).await? {
|
if filter_fn.call_async::<bool>(&entity).await? {
|
||||||
matched.push(entity);
|
matched.push(entity);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user