1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

formatting: merge imports

This commit is contained in:
mat 2025-05-30 14:44:48 -13:00
parent ae4b1e85e6
commit e37524899e
27 changed files with 222 additions and 190 deletions

View file

@ -1,13 +1,17 @@
//! Cache auth information
use std::io;
use std::path::Path;
use std::time::{SystemTime, UNIX_EPOCH};
use std::{
io,
path::Path,
time::{SystemTime, UNIX_EPOCH},
};
use serde::{Deserialize, Serialize};
use thiserror::Error;
use tokio::fs::{self, File};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::{
fs::{self, File},
io::{AsyncReadExt, AsyncWriteExt},
};
use tracing::{debug, trace};
#[derive(Debug, Error)]

View file

@ -2,8 +2,7 @@
mod utils;
use std::collections::HashMap;
use std::fmt::Write;
use std::{collections::HashMap, fmt::Write};
use proc_macro::TokenStream;
use proc_macro2::TokenTree;

View file

@ -2,8 +2,10 @@
use std::sync::Arc;
use azalea_auth::AccessTokenResponse;
use azalea_auth::certs::{Certificates, FetchCertificatesError};
use azalea_auth::{
AccessTokenResponse,
certs::{Certificates, FetchCertificatesError},
};
use bevy_ecs::component::Component;
use parking_lot::Mutex;
use thiserror::Error;

View file

@ -3,8 +3,7 @@ use std::{any, sync::Arc};
use bevy_ecs::{
component::Component,
entity::Entity,
query::QueryData,
query::{QueryFilter, ROQueryItem},
query::{QueryData, QueryFilter, ROQueryItem},
world::World,
};
use parking_lot::Mutex;

View file

