feat: switch to luajit for more features
This commit is contained in:
@@ -58,7 +58,7 @@ impl UserData for Client {
|
||||
|
||||
fn add_methods<M: UserDataMethods<Self>>(m: &mut M) {
|
||||
m.add_async_method("attack", interaction::attack);
|
||||
m.add_async_method("goto", movement::goto);
|
||||
m.add_async_method("go_to", movement::go_to);
|
||||
m.add_async_method("look_at", movement::look_at);
|
||||
m.add_async_method("mine", interaction::mine);
|
||||
m.add_async_method("open_container_at", container::open_container_at);
|
||||
|
@@ -22,7 +22,7 @@ pub fn eye_position(_lua: &Lua, client: &Client) -> Result<Vec3> {
|
||||
Ok(Vec3::from(client.eye_position()))
|
||||
}
|
||||
|
||||
pub async fn goto(
|
||||
pub async fn go_to(
|
||||
lua: Lua,
|
||||
client: UserDataRef<Client>,
|
||||
(data, metadata): (Value, Option<Table>),
|
||||
@@ -89,7 +89,7 @@ pub async fn goto(
|
||||
&client,
|
||||
without_mining,
|
||||
YGoal {
|
||||
y: data.as_integer().ok_or(error)?,
|
||||
y: data.as_table().ok_or(error)?.get("y")?,
|
||||
},
|
||||
),
|
||||
_ => {
|
||||
|
@@ -50,8 +50,8 @@ impl From<BlockPos> for Vec3 {
|
||||
|
||||
impl FromLua for Vec3 {
|
||||
fn from_lua(value: Value, _lua: &Lua) -> Result<Self> {
|
||||
match value {
|
||||
Value::Table(table) => Ok(
|
||||
if let Value::Table(table) = value {
|
||||
Ok(
|
||||
if let (Ok(x), Ok(y), Ok(z)) = (table.get(1), table.get(2), table.get(3)) {
|
||||
Self { x, y, z }
|
||||
} else {
|
||||
@@ -61,17 +61,13 @@ impl FromLua for Vec3 {
|
||||
z: table.get("z")?,
|
||||
}
|
||||
},
|
||||
),
|
||||
Value::Vector(vector) => Ok(Self {
|
||||
x: vector.x().into(),
|
||||
y: vector.y().into(),
|
||||
z: vector.z().into(),
|
||||
}),
|
||||
_ => Err(mlua::Error::FromLuaConversionError {
|
||||
)
|
||||
} else {
|
||||
Err(mlua::Error::FromLuaConversionError {
|
||||
from: value.type_name(),
|
||||
to: "Vec3".to_string(),
|
||||
message: None,
|
||||
}),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user