build(deps): update azalea

This commit is contained in:
Ryan 2025-04-18 00:20:55 -04:00
parent 505b1a26af
commit d27289e620
Signed by: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3
12 changed files with 99 additions and 97 deletions

69
Cargo.lock generated
View File

@ -261,6 +261,19 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
] ]
[[package]]
name = "async-compat"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bab94bde396a3f7b4962e396fdad640e241ed797d4d8d77fc8c237d14c58fc0"
dependencies = [
"futures-core",
"futures-io",
"once_cell",
"pin-project-lite",
"tokio",
]
[[package]] [[package]]
name = "async-compression" name = "async-compression"
version = "0.4.22" version = "0.4.22"
@ -399,7 +412,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea" name = "azalea"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"azalea-auth", "azalea-auth",
"azalea-block", "azalea-block",
@ -437,7 +450,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-auth" name = "azalea-auth"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"azalea-buf", "azalea-buf",
"azalea-crypto", "azalea-crypto",
@ -457,7 +470,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-block" name = "azalea-block"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"azalea-block-macros", "azalea-block-macros",
"azalea-buf", "azalea-buf",
@ -467,7 +480,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-block-macros" name = "azalea-block-macros"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -477,7 +490,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-brigadier" name = "azalea-brigadier"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"azalea-buf", "azalea-buf",
"azalea-chat", "azalea-chat",
@ -487,7 +500,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-buf" name = "azalea-buf"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"azalea-buf-macros", "azalea-buf-macros",
"byteorder", "byteorder",
@ -501,7 +514,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-buf-macros" name = "azalea-buf-macros"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -511,7 +524,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-chat" name = "azalea-chat"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"azalea-buf", "azalea-buf",
"azalea-language", "azalea-language",
@ -525,8 +538,9 @@ dependencies = [
[[package]] [[package]]
name = "azalea-client" name = "azalea-client"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"async-compat",
"azalea-auth", "azalea-auth",
"azalea-block", "azalea-block",
"azalea-buf", "azalea-buf",
@ -560,7 +574,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-core" name = "azalea-core"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"azalea-buf", "azalea-buf",
"azalea-chat", "azalea-chat",
@ -577,7 +591,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-crypto" name = "azalea-crypto"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"aes", "aes",
"azalea-buf", "azalea-buf",
@ -594,7 +608,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-entity" name = "azalea-entity"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"azalea-block", "azalea-block",
"azalea-buf", "azalea-buf",
@ -618,7 +632,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-inventory" name = "azalea-inventory"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"azalea-buf", "azalea-buf",
"azalea-chat", "azalea-chat",
@ -634,7 +648,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-inventory-macros" name = "azalea-inventory-macros"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -644,7 +658,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-language" name = "azalea-language"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"compact_str", "compact_str",
"serde", "serde",
@ -654,7 +668,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-physics" name = "azalea-physics"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"azalea-block", "azalea-block",
"azalea-core", "azalea-core",
@ -671,7 +685,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-protocol" name = "azalea-protocol"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"async-recursion", "async-recursion",
"azalea-auth", "azalea-auth",
@ -706,7 +720,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-protocol-macros" name = "azalea-protocol-macros"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -716,7 +730,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-registry" name = "azalea-registry"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"azalea-buf", "azalea-buf",
"azalea-registry-macros", "azalea-registry-macros",
@ -727,7 +741,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-registry-macros" name = "azalea-registry-macros"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"quote", "quote",
"syn", "syn",
@ -736,7 +750,7 @@ dependencies = [
[[package]] [[package]]
name = "azalea-world" name = "azalea-world"
version = "0.12.0+mc1.21.5" version = "0.12.0+mc1.21.5"
source = "git+https://github.com/azalea-rs/azalea#6a83a6fa387170ae71fbe06791cf3afa20aac1df" source = "git+https://github.com/azalea-rs/azalea#e86087366ff2c5aeacc866a900f33aeba2bda6d0"
dependencies = [ dependencies = [
"azalea-block", "azalea-block",
"azalea-buf", "azalea-buf",
@ -2280,7 +2294,7 @@ dependencies = [
"idna", "idna",
"ipnet", "ipnet",
"once_cell", "once_cell",
"rand 0.9.0", "rand 0.9.1",
"ring", "ring",
"thiserror 2.0.12", "thiserror 2.0.12",
"tinyvec", "tinyvec",
@ -2301,7 +2315,7 @@ dependencies = [
"moka", "moka",
"once_cell", "once_cell",
"parking_lot", "parking_lot",
"rand 0.9.0", "rand 0.9.1",
"smallvec", "smallvec",
"thiserror 2.0.12", "thiserror 2.0.12",
"tokio", "tokio",
@ -3988,7 +4002,7 @@ checksum = "b820744eb4dc9b57a3398183639c511b5a26d2ed702cedd3febaa1393caa22cc"
dependencies = [ dependencies = [
"bytes", "bytes",
"getrandom 0.3.2", "getrandom 0.3.2",
"rand 0.9.0", "rand 0.9.1",
"ring", "ring",
"rustc-hash 2.1.1", "rustc-hash 2.1.1",
"rustls", "rustls",
@ -4042,13 +4056,12 @@ dependencies = [
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97"
dependencies = [ dependencies = [
"rand_chacha 0.9.0", "rand_chacha 0.9.0",
"rand_core 0.9.3", "rand_core 0.9.3",
"zerocopy 0.8.24",
] ]
[[package]] [[package]]
@ -5379,7 +5392,7 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "470dbf6591da1b39d43c14523b2b469c86879a53e8b758c8e090a470fe7b1fbe" checksum = "470dbf6591da1b39d43c14523b2b469c86879a53e8b758c8e090a470fe7b1fbe"
dependencies = [ dependencies = [
"rand 0.9.0", "rand 0.9.1",
"web-time", "web-time",
] ]

View File

@ -125,7 +125,6 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> Result<
} }
} }
Event::KeepAlive(id) => call_listeners(&state, "keep_alive", || Ok(id)).await, Event::KeepAlive(id) => call_listeners(&state, "keep_alive", || Ok(id)).await,
Event::Login => call_listeners(&state, "login", || Ok(())).await,
Event::RemovePlayer(player_info) => { Event::RemovePlayer(player_info) => {
call_listeners(&state, "remove_player", || Ok(Player::from(player_info))).await call_listeners(&state, "remove_player", || Ok(Player::from(player_info))).await
} }
@ -201,6 +200,12 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> Result<
} }
_ => Ok(()), _ => Ok(()),
}, },
Event::Login => {
#[cfg(feature = "matrix")]
matrix_init(&client, state.clone());
call_listeners(&state, "login", || Ok(())).await
}
Event::Init => { Event::Init => {
debug!("received init event"); debug!("received init event");
@ -212,9 +217,6 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> Result<
exit(0); exit(0);
})?; })?;
#[cfg(feature = "matrix")]
matrix_init(&client, state.clone());
let globals = state.lua.globals(); let globals = state.lua.globals();
lua_init(client, &state, &globals).await?; lua_init(client, &state, &globals).await?;

