diff options
| -rw-r--r-- | CHANGELOG.md | 5 | ||||
| -rw-r--r-- | azalea-client/src/client.rs | 4 | ||||
| -rw-r--r-- | azalea-client/src/ping.rs | 7 | ||||
| -rw-r--r-- | azalea-client/src/plugins/inventory.rs | 2 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/config/mod.rs | 3 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/game/mod.rs | 3 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/login/mod.rs | 4 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/mod.rs | 6 | ||||
| -rw-r--r-- | azalea/examples/nearest_entity.rs | 6 | ||||
| -rw-r--r-- | azalea/src/auto_tool.rs | 2 | ||||
| -rw-r--r-- | azalea/src/lib.rs | 7 | ||||
| -rw-r--r-- | azalea/src/pathfinder/goals.rs | 2 | ||||
| -rw-r--r-- | azalea/src/pathfinder/mod.rs | 7 | ||||
| -rw-r--r-- | azalea/src/pathfinder/moves/mod.rs | 5 | ||||
| -rw-r--r-- | azalea/src/pathfinder/simulation.rs | 2 | ||||
| -rw-r--r-- | azalea/src/swarm/mod.rs | 2 |
16 files changed, 40 insertions, 27 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 10948e27..0b7ce01e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ is breaking anyways, semantic versioning is not followed. - `ClientBuilder::start` and `SwarmBuilder::start` now return a `Result<AppExit>` instead of `Result<!>`. - `ClientsideCloseContainerEvent`, `MenuOpenedEvent`, and `CloseContainerEvent` are now triggers instead of events. - `Client::chat` now takes anything with `impl Into<String>`. +- Some types related Azalea's bot plugin were moved to `azalea::bot::*`. ### Fixed @@ -53,11 +54,11 @@ is breaking anyways, semantic versioning is not followed. - Inventories now use the correct max stack sizes. - Clients now send the correct data component checksums when interacting with items. - Fix parsing some metadata fields of Display entities. -- Mining blocks in creative mode now works. (@qwqawawow) +- Mining blocks in creative mode now works. (@eihqnh) - Improved matchers on the `ChatPacket` functions to work on more servers. (@ShayBox) - Bevy's `AppExit` Event is now handled by Azalea's ECS runner. - Pathfinding now works over farmland blocks. -- Refreshing the account token no longer results in a panic. +- There is no longer a panic when the account token is automatically refreshed. - Fix `is_valid_id` on registries incorrectly returning true for values equal to the length. - Fix outdated implementation for the `ClientboundMerchantOffers` packet. - Fix compilation with new dependency versions. (@ShayBox) diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 98d8a3d3..2ec25dcc 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -64,13 +64,13 @@ use crate::{ player::{GameProfileComponent, PlayerInfo, retroactively_add_game_profile_component}, }; -/// `Client` has the things that a user interacting with the library will want. +/// A Minecraft client instance that can interact with the world. /// /// To make a new client, use either [`azalea::ClientBuilder`] or /// [`Client::join`]. /// /// Note that `Client` is inaccessible from systems (i.e. plugins), but you can -/// achieve everything that client can do with events. +/// achieve everything that client can do with ECS events. /// /// [`azalea::ClientBuilder`]: https://docs.rs/azalea/latest/azalea/struct.ClientBuilder.html #[derive(Clone)] diff --git a/azalea-client/src/ping.rs b/azalea-client/src/ping.rs index 38d5c26f..8c4e2240 100644 --- a/azalea-client/src/ping.rs +++ b/azalea-client/src/ping.rs @@ -67,9 +67,10 @@ pub async fn ping_server_with_proxy( ping_server_with_connection(address, conn).await } -/// Ping a Minecraft server after we've already created a [`Connection`]. The -/// `Connection` must still be in the handshake state (which is the state it's -/// in immediately after it's created). +/// Ping a Minecraft server after we've already created a [`Connection`]. +/// +/// The `Connection` must still be in the handshake state (which is the state +/// it's in immediately after it's created). pub async fn ping_server_with_connection( address: ServerAddress, mut conn: Connection<ClientboundHandshakePacket, ServerboundHandshakePacket>, diff --git a/azalea-client/src/plugins/inventory.rs b/azalea-client/src/plugins/inventory.rs index e6481577..968a805b 100644 --- a/azalea-client/src/plugins/inventory.rs +++ b/azalea-client/src/plugins/inventory.rs @@ -734,7 +734,7 @@ impl Default for Inventory { /// chest or crafting table). /// /// To watch for the menu being closed, you could use -/// [`ClientSideCloseContainerEvent`]. To close it manually, use +/// [`ClientsideCloseContainerEvent`]. To close it manually, use /// [`CloseContainerEvent`]. #[derive(Event, Debug, Clone)] pub struct MenuOpenedEvent { diff --git a/azalea-client/src/plugins/packet/config/mod.rs b/azalea-client/src/plugins/packet/config/mod.rs index 3116e245..416019e8 100644 --- a/azalea-client/src/plugins/packet/config/mod.rs +++ b/azalea-client/src/plugins/packet/config/mod.rs @@ -11,11 +11,10 @@ use bevy_ecs::prelude::*; pub use events::*; use tracing::{debug, warn}; -use super::as_system; +use super::{as_system, declare_packet_handlers}; use crate::{ client::InConfigState, connection::RawConnection, - declare_packet_handlers, disconnect::DisconnectEvent, local_player::InstanceHolder, packet::game::{KeepAliveEvent, ResourcePackEvent}, diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs index bc1d1752..fc8f34cf 100644 --- a/azalea-client/src/plugins/packet/game/mod.rs +++ b/azalea-client/src/plugins/packet/game/mod.rs @@ -27,7 +27,6 @@ use crate::{ chat::{ChatPacket, ChatReceivedEvent}, chunks, connection::RawConnection, - declare_packet_handlers, disconnect::DisconnectEvent, interact::BlockStatePredictionHandler, inventory::{ @@ -35,7 +34,7 @@ use crate::{ }, local_player::{Hunger, InstanceHolder, LocalGameMode, TabList}, movement::{KnockbackEvent, KnockbackType}, - packet::as_system, + packet::{as_system, declare_packet_handlers}, player::{GameProfileComponent, PlayerInfo}, tick_counter::TicksConnected, }; diff --git a/azalea-client/src/plugins/packet/login/mod.rs b/azalea-client/src/plugins/packet/login/mod.rs index 99ebae9b..03e87920 100644 --- a/azalea-client/src/plugins/packet/login/mod.rs +++ b/azalea-client/src/plugins/packet/login/mod.rs @@ -17,8 +17,8 @@ use tracing::{debug, error}; use super::as_system; use crate::{ - Account, InConfigState, connection::RawConnection, declare_packet_handlers, - disconnect::DisconnectEvent, player::GameProfileComponent, + Account, InConfigState, connection::RawConnection, disconnect::DisconnectEvent, + packet::declare_packet_handlers, player::GameProfileComponent, }; pub fn process_packet(ecs: &mut World, player: Entity, packet: &ClientboundLoginPacket) { diff --git a/azalea-client/src/plugins/packet/mod.rs b/azalea-client/src/plugins/packet/mod.rs index c8eff7d6..2602e878 100644 --- a/azalea-client/src/plugins/packet/mod.rs +++ b/azalea-client/src/plugins/packet/mod.rs @@ -65,8 +65,8 @@ impl Plugin for PacketPlugin { } } -#[macro_export] -macro_rules! declare_packet_handlers { +#[doc(hidden)] +macro_rules! __declare_packet_handlers { ( $packetenum:ident, $packetvar:expr, @@ -83,6 +83,8 @@ macro_rules! declare_packet_handlers { }; } +pub(crate) use __declare_packet_handlers as declare_packet_handlers; + pub(crate) fn as_system<T>(ecs: &mut World, f: impl FnOnce(T::Item<'_, '_>)) where T: SystemParam + 'static, diff --git a/azalea/examples/nearest_entity.rs b/azalea/examples/nearest_entity.rs index e859751e..80bb544d 100644 --- a/azalea/examples/nearest_entity.rs +++ b/azalea/examples/nearest_entity.rs @@ -1,4 +1,8 @@ -use azalea::{Bot, ClientBuilder, LookAtEvent, nearest_entity::EntityFinder}; +use azalea::{ + ClientBuilder, + bot::{Bot, LookAtEvent}, + nearest_entity::EntityFinder, +}; use azalea_client::Account; use azalea_core::tick::GameTick; use azalea_entity::{ diff --git a/azalea/src/auto_tool.rs b/azalea/src/auto_tool.rs index 0182e200..3d8d6e36 100644 --- a/azalea/src/auto_tool.rs +++ b/azalea/src/auto_tool.rs @@ -4,7 +4,7 @@ use azalea_core::position::BlockPos; use azalea_entity::{FluidOnEyes, Physics}; use azalea_inventory::{ItemStack, Menu, components}; -use crate::BotClientExt; +use crate::bot::BotClientExt; #[derive(Debug)] pub struct BestToolResult { diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs index 7b4ec5ae..ae49c649 100644 --- a/azalea/src/lib.rs +++ b/azalea/src/lib.rs @@ -4,7 +4,7 @@ pub mod accept_resource_packs; pub mod auto_respawn; pub mod auto_tool; -mod bot; +pub mod bot; pub mod container; pub mod nearest_entity; pub mod pathfinder; @@ -34,13 +34,14 @@ pub use azalea_world as world; pub use bevy_app as app; use bevy_app::AppExit; pub use bevy_ecs as ecs; -pub use bot::*; use ecs::component::Component; use futures::{Future, future::BoxFuture}; use protocol::{ServerAddress, connect::Proxy, resolver::ResolverError}; use swarm::SwarmBuilder; use thiserror::Error; +use crate::bot::DefaultBotPlugins; + pub type BoxHandleFn<S, R> = Box<dyn Fn(Client, azalea_client::Event, S) -> BoxFuture<'static, R> + Send>; pub type HandleFn<S, Fut> = fn(Client, azalea_client::Event, S) -> Fut; @@ -111,7 +112,7 @@ impl ClientBuilder<NoState, ()> { /// .build() /// .disable::<azalea::chat_signing::ChatSigningPlugin>(), /// ) - /// .add_plugins(azalea::DefaultBotPlugins); + /// .add_plugins(azalea::bot::DefaultBotPlugins); /// # client_builder.set_handler(handle); /// # #[derive(Component, Clone, Default)] /// # pub struct State; diff --git a/azalea/src/pathfinder/goals.rs b/azalea/src/pathfinder/goals.rs index 7a830973..18ab50c1 100644 --- a/azalea/src/pathfinder/goals.rs +++ b/azalea/src/pathfinder/goals.rs @@ -236,7 +236,7 @@ impl Goal for ReachBlockPosGoal { } let eye_position = n.center_bottom().up(1.62); - let look_direction = crate::direction_looking_at(eye_position, self.pos.center()); + let look_direction = crate::bot::direction_looking_at(eye_position, self.pos.center()); let block_hit_result = azalea_client::interact::pick::pick_block( look_direction, eye_position, diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index 736309a2..6fbf0de4 100644 --- a/azalea/src/pathfinder/mod.rs +++ b/azalea/src/pathfinder/mod.rs @@ -1,5 +1,8 @@ //! A pathfinding plugin to make bots able to traverse the world. //! +//! For the new functions on `Client` that the pathfinder adds, see +//! [`PathfinderClientExt`]. +//! //! Much of this code is based on [Baritone](https://github.com/cabaletta/baritone). pub mod astar; @@ -59,9 +62,9 @@ use self::{ moves::{ExecuteCtx, IsReachedCtx, SuccessorsFn}, }; use crate::{ - BotClientExt, WalkDirection, + WalkDirection, app::{App, Plugin}, - bot::{JumpEvent, LookAtEvent}, + bot::{BotClientExt, JumpEvent, LookAtEvent}, ecs::{ component::Component, entity::Entity, diff --git a/azalea/src/pathfinder/moves/mod.rs b/azalea/src/pathfinder/moves/mod.rs index 6d1c7c55..3111516d 100644 --- a/azalea/src/pathfinder/moves/mod.rs +++ b/azalea/src/pathfinder/moves/mod.rs @@ -24,7 +24,10 @@ use super::{ rel_block_pos::RelBlockPos, world::{CachedWorld, is_block_state_passable}, }; -use crate::{JumpEvent, LookAtEvent, auto_tool::best_tool_in_hotbar_for_block}; +use crate::{ + auto_tool::best_tool_in_hotbar_for_block, + bot::{JumpEvent, LookAtEvent}, +}; type Edge = astar::Edge<RelBlockPos, MoveData>; diff --git a/azalea/src/pathfinder/simulation.rs b/azalea/src/pathfinder/simulation.rs index 89a8b3c4..78de1642 100644 --- a/azalea/src/pathfinder/simulation.rs +++ b/azalea/src/pathfinder/simulation.rs @@ -63,7 +63,7 @@ fn create_simulation_instance(chunks: ChunkStorage) -> (App, Arc<RwLock<Instance azalea_entity::EntityPlugin, azalea_client::movement::MovementPlugin, super::PathfinderPlugin, - crate::BotPlugin, + crate::bot::BotPlugin, azalea_client::task_pool::TaskPoolPlugin::default(), // for mining azalea_client::inventory::InventoryPlugin, diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs index 25f11f1e..f2e65715 100644 --- a/azalea/src/swarm/mod.rs +++ b/azalea/src/swarm/mod.rs @@ -126,7 +126,7 @@ impl SwarmBuilder<NoState, NoSwarmState, (), ()> { /// /// let swarm_builder = SwarmBuilder::new_without_plugins() /// .add_plugins(azalea::DefaultPlugins.build().disable::<azalea::chat_signing::ChatSigningPlugin>()) - /// .add_plugins(azalea::DefaultBotPlugins) + /// .add_plugins(azalea::bot::DefaultBotPlugins) /// .add_plugins(azalea::swarm::DefaultSwarmPlugins); /// # swarm_builder.set_handler(handle).set_swarm_handler(swarm_handle); /// # #[derive(Component, Resource, Clone, Default)] |
