Compare commits

..

No commits in common. "update" and "main" have entirely different histories.
update ... main

12 changed files with 97 additions and 99 deletions

69
Cargo.lock generated
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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