refactor(client): use .map for queries
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
macro_rules! get_entities {
|
macro_rules! get_entities {
|
||||||
($client:ident) => {{
|
($client:ident) => {{
|
||||||
let ecs = $client.ecs.read();
|
let ecs = $client.ecs.read();
|
||||||
if let Some(mut query) = ecs.try_query::<(
|
ecs.try_query::<(
|
||||||
&AzaleaPosition,
|
&AzaleaPosition,
|
||||||
&CustomName,
|
&CustomName,
|
||||||
&EntityKindComponent,
|
&EntityKindComponent,
|
||||||
@@ -11,7 +11,8 @@ macro_rules! get_entities {
|
|||||||
&MinecraftEntityId,
|
&MinecraftEntityId,
|
||||||
Option<&Owneruuid>,
|
Option<&Owneruuid>,
|
||||||
&Pose,
|
&Pose,
|
||||||
)>() {
|
)>()
|
||||||
|
.map(|mut query| {
|
||||||
query
|
query
|
||||||
.iter(&ecs)
|
.iter(&ecs)
|
||||||
.map(
|
.map(
|
||||||
@@ -29,9 +30,8 @@ macro_rules! get_entities {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
} else {
|
})
|
||||||
Vec::new()
|
.unwrap_or_default()
|
||||||
}
|
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ macro_rules! get_entities {
|
|||||||
macro_rules! get_players {
|
macro_rules! get_players {
|
||||||
($client:ident) => {{
|
($client:ident) => {{
|
||||||
let ecs = $client.ecs.read();
|
let ecs = $client.ecs.read();
|
||||||
if let Some(mut query) = ecs.try_query_filtered::<(
|
ecs.try_query_filtered::<(
|
||||||
&MinecraftEntityId,
|
&MinecraftEntityId,
|
||||||
&EntityUuid,
|
&EntityUuid,
|
||||||
&EntityKindComponent,
|
&EntityKindComponent,
|
||||||
@@ -47,22 +47,21 @@ macro_rules! get_players {
|
|||||||
&LookDirection,
|
&LookDirection,
|
||||||
&Pose,
|
&Pose,
|
||||||
), (With<Player>, Without<Dead>)>()
|
), (With<Player>, Without<Dead>)>()
|
||||||
{
|
.map(|mut query| {
|
||||||
query
|
query
|
||||||
.iter(&ecs)
|
.iter(&ecs)
|
||||||
.map(|(id, uuid, kind, position, direction, pose)| {
|
.map(|(id, uuid, kind, position, direction, pose)| {
|
||||||
(
|
(
|
||||||
id.0,
|
id.0,
|
||||||
uuid.to_string(),
|
uuid.to_string(),
|
||||||
kind.to_string(),
|
kind.to_string(),
|
||||||
Vec3::from(*position),
|
Vec3::from(*position),
|
||||||
Direction::from(direction),
|
Direction::from(direction),
|
||||||
*pose as u8,
|
*pose as u8,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
} else {
|
})
|
||||||
Vec::new()
|
.unwrap_or_default()
|
||||||
}
|
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user