View File

@ -3,7 +3,7 @@
pub mod anti_knockback; pub mod anti_knockback;
use anti_knockback::anti_knockback; use anti_knockback::anti_knockback;
use azalea::{movement::handle_knockback, packet::game::process_packet_events}; use azalea::{connection::read_packets, movement::handle_knockback};
use bevy_app::{App, Plugin, PreUpdate}; use bevy_app::{App, Plugin, PreUpdate};
use bevy_ecs::schedule::IntoSystemConfigs; use bevy_ecs::schedule::IntoSystemConfigs;
@ -13,9 +13,7 @@ impl Plugin for HacksPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_systems( app.add_systems(
PreUpdate, PreUpdate,
anti_knockback anti_knockback.after(read_packets).before(handle_knockback),
.after(process_packet_events)
.before(handle_knockback),
); );
} }
} }

View File

@ -60,7 +60,7 @@ pub async fn get_block_states(
true true
}) })
{ {
matched.push(block.id); matched.push(block.id());
} }
} }
} }

View File

@ -4,7 +4,6 @@ use azalea::{
prelude::ContainerClientExt, prelude::ContainerClientExt,
protocol::packets::game::ServerboundSetCarriedItem, protocol::packets::game::ServerboundSetCarriedItem,
}; };
use log::error;
use mlua::{Lua, Result, UserDataRef, Value}; use mlua::{Lua, Result, UserDataRef, Value};
use super::{Client, Container, ContainerRef, ItemStack, Vec3}; use super::{Client, Container, ContainerRef, ItemStack, Vec3};
@ -126,11 +125,8 @@ pub fn set_held_slot(_lua: &Lua, client: &Client, slot: u8) -> Result<()> {
inventory.selected_hotbar_slot = slot; inventory.selected_hotbar_slot = slot;
}; };
if let Err(error) = client.write_packet(ServerboundSetCarriedItem { client.write_packet(ServerboundSetCarriedItem {
slot: u16::from(slot), slot: u16::from(slot),
}) { });
error!("failed to send SetCarriedItem packet: {error:?}");
}
Ok(()) Ok(())
} }

