Compare commits
3 Commits
94d1727d87
...
85e1f082a7
Author | SHA1 | Date | |
---|---|---|---|
85e1f082a7 | |||
33838e5aed | |||
7cf7254dce |
451
Cargo.lock
generated
451
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -61,8 +61,6 @@ function update_listeners()
|
||||
message = function()
|
||||
info("bot successfully logged in!")
|
||||
end,
|
||||
},
|
||||
spawn = {
|
||||
eat = function()
|
||||
sleep(5000)
|
||||
check_food()
|
||||
|
@ -33,7 +33,7 @@ impl CommandSource {
|
||||
}
|
||||
self.client.chat(
|
||||
&(if self.message.is_whisper()
|
||||
&& let Some(username) = self.message.username()
|
||||
&& let Some(username) = self.message.sender()
|
||||
{
|
||||
format!("/w {username} {chunk}")
|
||||
} else {
|
||||
@ -50,7 +50,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
|
||||
tokio::spawn(async move {
|
||||
let source = source.lock().await;
|
||||
source.reply(
|
||||
&reload(&source.state.lua, source.message.username())
|
||||
&reload(&source.state.lua, source.message.sender())
|
||||
.map_or_else(|error| error.to_string(), |()| String::from("ok")),
|
||||
);
|
||||
});
|
||||
@ -64,7 +64,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
|
||||
tokio::spawn(async move {
|
||||
let source = source.lock().await;
|
||||
source.reply(
|
||||
&eval(&source.state.lua, &code, source.message.username())
|
||||
&eval(&source.state.lua, &code, source.message.sender())
|
||||
.await
|
||||
.unwrap_or_else(|error| error.to_string()),
|
||||
);
|
||||
@ -80,7 +80,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
|
||||
tokio::spawn(async move {
|
||||
let source = source.lock().await;
|
||||
source.reply(
|
||||
&exec(&source.state.lua, &code, source.message.username())
|
||||
&exec(&source.state.lua, &code, source.message.sender())
|
||||
.await
|
||||
.map_or_else(|error| error.to_string(), |()| String::from("ok")),
|
||||
);
|
||||
|
@ -32,7 +32,7 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> Result<
|
||||
Event::Chat(message) => {
|
||||
let globals = state.lua.globals();
|
||||
let (sender, mut content) = message.split_sender_and_content();
|
||||
let uuid = message.uuid().map(|uuid| uuid.to_string());
|
||||
let uuid = message.sender_uuid().map(|uuid| uuid.to_string());
|
||||
let is_whisper = message.is_whisper();
|
||||
let text = message.message();
|
||||
let ansi_text = text.to_ansi();
|
||||
|
@ -108,7 +108,7 @@ pub async fn open_container_at(
|
||||
.map(Container))
|
||||
}
|
||||
|
||||
pub fn open_inventory(_lua: &Lua, client: &mut Client, _: ()) -> Result<Option<Container>> {
|
||||
pub fn open_inventory(_lua: &Lua, client: &Client, _: ()) -> Result<Option<Container>> {
|
||||
Ok(client.open_inventory().map(Container))
|
||||
}
|
||||
|
||||
|
@ -8,12 +8,12 @@ use mlua::{Lua, Result, UserDataRef};
|
||||
|
||||
use super::{Client, Vec3};
|
||||
|
||||
pub fn attack(_lua: &Lua, client: &mut Client, entity_id: i32) -> Result<()> {
|
||||
pub fn attack(_lua: &Lua, client: &Client, entity_id: i32) -> Result<()> {
|
||||
client.attack(MinecraftEntityId(entity_id));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn block_interact(_lua: &Lua, client: &mut Client, position: Vec3) -> Result<()> {
|
||||
pub fn block_interact(_lua: &Lua, client: &Client, position: Vec3) -> Result<()> {
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
client.block_interact(BlockPos::new(
|
||||
position.x as i32,
|
||||
@ -45,7 +45,7 @@ pub fn set_mining(_lua: &Lua, client: &Client, mining: bool) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn start_mining(_lua: &Lua, client: &mut Client, position: Vec3) -> Result<()> {
|
||||
pub fn start_mining(_lua: &Lua, client: &Client, position: Vec3) -> Result<()> {
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
client.start_mining(BlockPos::new(
|
||||
position.x as i32,
|
||||
|
@ -66,30 +66,30 @@ impl UserData for Client {
|
||||
m.add_async_method("mine", interaction::mine);
|
||||
m.add_async_method("open_container_at", container::open_container_at);
|
||||
m.add_async_method("set_client_information", state::set_client_information);
|
||||
m.add_method("attack", interaction::attack);
|
||||
m.add_method("best_tool_for_block", world::best_tool_for_block);
|
||||
m.add_method("block_interact", interaction::block_interact);
|
||||
m.add_method("chat", chat);
|
||||
m.add_method("disconnect", disconnect);
|
||||
m.add_method("find_blocks", world::find::blocks);
|
||||
m.add_method("get_block_state", world::get_block_state);
|
||||
m.add_method("get_fluid_state", world::get_fluid_state);
|
||||
m.add_method("jump", movement::jump);
|
||||
m.add_method("look_at", movement::look_at);
|
||||
m.add_method("open_inventory", container::open_inventory);
|
||||
m.add_method("set_component", state::set_component);
|
||||
m.add_method("set_direction", movement::set_direction);
|
||||
m.add_method("set_held_slot", container::set_held_slot);
|
||||
m.add_method("set_jumping", movement::set_jumping);
|
||||
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("sprint", movement::sprint);
|
||||
m.add_method("start_mining", interaction::start_mining);
|
||||
m.add_method("stop_pathfinding", movement::stop_pathfinding);
|
||||
m.add_method("stop_sleeping", movement::stop_sleeping);
|
||||
m.add_method("use_item", interaction::use_item);
|
||||
m.add_method_mut("attack", interaction::attack);
|
||||
m.add_method_mut("block_interact", interaction::block_interact);
|
||||
m.add_method_mut("jump", movement::jump);
|
||||
m.add_method_mut("look_at", movement::look_at);
|
||||
m.add_method_mut("open_inventory", container::open_inventory);
|
||||
m.add_method_mut("set_direction", movement::set_direction);
|
||||
m.add_method_mut("set_jumping", movement::set_jumping);
|
||||
m.add_method_mut("sprint", movement::sprint);
|
||||
m.add_method_mut("start_mining", interaction::start_mining);
|
||||
m.add_method_mut("walk", movement::walk);
|
||||
m.add_method("walk", movement::walk);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ pub async fn go_to(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn jump(_lua: &Lua, client: &mut Client, _: ()) -> Result<()> {
|
||||
pub fn jump(_lua: &Lua, client: &Client, _: ()) -> Result<()> {
|
||||
client.jump();
|
||||
Ok(())
|
||||
}
|
||||
@ -115,7 +115,7 @@ pub fn looking_at(lua: &Lua, client: &Client) -> Result<Option<Table>> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn look_at(_lua: &Lua, client: &mut Client, position: Vec3) -> Result<()> {
|
||||
pub fn look_at(_lua: &Lua, client: &Client, position: Vec3) -> Result<()> {
|
||||
client.look_at(azalea::Vec3::new(position.x, position.y, position.z));
|
||||
Ok(())
|
||||
}
|
||||
@ -150,12 +150,12 @@ pub fn position(_lua: &Lua, client: &Client) -> Result<Vec3> {
|
||||
Ok(Vec3::from(&client.component::<Position>()))
|
||||
}
|
||||
|
||||
pub fn set_direction(_lua: &Lua, client: &mut Client, direction: Direction) -> Result<()> {
|
||||
pub fn set_direction(_lua: &Lua, client: &Client, direction: Direction) -> Result<()> {
|
||||
client.set_direction(direction.y, direction.x);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_jumping(_lua: &Lua, client: &mut Client, jumping: bool) -> Result<()> {
|
||||
pub fn set_jumping(_lua: &Lua, client: &Client, jumping: bool) -> Result<()> {
|
||||
client.set_jumping(jumping);
|
||||
Ok(())
|
||||
}
|
||||
@ -184,7 +184,7 @@ pub fn set_sneaking(_lua: &Lua, client: &Client, sneaking: bool) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn sprint(_lua: &Lua, client: &mut Client, direction: u8) -> Result<()> {
|
||||
pub fn sprint(_lua: &Lua, client: &Client, direction: u8) -> Result<()> {
|
||||
client.sprint(match direction {
|
||||
5 => SprintDirection::ForwardRight,
|
||||
6 => SprintDirection::ForwardLeft,
|
||||
@ -209,7 +209,7 @@ pub fn stop_sleeping(_lua: &Lua, client: &Client, _: ()) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn walk(_lua: &Lua, client: &mut Client, direction: u8) -> Result<()> {
|
||||
pub fn walk(_lua: &Lua, client: &Client, direction: u8) -> Result<()> {
|
||||
client.walk(match direction {
|
||||
1 => WalkDirection::Forward,
|
||||
2 => WalkDirection::Backward,
|
||||
|
Loading…
x
Reference in New Issue
Block a user