diff options
| author | mat <git@matdoes.dev> | 2024-10-26 05:29:26 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2024-10-26 05:29:26 +0000 |
| commit | 6b0fe5bf638079d535e70c3c91e78fe35a5d2a2f (patch) | |
| tree | 3b65d2984a0cffbe5acb3d44d7e3b8b145c32f95 /azalea | |
| parent | b762575db61cf775d603e11eb2bd27ae13bdc4e9 (diff) | |
| download | azalea-drasl-6b0fe5bf638079d535e70c3c91e78fe35a5d2a2f.tar.xz | |
group imports with rustfmt
Diffstat (limited to 'azalea')
| -rw-r--r-- | azalea/examples/steal.rs | 3 | ||||
| -rw-r--r-- | azalea/examples/testbot/commands/movement.rs | 3 | ||||
| -rw-r--r-- | azalea/examples/testbot/main.rs | 11 | ||||
| -rw-r--r-- | azalea/src/accept_resource_packs.rs | 3 | ||||
| -rw-r--r-- | azalea/src/auto_respawn.rs | 3 | ||||
| -rw-r--r-- | azalea/src/bot.rs | 25 | ||||
| -rw-r--r-- | azalea/src/container.rs | 2 | ||||
| -rw-r--r-- | azalea/src/lib.rs | 5 | ||||
| -rw-r--r-- | azalea/src/pathfinder/mining.rs | 3 | ||||
| -rw-r--r-- | azalea/src/pathfinder/mod.rs | 34 | ||||
| -rw-r--r-- | azalea/src/pathfinder/moves/basic.rs | 3 | ||||
| -rw-r--r-- | azalea/src/pathfinder/moves/mod.rs | 14 | ||||
| -rw-r--r-- | azalea/src/pathfinder/moves/parkour.rs | 3 | ||||
| -rw-r--r-- | azalea/src/pathfinder/world.rs | 3 | ||||
| -rw-r--r-- | azalea/src/prelude.rs | 11 | ||||
| -rw-r--r-- | azalea/src/swarm/chat.rs | 13 | ||||
| -rw-r--r-- | azalea/src/swarm/mod.rs | 3 |
17 files changed, 73 insertions, 69 deletions
diff --git a/azalea/examples/steal.rs b/azalea/examples/steal.rs index c6ab4639..b0586f19 100644 --- a/azalea/examples/steal.rs +++ b/azalea/examples/steal.rs @@ -1,10 +1,11 @@ //! Steal all the diamonds from all the nearby chests. +use std::sync::Arc; + use azalea::{prelude::*, BlockPos}; use azalea_inventory::operations::QuickMoveClick; use azalea_inventory::ItemSlot; use parking_lot::Mutex; -use std::sync::Arc; #[tokio::main] async fn main() { diff --git a/azalea/examples/testbot/commands/movement.rs b/azalea/examples/testbot/commands/movement.rs index 4957533f..3c66fefa 100644 --- a/azalea/examples/testbot/commands/movement.rs +++ b/azalea/examples/testbot/commands/movement.rs @@ -9,9 +9,8 @@ use azalea::{ }; use parking_lot::Mutex; -use crate::BotTask; - use super::{CommandSource, Ctx}; +use crate::BotTask; pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { commands.register( diff --git a/azalea/examples/testbot/main.rs b/azalea/examples/testbot/main.rs index 6795e6cf..e7d68d5e 100644 --- a/azalea/examples/testbot/main.rs +++ b/azalea/examples/testbot/main.rs @@ -14,17 +14,17 @@ mod commands; pub mod killaura; -use azalea::pathfinder::PathfinderDebugParticles; -use azalea::ClientInformation; +use std::sync::Arc; +use std::time::Duration; use azalea::brigadier::command_dispatcher::CommandDispatcher; use azalea::ecs::prelude::*; +use azalea::pathfinder::PathfinderDebugParticles; use azalea::prelude::*; use azalea::swarm::prelude::*; +use azalea::ClientInformation; use commands::{register_commands, CommandSource}; use parking_lot::Mutex; -use std::sync::Arc; -use std::time::Duration; const USERNAME: &str = "azalea"; const ADDRESS: &str = "localhost"; @@ -38,10 +38,11 @@ const PATHFINDER_DEBUG_PARTICLES: bool = false; #[tokio::main] async fn main() { { - use parking_lot::deadlock; use std::thread; use std::time::Duration; + use parking_lot::deadlock; + // Create a background thread which checks for deadlocks every 10s thread::spawn(move || loop { thread::sleep(Duration::from_secs(10)); diff --git a/azalea/src/accept_resource_packs.rs b/azalea/src/accept_resource_packs.rs index 02953d9e..c9765c77 100644 --- a/azalea/src/accept_resource_packs.rs +++ b/azalea/src/accept_resource_packs.rs @@ -1,4 +1,3 @@ -use crate::app::{App, Plugin}; use azalea_client::chunks::handle_chunk_batch_finished_event; use azalea_client::inventory::InventorySet; use azalea_client::packet_handling::game::SendPacketEvent; @@ -10,6 +9,8 @@ use azalea_protocol::packets::game::serverbound_resource_pack_packet::{ use bevy_app::Update; use bevy_ecs::prelude::*; +use crate::app::{App, Plugin}; + /// A plugin that makes it so bots automatically accept resource packs. #[derive(Clone, Default)] pub struct AcceptResourcePacksPlugin; diff --git a/azalea/src/auto_respawn.rs b/azalea/src/auto_respawn.rs index 07b3e0f5..43ec4821 100644 --- a/azalea/src/auto_respawn.rs +++ b/azalea/src/auto_respawn.rs @@ -1,4 +1,3 @@ -use crate::app::{App, Plugin}; use azalea_client::{ packet_handling::{death_event_on_0_health, game::DeathEvent}, respawn::{perform_respawn, PerformRespawnEvent}, @@ -6,6 +5,8 @@ use azalea_client::{ use bevy_app::Update; use bevy_ecs::prelude::*; +use crate::app::{App, Plugin}; + /// A plugin that makes [`DeathEvent`]s send [`PerformRespawnEvent`]s. #[derive(Clone, Default)] pub struct AutoRespawnPlugin; diff --git a/azalea/src/bot.rs b/azalea/src/bot.rs index 529bb251..eee0f880 100644 --- a/azalea/src/bot.rs +++ b/azalea/src/bot.rs @@ -1,14 +1,5 @@ -use crate::accept_resource_packs::AcceptResourcePacksPlugin; -use crate::app::{App, Plugin, PluginGroup, PluginGroupBuilder}; -use crate::auto_respawn::AutoRespawnPlugin; -use crate::container::ContainerPlugin; -use crate::ecs::{ - component::Component, - entity::Entity, - event::EventReader, - query::{With, Without}, - system::{Commands, Query}, -}; +use std::f64::consts::PI; + use azalea_client::interact::SwingArmEvent; use azalea_client::mining::Mining; use azalea_client::TickBroadcast; @@ -23,9 +14,19 @@ use bevy_app::Update; use bevy_ecs::prelude::Event; use bevy_ecs::schedule::IntoSystemConfigs; use futures_lite::Future; -use std::f64::consts::PI; use tracing::trace; +use crate::accept_resource_packs::AcceptResourcePacksPlugin; +use crate::app::{App, Plugin, PluginGroup, PluginGroupBuilder}; +use crate::auto_respawn::AutoRespawnPlugin; +use crate::container::ContainerPlugin; +use crate::ecs::{ + component::Component, + entity::Entity, + event::EventReader, + query::{With, Without}, + system::{Commands, Query}, +}; use crate::pathfinder::PathfinderPlugin; #[derive(Clone, Default)] diff --git a/azalea/src/container.rs b/azalea/src/container.rs index c9283b6b..980210ae 100644 --- a/azalea/src/container.rs +++ b/azalea/src/container.rs @@ -1,3 +1,4 @@ +use std::fmt::Debug; use std::fmt::Formatter; use azalea_client::{ @@ -11,7 +12,6 @@ use azalea_protocol::packets::game::ClientboundGamePacket; use bevy_app::{App, Plugin, Update}; use bevy_ecs::{component::Component, prelude::EventReader, system::Commands}; use futures_lite::Future; -use std::fmt::Debug; use crate::bot::BotClientExt; diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs index c78b6ef1..5e412f52 100644 --- a/azalea/src/lib.rs +++ b/azalea/src/lib.rs @@ -34,6 +34,8 @@ pub use azalea_physics as physics; pub use azalea_protocol as protocol; pub use azalea_registry as registry; pub use azalea_world as world; +pub use bevy_app as app; +pub use bevy_ecs as ecs; pub use bot::*; use ecs::component::Component; use futures::{future::BoxFuture, Future}; @@ -42,9 +44,6 @@ use protocol::{resolver::ResolverError, ServerAddress}; use swarm::SwarmBuilder; use thiserror::Error; -pub use bevy_app as app; -pub use bevy_ecs as ecs; - pub type BoxHandleFn<S> = Box<dyn Fn(Client, azalea_client::Event, S) -> BoxFuture<'static, Result<(), anyhow::Error>>>; pub type HandleFn<S, Fut> = fn(Client, azalea_client::Event, S) -> Fut; diff --git a/azalea/src/pathfinder/mining.rs b/azalea/src/pathfinder/mining.rs index 1bc08c43..31b37b49 100644 --- a/azalea/src/pathfinder/mining.rs +++ b/azalea/src/pathfinder/mining.rs @@ -4,9 +4,8 @@ use azalea_block::{BlockState, BlockStates}; use azalea_inventory::Menu; use nohash_hasher::IntMap; -use crate::auto_tool::best_tool_in_hotbar_for_block; - use super::costs::BLOCK_BREAK_ADDITIONAL_PENALTY; +use crate::auto_tool::best_tool_in_hotbar_for_block; pub struct MiningCache { block_state_id_costs: UnsafeCell<IntMap<u32, f32>>, diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index cb6ba2bb..1f864526 100644 --- a/azalea/src/pathfinder/mod.rs +++ b/azalea/src/pathfinder/mod.rs @@ -11,20 +11,11 @@ pub mod moves; pub mod simulation; pub mod world; -use crate::bot::{JumpEvent, LookAtEvent}; -use crate::pathfinder::astar::a_star; -use crate::WalkDirection; +use std::collections::VecDeque; +use std::sync::atomic::{self, AtomicUsize}; +use std::sync::Arc; +use std::time::{Duration, Instant}; -use crate::app::{App, Plugin}; -use crate::ecs::{ - component::Component, - entity::Entity, - event::{EventReader, EventWriter}, - query::{With, Without}, - system::{Commands, Query, Res}, -}; -use crate::pathfinder::moves::PathfinderCtx; -use crate::pathfinder::world::CachedWorld; use azalea_client::inventory::{Inventory, InventorySet, SetSelectedHotbarSlotEvent}; use azalea_client::mining::{Mining, StartMiningBlockEvent}; use azalea_client::movement::MoveEventsSet; @@ -42,10 +33,6 @@ use bevy_ecs::query::Changed; use bevy_ecs::schedule::IntoSystemConfigs; use bevy_tasks::{AsyncComputeTaskPool, Task}; use futures_lite::future; -use std::collections::VecDeque; -use std::sync::atomic::{self, AtomicUsize}; -use std::sync::Arc; -use std::time::{Duration, Instant}; use tracing::{debug, error, info, trace, warn}; use self::debug::debug_render_path_with_particles; @@ -53,6 +40,19 @@ pub use self::debug::PathfinderDebugParticles; use self::goals::Goal; use self::mining::MiningCache; use self::moves::{ExecuteCtx, IsReachedCtx, SuccessorsFn}; +use crate::app::{App, Plugin}; +use crate::bot::{JumpEvent, LookAtEvent}; +use crate::ecs::{ + component::Component, + entity::Entity, + event::{EventReader, EventWriter}, + query::{With, Without}, + system::{Commands, Query, Res}, +}; +use crate::pathfinder::astar::a_star; +use crate::pathfinder::moves::PathfinderCtx; +use crate::pathfinder::world::CachedWorld; +use crate::WalkDirection; #[derive(Clone, Default)] pub struct PathfinderPlugin; diff --git a/azalea/src/pathfinder/moves/basic.rs b/azalea/src/pathfinder/moves/basic.rs index 54a6dc6a..bb931caf 100644 --- a/azalea/src/pathfinder/moves/basic.rs +++ b/azalea/src/pathfinder/moves/basic.rs @@ -6,9 +6,8 @@ use azalea_core::{ position::{BlockPos, Vec3}, }; -use crate::pathfinder::{astar, costs::*}; - use super::{default_is_reached, Edge, ExecuteCtx, IsReachedCtx, MoveData, PathfinderCtx}; +use crate::pathfinder::{astar, costs::*}; pub fn basic_move(ctx: &mut PathfinderCtx, node: BlockPos) { forward_move(ctx, node); diff --git a/azalea/src/pathfinder/moves/mod.rs b/azalea/src/pathfinder/moves/mod.rs index bb10b192..28974132 100644 --- a/azalea/src/pathfinder/moves/mod.rs +++ b/azalea/src/pathfinder/moves/mod.rs @@ -3,13 +3,6 @@ pub mod parkour; use std::{fmt::Debug, sync::Arc}; -use crate::{auto_tool::best_tool_in_hotbar_for_block, JumpEvent, LookAtEvent}; - -use super::{ - astar, - mining::MiningCache, - world::{is_block_state_passable, CachedWorld}, -}; use azalea_client::{ inventory::SetSelectedHotbarSlotEvent, mining::StartMiningBlockEvent, SprintDirection, StartSprintEvent, StartWalkEvent, WalkDirection, @@ -20,6 +13,13 @@ use azalea_world::Instance; use bevy_ecs::{entity::Entity, event::EventWriter}; use parking_lot::RwLock; +use super::{ + astar, + mining::MiningCache, + world::{is_block_state_passable, CachedWorld}, +}; +use crate::{auto_tool::best_tool_in_hotbar_for_block, JumpEvent, LookAtEvent}; + type Edge = astar::Edge<BlockPos, MoveData>; pub type SuccessorsFn = fn(&mut PathfinderCtx, BlockPos); diff --git a/azalea/src/pathfinder/moves/parkour.rs b/azalea/src/pathfinder/moves/parkour.rs index 66f02197..0f279dca 100644 --- a/azalea/src/pathfinder/moves/parkour.rs +++ b/azalea/src/pathfinder/moves/parkour.rs @@ -1,9 +1,8 @@ use azalea_client::{SprintDirection, WalkDirection}; use azalea_core::{direction::CardinalDirection, position::BlockPos}; -use crate::pathfinder::{astar, costs::*}; - use super::{Edge, ExecuteCtx, IsReachedCtx, MoveData, PathfinderCtx}; +use crate::pathfinder::{astar, costs::*}; pub fn parkour_move(ctx: &mut PathfinderCtx, node: BlockPos) { parkour_forward_1_move(ctx, node); diff --git a/azalea/src/pathfinder/world.rs b/azalea/src/pathfinder/world.rs index 2d859026..3a004f65 100644 --- a/azalea/src/pathfinder/world.rs +++ b/azalea/src/pathfinder/world.rs @@ -490,9 +490,10 @@ pub fn is_block_state_solid(block: BlockState) -> bool { #[cfg(test)] mod tests { - use super::*; use azalea_world::{Chunk, ChunkStorage, PartialInstance}; + use super::*; + #[test] fn test_is_passable() { let mut partial_world = PartialInstance::default(); diff --git a/azalea/src/prelude.rs b/azalea/src/prelude.rs index b4d66aaf..d1442b10 100644 --- a/azalea/src/prelude.rs +++ b/azalea/src/prelude.rs @@ -1,12 +1,13 @@ //! The Azalea prelude. Things that are necessary for a bare-bones bot are //! re-exported here. -pub use crate::{ - bot::BotClientExt, container::ContainerClientExt, pathfinder::PathfinderClientExt, - ClientBuilder, -}; pub use azalea_client::{Account, Client, Event}; +pub use azalea_core::tick::GameTick; + // this is necessary to make the macros that reference bevy_ecs work pub use crate::ecs as bevy_ecs; pub use crate::ecs::{component::Component, system::Resource}; -pub use azalea_core::tick::GameTick; +pub use crate::{ + bot::BotClientExt, container::ContainerClientExt, pathfinder::PathfinderClientExt, + ClientBuilder, +}; diff --git a/azalea/src/swarm/chat.rs b/azalea/src/swarm/chat.rs index 7425293b..cf01c60b 100644 --- a/azalea/src/swarm/chat.rs +++ b/azalea/src/swarm/chat.rs @@ -13,18 +13,19 @@ // in Swarm that's set to the smallest index of all the bots, and we remove all // messages from the queue that are before that index. +use std::collections::VecDeque; + +use azalea_client::chat::{ChatPacket, ChatReceivedEvent}; +use bevy_app::{App, Plugin, Update}; +use bevy_ecs::prelude::Event; + +use super::{Swarm, SwarmEvent}; use crate::ecs::{ component::Component, event::{EventReader, EventWriter}, schedule::IntoSystemConfigs, system::{Commands, Query, Res, ResMut, Resource}, }; -use azalea_client::chat::{ChatPacket, ChatReceivedEvent}; -use bevy_app::{App, Plugin, Update}; -use bevy_ecs::prelude::Event; -use std::collections::VecDeque; - -use super::{Swarm, SwarmEvent}; #[derive(Clone)] pub struct SwarmChatPlugin; diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs index 451d887c..8c2d23f6 100644 --- a/azalea/src/swarm/mod.rs +++ b/azalea/src/swarm/mod.rs @@ -4,6 +4,8 @@ mod chat; mod events; pub mod prelude; +use std::{collections::HashMap, future::Future, net::SocketAddr, sync::Arc, time::Duration}; + use azalea_client::{ chat::ChatPacket, start_ecs_runner, Account, Client, DefaultPlugins, Event, JoinError, StartClientOpts, @@ -14,7 +16,6 @@ use bevy_app::{App, PluginGroup, PluginGroupBuilder, Plugins}; use bevy_ecs::{component::Component, entity::Entity, system::Resource, world::World}; use futures::future::{join_all, BoxFuture}; use parking_lot::{Mutex, RwLock}; -use std::{collections::HashMap, future::Future, net::SocketAddr, sync::Arc, time::Duration}; use tokio::sync::mpsc; use tracing::error; |