View File

@ -3,7 +3,6 @@ use azalea::{
protocol::packets::game::{ServerboundUseItem, s_interact::InteractionHand}, protocol::packets::game::{ServerboundUseItem, s_interact::InteractionHand},
world::MinecraftEntityId, world::MinecraftEntityId,
}; };
use log::error;
use mlua::{Lua, Result, UserDataRef}; use mlua::{Lua, Result, UserDataRef};
use super::{Client, Vec3}; use super::{Client, Vec3};
@ -57,7 +56,7 @@ pub fn start_mining(_lua: &Lua, client: &Client, position: Vec3) -> Result<()> {
pub fn use_item(_lua: &Lua, client: &Client, hand: Option<u8>) -> Result<()> { pub fn use_item(_lua: &Lua, client: &Client, hand: Option<u8>) -> Result<()> {
let direction = client.direction(); let direction = client.direction();
if let Err(error) = client.write_packet(ServerboundUseItem { client.write_packet(ServerboundUseItem {
hand: match hand { hand: match hand {
Some(1) => InteractionHand::OffHand, Some(1) => InteractionHand::OffHand,
_ => InteractionHand::MainHand, _ => InteractionHand::MainHand,
@ -65,8 +64,6 @@ pub fn use_item(_lua: &Lua, client: &Client, hand: Option<u8>) -> Result<()> {
sequence: 0, sequence: 0,
yaw: direction.0, yaw: direction.0,
pitch: direction.1, pitch: direction.1,
}) { });
error!("failed to send UseItem packet: {error:?}");
}
Ok(()) Ok(())
} }

View File

@ -9,7 +9,6 @@ use azalea::{
protocol::packets::game::{ServerboundPlayerCommand, s_player_command::Action}, protocol::packets::game::{ServerboundPlayerCommand, s_player_command::Action},
world::MinecraftEntityId, world::MinecraftEntityId,
}; };
use log::error;
use mlua::{FromLua, Lua, Result, Table, UserDataRef, Value}; use mlua::{FromLua, Lua, Result, Table, UserDataRef, Value};
use super::{Client, Direction, Vec3}; use super::{Client, Direction, Vec3};
@ -215,7 +214,7 @@ pub fn set_position(_lua: &Lua, client: &Client, new_position: Vec3) -> Result<(
} }
pub fn set_sneaking(_lua: &Lua, client: &Client, sneaking: bool) -> Result<()> { pub fn set_sneaking(_lua: &Lua, client: &Client, sneaking: bool) -> Result<()> {
if let Err(error) = client.write_packet(ServerboundPlayerCommand { client.write_packet(ServerboundPlayerCommand {
id: client.component::<MinecraftEntityId>(), id: client.component::<MinecraftEntityId>(),
action: if sneaking { action: if sneaking {
Action::PressShiftKey Action::PressShiftKey
@ -223,9 +222,7 @@ pub fn set_sneaking(_lua: &Lua, client: &Client, sneaking: bool) -> Result<()> {
Action::ReleaseShiftKey Action::ReleaseShiftKey
}, },
data: 0, data: 0,
}) { });
error!("failed to send PlayerCommand packet: {error:?}");
}
Ok(()) Ok(())
} }
@ -244,13 +241,11 @@ pub fn stop_pathfinding(_lua: &Lua, client: &Client, (): ()) -> Result<()> {
} }
pub fn stop_sleeping(_lua: &Lua, client: &Client, (): ()) -> Result<()> { pub fn stop_sleeping(_lua: &Lua, client: &Client, (): ()) -> Result<()> {
if let Err(error) = client.write_packet(ServerboundPlayerCommand { client.write_packet(ServerboundPlayerCommand {
id: client.component::<MinecraftEntityId>(), id: client.component::<MinecraftEntityId>(),
action: Action::StopSleeping, action: Action::StopSleeping,
data: 0, data: 0,
}) { });
error!("failed to send PlayerCommand packet: {error:?}");
}
Ok(()) Ok(())
} }

View File

@ -40,21 +40,22 @@ pub async fn set_client_information(
allows_listing: info.get("allows_listing")?, allows_listing: info.get("allows_listing")?,
model_customization: info model_customization: info
.get::<Table>("model_customization") .get::<Table>("model_customization")
.as_ref()
.map(|t| ModelCustomization { .map(|t| ModelCustomization {
cape: get_bool(&t, "cape"), cape: get_bool(t, "cape"),
jacket: get_bool(&t, "jacket"), jacket: get_bool(t, "jacket"),
left_sleeve: get_bool(&t, "left_sleeve"), left_sleeve: get_bool(t, "left_sleeve"),
right_sleeve: get_bool(&t, "right_sleeve"), right_sleeve: get_bool(t, "right_sleeve"),
left_pants: get_bool(&t, "left_pants"), left_pants: get_bool(t, "left_pants"),
right_pants: get_bool(&t, "right_pants"), right_pants: get_bool(t, "right_pants"),
hat: get_bool(&t, "hat"), hat: get_bool(t, "hat"),
}) })
.unwrap_or_default(), .unwrap_or_default(),
view_distance: info.get("view_distance").unwrap_or(8), view_distance: info.get("view_distance").unwrap_or(8),
..ClientInformation::default() ..ClientInformation::default()
}) })
.await .await;
.map_err(Error::external) Ok(())
} }
pub fn set_component( pub fn set_component(

View File

@ -28,7 +28,10 @@ pub fn blocks(
nearest_to.z as i32, nearest_to.z as i32,
), ),
&BlockStates { &BlockStates {
set: block_states.iter().map(|&id| BlockState { id }).collect(), set: block_states
.into_iter()
.flat_map(BlockState::try_from)
.collect(),
}, },
) )
.map(Vec3::from) .map(Vec3::from)

