diff --git a/src/lua/client/container.rs b/src/lua/client/container.rs index 2d63a59..6f3834b 100644 --- a/src/lua/client/container.rs +++ b/src/lua/client/container.rs @@ -6,7 +6,7 @@ use azalea::{ protocol::packets::game::ServerboundSetCarriedItem, }; use log::error; -use mlua::{Lua, Result, Table, UserDataRef}; +use mlua::{Lua, Result, UserDataRef, Value}; pub fn container(_lua: &Lua, client: &Client) -> Result> { Ok(client.get_open_container().map(ContainerRef)) @@ -21,7 +21,7 @@ pub fn held_slot(_lua: &Lua, client: &Client) -> Result { } #[allow(clippy::too_many_lines)] -pub fn menu(lua: &Lua, client: &Client) -> Result { +pub fn menu(lua: &Lua, client: &Client) -> Result { fn from_slot_list(s: SlotList) -> Vec { s.iter() .map(|i| ItemStack(i.to_owned())) @@ -84,9 +84,9 @@ pub fn menu(lua: &Lua, client: &Client) -> Result
{ table.set("contents", from_slot_list(contents))?; table.set("player", from_slot_list(player))?; } - _ => (), + _ => return Ok(Value::Nil), } - Ok(table) + Ok(Value::Table(table)) } pub async fn open_container_at( diff --git a/src/lua/client/interaction.rs b/src/lua/client/interaction.rs index c5b65e3..a40a095 100644 --- a/src/lua/client/interaction.rs +++ b/src/lua/client/interaction.rs @@ -55,15 +55,15 @@ pub fn start_mining(_lua: &Lua, client: &mut Client, position: Vec3) -> Result<( } pub fn use_item(_lua: &Lua, client: &Client, hand: Option) -> Result<()> { - let d = client.direction(); + let direction = client.direction(); if let Err(error) = client.write_packet(ServerboundUseItem { hand: match hand { Some(1) => InteractionHand::OffHand, _ => InteractionHand::MainHand, }, sequence: 0, - yaw: d.0, - pitch: d.1, + yaw: direction.0, + pitch: direction.1, }) { error!("failed to send UseItem packet: {error:?}"); } diff --git a/src/lua/client/movement.rs b/src/lua/client/movement.rs index 965053c..8d934b9 100644 --- a/src/lua/client/movement.rs +++ b/src/lua/client/movement.rs @@ -14,8 +14,11 @@ use log::error; use mlua::{FromLua, Lua, Result, Table, UserDataRef, Value}; pub fn direction(_lua: &Lua, client: &Client) -> Result { - let d = client.direction(); - Ok(Direction { y: d.0, x: d.1 }) + let direction = client.direction(); + Ok(Direction { + y: direction.0, + x: direction.1, + }) } pub fn eye_position(_lua: &Lua, client: &Client) -> Result { diff --git a/src/lua/client/state.rs b/src/lua/client/state.rs index 8dc4aa1..fb69672 100644 --- a/src/lua/client/state.rs +++ b/src/lua/client/state.rs @@ -19,7 +19,6 @@ pub fn health(_lua: &Lua, client: &Client) -> Result { pub fn hunger(lua: &Lua, client: &Client) -> Result
{ let hunger = client.hunger(); - let table = lua.create_table()?; table.set("food", hunger.food)?; table.set("saturation", hunger.saturation)?; diff --git a/src/main.rs b/src/main.rs index a871821..98501c2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -114,9 +114,9 @@ async fn main() -> anyhow::Result<()> { )), }; let Err(error) = ClientBuilder::new_without_plugins() + .add_plugins(DefaultBotPlugins) .add_plugins(default_plugins) .add_plugins(record_plugin) - .add_plugins(DefaultBotPlugins) .set_handler(events::handle_event) .set_state(State { lua: Arc::new(lua),