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