View File

@ -3,16 +3,19 @@ mod queries;
pub mod find; pub mod find;
use azalea::{BlockPos, auto_tool::AutoToolClientExt, blocks::BlockState, world::InstanceName}; use azalea::{BlockPos, auto_tool::AutoToolClientExt, blocks::BlockState, world::InstanceName};
use mlua::{Lua, Result, Table}; use mlua::{Lua, Result, Table, Value};
use super::{Client, Direction, Vec3}; use super::{Client, Direction, Vec3};
pub fn best_tool_for_block(lua: &Lua, client: &Client, block_state: u16) -> Result<Table> { pub fn best_tool_for_block(lua: &Lua, client: &Client, block_state: u16) -> Result<Value> {
let result = client.best_tool_in_hotbar_for_block(BlockState { id: block_state }); let Ok(block) = BlockState::try_from(block_state) else {
return Ok(Value::Nil);
};
let result = client.best_tool_in_hotbar_for_block(block);
let table = lua.create_table()?; let table = lua.create_table()?;
table.set("index", result.index)?; table.set("index", result.index)?;
table.set("percentage_per_tick", result.percentage_per_tick)?; table.set("percentage_per_tick", result.percentage_per_tick)?;
Ok(table) Ok(Value::Table(table))
} }
pub fn dimension(_lua: &Lua, client: &Client) -> Result<String> { pub fn dimension(_lua: &Lua, client: &Client) -> Result<String> {
@ -29,7 +32,7 @@ pub fn get_block_state(_lua: &Lua, client: &Client, position: Vec3) -> Result<Op
position.y as i32, position.y as i32,
position.z as i32, position.z as i32,
)) ))
.map(|block| block.id)) .map(|block| block.id()))
} }
#[allow(clippy::cast_possible_truncation)] #[allow(clippy::cast_possible_truncation)]

View File