@ -1,15 +1,15 @@
use std::backtrace::Backtrace;
use std::io;
use std::{backtrace::Backtrace, io};
use azalea_core::position::Vec3;
use azalea_core::tick::GameTick;
use azalea_entity::{Attributes, Jumping, metadata::Sprinting};
use azalea_entity::{InLoadedChunk, LastSentPosition, LookDirection, Physics, Position};
use azalea_core::{position::Vec3, tick::GameTick};
use azalea_entity::{
Attributes, InLoadedChunk, Jumping, LastSentPosition, LookDirection, Physics, Position,
metadata::Sprinting,
};
use azalea_physics::{PhysicsSet, ai_step};
use azalea_protocol::packets::game::{ServerboundPlayerCommand, ServerboundPlayerInput};
use azalea_protocol::packets::{
Packet,
game::{
ServerboundPlayerCommand, ServerboundPlayerInput,
s_move_player_pos::ServerboundMovePlayerPos,
s_move_player_pos_rot::ServerboundMovePlayerPosRot,
s_move_player_rot::ServerboundMovePlayerRot,
@ -21,8 +21,7 @@ use bevy_app::{App, Plugin, Update};
use bevy_ecs::prelude::*;
use thiserror::Error;
use crate::client::Client;
use crate::packet::game::SendPacketEvent;
use crate::{client::Client, packet::game::SendPacketEvent};
#[derive(Error, Debug)]
pub enum MovePlayerError {

View file

@ -3,21 +3,23 @@ mod events;
use std::io::Cursor;
use azalea_entity::LocalEntity;
use azalea_protocol::packets::ConnectionProtocol;
use azalea_protocol::packets::config::*;
use azalea_protocol::read::ReadPacketError;
use azalea_protocol::read::deserialize_packet;
use azalea_protocol::{
packets::{ConnectionProtocol, config::*},
read::{ReadPacketError, deserialize_packet},
};
use bevy_ecs::prelude::*;
pub use events::*;
use tracing::{debug, warn};
use super::as_system;
use crate::client::InConfigState;
use crate::connection::RawConnection;
use crate::disconnect::DisconnectEvent;
use crate::packet::game::KeepAliveEvent;
use crate::packet::game::ResourcePackEvent;
use crate::{InstanceHolder, declare_packet_handlers};
use crate::{
InstanceHolder,
client::InConfigState,
connection::RawConnection,
declare_packet_handlers,
disconnect::DisconnectEvent,
packet::game::{KeepAliveEvent, ResourcePackEvent},
};
pub fn process_raw_packet(
ecs: &mut World,

View file

@ -2,34 +2,38 @@ use std::{fmt::Debug, sync::Arc};
use azalea_auth::game_profile::GameProfile;
use azalea_buf::AzaleaWrite;
use azalea_core::delta::PositionDelta8;
use azalea_core::game_type::{GameMode, OptionalGameType};
use azalea_core::position::{ChunkPos, Vec3};
use azalea_core::resource_location::ResourceLocation;
use azalea_core::tick::GameTick;
use azalea_entity::metadata::PlayerMetadataBundle;
use azalea_protocol::packets::common::CommonPlayerSpawnInfo;
use azalea_protocol::packets::config::{ClientboundFinishConfiguration, ClientboundRegistryData};
use azalea_protocol::packets::game::c_level_chunk_with_light::ClientboundLevelChunkPacketData;
use azalea_protocol::packets::game::c_light_update::ClientboundLightUpdatePacketData;
use azalea_protocol::packets::game::{
ClientboundAddEntity, ClientboundLevelChunkWithLight, ClientboundLogin, ClientboundRespawn,
use azalea_core::{
delta::PositionDelta8,
game_type::{GameMode, OptionalGameType},
position::{ChunkPos, Vec3},
resource_location::ResourceLocation,
tick::GameTick,
};
use azalea_entity::metadata::PlayerMetadataBundle;
use azalea_protocol::packets::{
ConnectionProtocol, Packet, ProtocolPacket,
common::CommonPlayerSpawnInfo,
config::{ClientboundFinishConfiguration, ClientboundRegistryData},
game::{
ClientboundAddEntity, ClientboundLevelChunkWithLight, ClientboundLogin, ClientboundRespawn,
c_level_chunk_with_light::ClientboundLevelChunkPacketData,
c_light_update::ClientboundLightUpdatePacketData,
},
};
use azalea_protocol::packets::{ConnectionProtocol, Packet, ProtocolPacket};
use azalea_registry::{DimensionType, EntityKind};
use azalea_world::palette::{PalettedContainer, PalettedContainerKind};
use azalea_world::{Chunk, Instance, MinecraftEntityId, Section};
use azalea_world::{
Chunk, Instance, MinecraftEntityId, Section,
palette::{PalettedContainer, PalettedContainerKind},
};
use bevy_app::App;
use bevy_ecs::component::Mutable;
use bevy_ecs::{prelude::*, schedule::ExecutorKind};
use bevy_ecs::{component::Mutable, prelude::*, schedule::ExecutorKind};
use parking_lot::RwLock;
use simdnbt::owned::{NbtCompound, NbtTag};
use uuid::Uuid;
use crate::connection::RawConnection;
use crate::disconnect::DisconnectEvent;
use crate::{
ClientInformation, GameProfileComponent, InConfigState, InstanceHolder, LocalPlayerBundle,
connection::RawConnection, disconnect::DisconnectEvent,
};
/// A way to simulate a client in a server, used for some internal tests.

View file

@ -3,21 +3,18 @@
//! The most common ones are [`Vec3`] and [`BlockPos`], which are usually used
//! for entity positions and block positions, respectively.
use std::hash::Hasher;
use std::io;
use std::str::FromStr;
use std::{
fmt,
hash::Hash,
hash::{Hash, Hasher},
io,
io::{Cursor, Write},
ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, Sub},
str::FromStr,
};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError};
use crate::direction::Direction;
use crate::math;
use crate::resource_location::ResourceLocation;
use crate::{direction::Direction, math, resource_location::ResourceLocation};
macro_rules! vec3_impl {
($name:ident, $type:ty) => {

View file

@ -2,10 +2,9 @@
mod signing;
use aes::cipher::inout::InOutBuf;
use aes::{
Aes128,
cipher::{BlockDecryptMut, BlockEncryptMut, KeyIvInit},
cipher::{BlockDecryptMut, BlockEncryptMut, KeyIvInit, inout::InOutBuf},
};
use rand::{RngCore, rngs::OsRng};
use sha1::{Digest, Sha1};

View file

@ -25,8 +25,7 @@ use tokio::{
io::{self, AsyncWriteExt},
net::{TcpListener, TcpStream},
};
use tracing::Level;
use tracing::{error, info, warn};
use tracing::{Level, error, info, warn};
const LISTEN_ADDR: &str = "127.0.0.1:25566";
const PROXY_ADDR: &str = "127.0.0.1:25565";

View file

@ -1,29 +1,40 @@
//! Connect to remote servers/clients.
use std::fmt::{self, Debug, Display};
use std::io::{self, Cursor};
use std::marker::PhantomData;
use std::net::SocketAddr;
use std::{
fmt::{self, Debug, Display},
io::{self, Cursor},
marker::PhantomData,
net::SocketAddr,
};
use azalea_auth::game_profile::GameProfile;
use azalea_auth::sessionserver::{ClientSessionServerError, ServerSessionServerError};
use azalea_auth::{
game_profile::GameProfile,
sessionserver::{ClientSessionServerError, ServerSessionServerError},
};
use azalea_crypto::{Aes128CfbDec, Aes128CfbEnc};
use thiserror::Error;
use tokio::io::{AsyncWriteExt, BufStream};
use tokio::net::TcpStream;
use tokio::net::tcp::{OwnedReadHalf, OwnedWriteHalf, ReuniteError};
use tokio::{
io::{AsyncWriteExt, BufStream},
net::{
TcpStream,
tcp::{OwnedReadHalf, OwnedWriteHalf, ReuniteError},
},
};
use tracing::{error, info};
use uuid::Uuid;
use crate::packets::ProtocolPacket;
use crate::packets::config::{ClientboundConfigPacket, ServerboundConfigPacket};
use crate::packets::game::{ClientboundGamePacket, ServerboundGamePacket};
use crate::packets::handshake::{ClientboundHandshakePacket, ServerboundHandshakePacket};
use crate::packets::login::c_hello::ClientboundHello;
use crate::packets::login::{ClientboundLoginPacket, ServerboundLoginPacket};
use crate::packets::status::{ClientboundStatusPacket, ServerboundStatusPacket};
use crate::read::{ReadPacketError, deserialize_packet, read_raw_packet, try_read_raw_packet};
use crate::write::{serialize_packet, write_raw_packet};
use crate::{
packets::{
ProtocolPacket,
config::{ClientboundConfigPacket, ServerboundConfigPacket},
game::{ClientboundGamePacket, ServerboundGamePacket},
handshake::{ClientboundHandshakePacket, ServerboundHandshakePacket},
login::{ClientboundLoginPacket, ServerboundLoginPacket, c_hello::ClientboundHello},
status::{ClientboundStatusPacket, ServerboundStatusPacket},
},
read::{ReadPacketError, deserialize_packet, read_raw_packet, try_read_raw_packet},
write::{serialize_packet, write_raw_packet},
};
pub struct RawReadConnection {
pub read_stream: OwnedReadHalf,

View file

@ -1,23 +1,25 @@
//! Read packets from a stream.
use std::backtrace::Backtrace;
use std::sync::LazyLock;
use std::{env, io};
use std::{
backtrace::Backtrace,
env,
fmt::Debug,
io,
io::{Cursor, Read},
sync::LazyLock,
};
use azalea_buf::AzaleaReadVar;
use azalea_buf::BufReadError;
use azalea_buf::{AzaleaReadVar, BufReadError};
use azalea_crypto::Aes128CfbDec;
use flate2::read::ZlibDecoder;
use futures::StreamExt;
use futures_lite::future;
use thiserror::Error;
use tokio::io::AsyncRead;
use tokio_util::bytes::Buf;
use tokio_util::codec::{BytesCodec, FramedRead};
use tokio_util::{
bytes::Buf,
codec::{BytesCodec, FramedRead},
};
use tracing::trace;
use crate::packets::ProtocolPacket;

View file

@ -9,8 +9,10 @@ mod data;
mod extra;
pub mod tags;
use std::fmt::{self, Debug};
use std::io::{self, Cursor, Write};
use std::{
fmt::{self, Debug},
io::{self, Cursor, Write},
};
use azalea_buf::{AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
use azalea_registry_macros::registry;

View file

@ -1,24 +1,26 @@
use std::collections::hash_map::Entry;
use std::{
collections::HashMap,
collections::{HashMap, hash_map::Entry},
fmt,
fmt::Debug,
io,
io::{Cursor, Write},
sync::{Arc, Weak},
};
use std::{fmt, io};
use azalea_block::block_state::{BlockState, BlockStateIntegerRepr};
use azalea_block::fluid_state::FluidState;
use azalea_block::{
block_state::{BlockState, BlockStateIntegerRepr},
fluid_state::FluidState,
};
use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError};
use azalea_core::position::{BlockPos, ChunkBlockPos, ChunkPos, ChunkSectionBlockPos};
use nohash_hasher::IntMap;
use parking_lot::RwLock;
use tracing::{debug, trace, warn};
use crate::heightmap::Heightmap;
use crate::heightmap::HeightmapKind;
use crate::palette::PalettedContainer;
use crate::palette::PalettedContainerKind;
use crate::{
heightmap::{Heightmap, HeightmapKind},
palette::{PalettedContainer, PalettedContainerKind},
};
const SECTION_HEIGHT: u32 = 16;

View file

@ -1,16 +1,16 @@
use std::{
collections::{HashMap, HashSet},
fmt::Debug,
fmt::{self, Display},
fmt::{self, Debug, Display},
hash::{Hash, Hasher},
io::{self, Cursor},
};
use azalea_block::BlockState;
use azalea_block::fluid_state::FluidState;
use azalea_block::{BlockState, fluid_state::FluidState};
use azalea_buf::{AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
use azalea_core::position::{BlockPos, ChunkPos};
use azalea_core::registry_holder::RegistryHolder;
use azalea_core::{
position::{BlockPos, ChunkPos},
registry_holder::RegistryHolder,
};
use bevy_ecs::{component::Component, entity::Entity};
use derive_more::{Deref, DerefMut};
use nohash_hasher::IntMap;

View file

@ -1,5 +1,4 @@
use std::env;
use std::process::Command;
use std::{env, process::Command};
fn main() {
// If using `rustup`, check the toolchain via `RUSTUP_TOOLCHAIN`

View file

@ -1,10 +1,10 @@
use azalea::ClientBuilder;
use azalea::nearest_entity::EntityFinder;
use azalea::{Bot, LookAtEvent};
use azalea::{Bot, ClientBuilder, LookAtEvent, nearest_entity::EntityFinder};
use azalea_client::Account;
use azalea_core::tick::GameTick;
use azalea_entity::metadata::{ItemItem, Player};
use azalea_entity::{EyeHeight, LocalEntity, Position};
use azalea_entity::{
EyeHeight, LocalEntity, Position,
metadata::{ItemItem, Player},
};
use bevy_app::Plugin;
use bevy_ecs::{
prelude::{Entity, EventWriter},

View file

@ -2,10 +2,8 @@
use std::sync::Arc;
use azalea::pathfinder::goals::RadiusGoal;
use azalea::{BlockPos, prelude::*};
use azalea_inventory::ItemStack;
use azalea_inventory::operations::QuickMoveClick;
use azalea::{BlockPos, pathfinder::goals::RadiusGoal, prelude::*};
use azalea_inventory::{ItemStack, operations::QuickMoveClick};
use parking_lot::Mutex;
#[tokio::main]

View file

@ -2,12 +2,10 @@ pub mod combat;
pub mod debug;
pub mod movement;
use azalea::Client;
use azalea::GameProfileComponent;
use azalea::brigadier::prelude::*;
use azalea::chat::ChatPacket;
use azalea::ecs::prelude::*;
use azalea::entity::metadata::Player;
use azalea::{
Client, GameProfileComponent, brigadier::prelude::*, chat::ChatPacket, ecs::prelude::*,
entity::metadata::Player,
};
use parking_lot::Mutex;
use crate::State;

View file

@ -25,16 +25,12 @@
mod commands;
pub mod killaura;
use std::time::Duration;
use std::{env, process};
use std::{sync::Arc, thread};
use std::{env, process, sync::Arc, thread, time::Duration};
use azalea::ClientInformation;
use azalea::brigadier::command_dispatcher::CommandDispatcher;
use azalea::ecs::prelude::*;
use azalea::pathfinder::debug::PathfinderDebugParticles;
use azalea::prelude::*;
use azalea::swarm::prelude::*;
use azalea::{
ClientInformation, brigadier::command_dispatcher::CommandDispatcher, ecs::prelude::*,
pathfinder::debug::PathfinderDebugParticles, prelude::*, swarm::prelude::*,
};
use commands::{CommandSource, register_commands};
use parking_lot::Mutex;

View file

@ -1,12 +1,18 @@
use azalea_client::InConfigState;
use azalea_client::chunks::handle_chunk_batch_finished_event;
use azalea_client::inventory::InventorySet;
use azalea_client::packet::config::SendConfigPacketEvent;
use azalea_client::packet::game::SendPacketEvent;
use azalea_client::packet::{death_event_on_0_health, game::ResourcePackEvent};
use azalea_client::respawn::perform_respawn;
use azalea_protocol::packets::config;
use azalea_protocol::packets::game::s_resource_pack::{self, ServerboundResourcePack};
use azalea_client::{
InConfigState,
chunks::handle_chunk_batch_finished_event,
inventory::InventorySet,
packet::{
config::SendConfigPacketEvent,
death_event_on_0_health,
game::{ResourcePackEvent, SendPacketEvent},
},
respawn::perform_respawn,
};
use azalea_protocol::packets::{
config,
game::s_resource_pack::{self, ServerboundResourcePack},
};
use bevy_app::Update;
use bevy_ecs::prelude::*;

View file

@ -1,9 +1,13 @@
use std::f64::consts::PI;
use azalea_client::mining::Mining;
use azalea_client::tick_broadcast::{TickBroadcast, UpdateBroadcast};
use azalea_core::position::{BlockPos, Vec3};
use azalea_core::tick::GameTick;
use azalea_client::{
mining::Mining,
tick_broadcast::{TickBroadcast, UpdateBroadcast},
};
use azalea_core::{
position::{BlockPos, Vec3},
tick::GameTick,
};
use azalea_entity::{
EyeHeight, Jumping, LocalEntity, LookDirection, Position, clamp_look_direction,
metadata::Player,
@ -14,18 +18,20 @@ use bevy_ecs::prelude::*;
use futures_lite::Future;
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::{
accept_resource_packs::AcceptResourcePacksPlugin,
app::{App, Plugin, PluginGroup, PluginGroupBuilder},
auto_respawn::AutoRespawnPlugin,
container::ContainerPlugin,
ecs::{
component::Component,
entity::Entity,
event::EventReader,
query::{With, Without},
system::{Commands, Query},
},
pathfinder::PathfinderPlugin,
};
use crate::pathfinder::PathfinderPlugin;
#[derive(Clone, Default)]
pub struct BotPlugin;

View file

@ -1,10 +1,9 @@
use std::fmt;
use std::fmt::Debug;
use std::{fmt, fmt::Debug};
use azalea_client::packet::game::ReceiveGamePacketEvent;
use azalea_client::{
Client,
inventory::{CloseContainerEvent, ContainerClickEvent, Inventory},
packet::game::ReceiveGamePacketEvent,
};
use azalea_core::position::BlockPos;
use azalea_inventory::{ItemStack, Menu, operations::ClickOperation};

View file

@ -13,8 +13,7 @@ pub mod pathfinder;
pub mod prelude;
pub mod swarm;
use std::net::SocketAddr;
use std::time::Duration;
use std::{net::SocketAddr, time::Duration};
use app::Plugins;
pub use azalea_auth as auth;
@ -39,8 +38,7 @@ pub use bevy_ecs as ecs;
pub use bot::*;
use ecs::component::Component;
use futures::{Future, future::BoxFuture};
use protocol::connect::Proxy;
use protocol::{ServerAddress, resolver::ResolverError};
use protocol::{ServerAddress, connect::Proxy, resolver::ResolverError};
use swarm::SwarmBuilder;
use thiserror::Error;

View file

@ -12,23 +12,27 @@ pub mod rel_block_pos;
pub mod simulation;
pub mod world;
use std::collections::VecDeque;
use std::ops::RangeInclusive;
use std::sync::Arc;
use std::sync::atomic::{self, AtomicUsize};
use std::time::{Duration, Instant};
use std::{cmp, thread};
use std::{
cmp,
collections::VecDeque,
ops::RangeInclusive,
sync::{
Arc,
atomic::{self, AtomicUsize},
},
thread,
time::{Duration, Instant},
};
use astar::{Edge, PathfinderTimeout};
use azalea_client::inventory::{Inventory, InventorySet, SetSelectedHotbarSlotEvent};
use azalea_client::mining::{Mining, StartMiningBlockEvent};
use azalea_client::movement::MoveEventsSet;
use azalea_client::{InstanceHolder, StartSprintEvent, StartWalkEvent};
use azalea_core::position::BlockPos;
use azalea_core::tick::GameTick;
use azalea_entity::LocalEntity;
use azalea_entity::metadata::Player;
use azalea_entity::{Physics, Position};
use azalea_client::{
InstanceHolder, StartSprintEvent, StartWalkEvent,
inventory::{Inventory, InventorySet, SetSelectedHotbarSlotEvent},
mining::{Mining, StartMiningBlockEvent},
movement::MoveEventsSet,
};
use azalea_core::{position::BlockPos, tick::GameTick};
use azalea_entity::{LocalEntity, Physics, Position, metadata::Player};
use azalea_physics::PhysicsSet;
use azalea_world::{InstanceContainer, InstanceName};
use bevy_app::{PreUpdate, Update};
@ -41,21 +45,25 @@ use rel_block_pos::RelBlockPos;
use tokio::sync::broadcast::error::RecvError;
use tracing::{debug, error, info, trace, warn};
use self::debug::debug_render_path_with_particles;
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 self::{
debug::debug_render_path_with_particles,
goals::Goal,
mining::MiningCache,
moves::{ExecuteCtx, IsReachedCtx, SuccessorsFn},
};
use crate::{
BotClientExt, WalkDirection,
app::{App, Plugin},
bot::{JumpEvent, LookAtEvent},
ecs::{
component::Component,
entity::Entity,
event::{EventReader, EventWriter},
query::{With, Without},
system::{Commands, Query, Res},
},
pathfinder::{astar::a_star, moves::PathfinderCtx, world::CachedWorld},
};
use crate::pathfinder::{astar::a_star, moves::PathfinderCtx, world::CachedWorld};
use crate::{BotClientExt, WalkDirection};
#[derive(Clone, Default)]
pub struct PathfinderPlugin;

View file

@ -6,8 +6,10 @@ 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, resource::Resource};
pub use crate::{
ClientBuilder, bot::BotClientExt, container::ContainerClientExt,
ClientBuilder,
bot::BotClientExt,
container::ContainerClientExt,
ecs::{component::Component, resource::Resource},
pathfinder::PathfinderClientExt,
};

View file

@ -1,2 +1,3 @@
wrap_comments = true
group_imports = "StdExternalCrate"
imports_granularity = "Crate"