feat(client): add set_position method
This commit is contained in:
parent
aaad1fe78a
commit
3236c4c32e
@ -72,6 +72,7 @@ impl UserData for Client {
|
||||
m.add_method("get_fluid_state", world::get_fluid_state);
|
||||
m.add_method("set_held_slot", container::set_held_slot);
|
||||
m.add_method("set_mining", interaction::set_mining);
|
||||
m.add_method("set_position", movement::set_position);
|
||||
m.add_method("set_sneaking", movement::set_sneaking);
|
||||
m.add_method("stop_pathfinding", movement::stop_pathfinding);
|
||||
m.add_method("stop_sleeping", movement::stop_sleeping);
|
||||
|
@ -185,6 +185,15 @@ pub fn set_jumping(_lua: &Lua, client: &mut Client, jumping: bool) -> Result<()>
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_position(_lua: &Lua, client: &Client, new_position: Vec3) -> Result<()> {
|
||||
let mut ecs = client.ecs.lock();
|
||||
let mut position = client.query::<&mut Position>(&mut ecs);
|
||||
position.x = new_position.x;
|
||||
position.y = new_position.y;
|
||||
position.z = new_position.z;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_sneaking(_lua: &Lua, client: &Client, sneaking: bool) -> Result<()> {
|
||||
if let Err(error) = client.write_packet(ServerboundPlayerCommand {
|
||||
id: client.component::<MinecraftEntityId>(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user