@ -22,7 +22,7 @@ use std::{
sync::Arc, sync::Arc,
}; };
use anyhow::Context; use anyhow::{Context, Result};
use arguments::Arguments; use arguments::Arguments;
use azalea::{ use azalea::{
DefaultBotPlugins, DefaultPlugins, brigadier::prelude::CommandDispatcher, prelude::*, DefaultBotPlugins, DefaultPlugins, brigadier::prelude::CommandDispatcher, prelude::*,
@ -55,7 +55,7 @@ struct State {
} }
#[tokio::main] #[tokio::main]
async fn main() -> anyhow::Result<()> { async fn main() -> Result<()> {
#[cfg(feature = "console-subscriber")] #[cfg(feature = "console-subscriber")]
console_subscriber::init(); console_subscriber::init();
@ -131,8 +131,7 @@ async fn main() -> anyhow::Result<()> {
} else { } else {
Account::offline(&username) Account::offline(&username)
}; };
let Err(err) = ClientBuilder::new_without_plugins()
let Err(error) = ClientBuilder::new_without_plugins()
.add_plugins(DefaultBotPlugins) .add_plugins(DefaultBotPlugins)
.add_plugins(HacksPlugin) .add_plugins(HacksPlugin)
.add_plugins(default_plugins) .add_plugins(default_plugins)
@ -145,7 +144,7 @@ async fn main() -> anyhow::Result<()> {
}) })
.start(account, server) .start(account, server)
.await; .await;
eprintln!("{error}"); eprintln!("{err}");
Ok(()) Ok(())
} }

View File

@ -3,17 +3,15 @@
use std::sync::Arc; use std::sync::Arc;
use azalea::{ use azalea::{
ecs::{event::EventReader, system::Query}, ecs::event::EventReader,
packet::{ packet::{
config::ReceiveConfigPacketEvent, config::ReceiveConfigPacketEvent, game::ReceiveGamePacketEvent,
game::emit_receive_packet_events, login::ReceiveLoginPacketEvent,
login::{LoginPacketEvent, process_packet_events},
}, },
protocol::packets::login::ClientboundLoginPacket, protocol::packets::login::ClientboundLoginPacket,
raw_connection::RawConnection,
}; };
use bevy_app::{App, First, Plugin}; use bevy_app::{App, First, Plugin};
use bevy_ecs::{schedule::IntoSystemConfigs, system::ResMut}; use bevy_ecs::system::ResMut;
use log::error; use log::error;
use parking_lot::Mutex; use parking_lot::Mutex;
@ -28,19 +26,16 @@ impl Plugin for RecordPlugin {
let recorder = self.recorder.lock().take(); let recorder = self.recorder.lock().take();
if let Some(recorder) = recorder { if let Some(recorder) = recorder {
app.insert_resource(recorder) app.insert_resource(recorder)
.add_systems(First, record_login_packets.before(process_packet_events)) .add_systems(First, record_login_packets)
.add_systems(First, record_configuration_packets) .add_systems(First, record_configuration_packets)
.add_systems( .add_systems(First, record_game_packets);
First,
record_game_packets.before(emit_receive_packet_events),
);
} }
} }
} }
fn record_login_packets( fn record_login_packets(
recorder: Option<ResMut<Recorder>>, recorder: Option<ResMut<Recorder>>,
mut events: EventReader<LoginPacketEvent>, mut events: EventReader<ReceiveLoginPacketEvent>,
) { ) {
if let Some(mut recorder) = recorder { if let Some(mut recorder) = recorder {
for event in events.read() { for event in events.read() {
@ -63,20 +58,20 @@ fn record_configuration_packets(
) { ) {
if let Some(mut recorder) = recorder { if let Some(mut recorder) = recorder {
for event in events.read() { for event in events.read() {
if let Err(error) = recorder.save_packet(&event.packet) { if let Err(error) = recorder.save_packet(event.packet.as_ref()) {
error!("failed to record configuration packet: {error:?}"); error!("failed to record configuration packet: {error:?}");
} }
} }
} }
} }
fn record_game_packets(recorder: Option<ResMut<Recorder>>, query: Query<&RawConnection>) { fn record_game_packets(
if let Some(mut recorder) = recorder recorder: Option<ResMut<Recorder>>,
&& let Ok(raw_conn) = query.get_single() mut events: EventReader<ReceiveGamePacketEvent>,
{ ) {
let queue = raw_conn.incoming_packet_queue(); if let Some(mut recorder) = recorder {
for raw_packet in queue.lock().iter() { for event in events.read() {
if let Err(error) = recorder.save_raw_packet(raw_packet) { if let Err(error) = recorder.save_packet(event.packet.as_ref()) {
error!("failed to record game packet: {error:?}"); error!("failed to record game packet: {error:?}");
} }
} }