refactor(client): make more methods async

This commit is contained in:
2025-02-18 21:34:57 -05:00
parent 75d4a9c183
commit 324cb2d6d8
3 changed files with 34 additions and 8 deletions

View File

@@ -1,9 +1,21 @@
use super::{Client, Vec3};
use azalea::{BlockPos, BotClientExt, world::MinecraftEntityId};
use azalea::{BlockPos, BotClientExt, attack::AttackEvent, world::MinecraftEntityId};
use mlua::{Lua, Result, UserDataRef};
pub fn attack(_lua: &Lua, client: &mut Client, entity_id: u32) -> Result<()> {
client.attack(MinecraftEntityId(entity_id));
pub async fn attack(_lua: Lua, client: UserDataRef<Client>, entity_id: u32) -> Result<()> {
client.clone().attack(MinecraftEntityId(entity_id));
while client.get_tick_broadcaster().recv().await.is_ok() {
if client
.ecs
.lock()
.get::<AttackEvent>(client.entity)
.is_none()
{
break;
}
}
Ok(())
}