feat(client): add pathfinder field
This commit is contained in:
parent
54c6b8c88f
commit
c65682d273
@ -11,6 +11,7 @@ use azalea::{
|
||||
Client as AzaleaClient,
|
||||
entity::metadata::{AirSupply, Score},
|
||||
interact::HitResultComponent,
|
||||
pathfinder::{ExecutingPath, Pathfinder},
|
||||
};
|
||||
use mlua::{Lua, Result, UserData, UserDataFields, UserDataMethods};
|
||||
|
||||
@ -74,6 +75,37 @@ impl UserData for Client {
|
||||
})
|
||||
});
|
||||
|
||||
f.add_field_method_get("pathfinder", |lua, this| {
|
||||
let client = this.inner.as_ref().unwrap();
|
||||
let pathfinder = lua.create_table()?;
|
||||
pathfinder.set(
|
||||
"is_calculating",
|
||||
client.component::<Pathfinder>().is_calculating,
|
||||
)?;
|
||||
pathfinder.set(
|
||||
"is_executing",
|
||||
if let Some(p) = client.get_component::<ExecutingPath>() {
|
||||
pathfinder.set(
|
||||
"last_reached_node",
|
||||
Vec3 {
|
||||
x: f64::from(p.last_reached_node.x),
|
||||
y: f64::from(p.last_reached_node.y),
|
||||
z: f64::from(p.last_reached_node.z),
|
||||
},
|
||||
)?;
|
||||
pathfinder.set(
|
||||
"last_node_reach_elapsed",
|
||||
p.last_node_reached_at.elapsed().as_millis(),
|
||||
)?;
|
||||
pathfinder.set("is_path_partial", p.is_path_partial)?;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
},
|
||||
)?;
|
||||
Ok(pathfinder)
|
||||
});
|
||||
|
||||
f.add_field_method_get("position", |_, this| {
|
||||
let p = this.inner.as_ref().unwrap().position();
|
||||
Ok(Vec3 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user