From 6b0fe5bf638079d535e70c3c91e78fe35a5d2a2f Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 26 Oct 2024 05:29:26 +0000 Subject: [PATCH] group imports with rustfmt --- azalea-auth/src/auth.rs | 10 +-- azalea-auth/src/cache.rs | 3 +- azalea-auth/src/game_profile.rs | 3 +- azalea-block/azalea-block-macros/src/lib.rs | 5 +- azalea-block/src/generated.rs | 6 +- azalea-block/src/lib.rs | 10 +-- .../src/arguments/bool_argument_type.rs | 3 +- .../src/arguments/double_argument_type.rs | 3 +- .../src/arguments/float_argument_type.rs | 3 +- .../src/arguments/integer_argument_type.rs | 3 +- .../src/arguments/long_argument_type.rs | 3 +- .../src/arguments/string_argument_type.rs | 3 +- .../src/builder/argument_builder.rs | 6 +- .../src/builder/required_argument_builder.rs | 3 +- azalea-brigadier/src/command_dispatcher.rs | 15 +++-- .../src/context/command_context.rs | 3 +- .../src/context/command_context_builder.rs | 3 +- .../src/context/parsed_argument.rs | 3 +- .../src/context/parsed_command_node.rs | 3 +- .../src/exceptions/builtin_exceptions.rs | 3 +- .../exceptions/command_syntax_exception.rs | 3 +- azalea-brigadier/src/parse_results.rs | 3 +- azalea-brigadier/src/string_reader.rs | 3 +- azalea-brigadier/src/suggestion/mod.rs | 12 ++-- .../src/suggestion/suggestions.rs | 12 ++-- .../src/suggestion/suggestions_builder.rs | 3 +- azalea-brigadier/src/tree/mod.rs | 15 +++-- azalea-buf/src/lib.rs | 3 +- azalea-buf/src/read.rs | 6 +- azalea-buf/src/serializable_uuid.rs | 4 +- azalea-buf/src/write.rs | 6 +- azalea-chat/src/base_component.rs | 3 +- azalea-chat/src/component.rs | 16 +++-- azalea-chat/src/style.rs | 3 +- azalea-chat/src/text_component.rs | 9 +-- azalea-chat/src/translatable_component.rs | 7 +- azalea-client/src/chat.rs | 9 +-- azalea-client/src/client.rs | 67 ++++++++++--------- azalea-client/src/movement.rs | 8 ++- azalea-client/src/packet_handling/mod.rs | 3 +- azalea-client/src/ping.rs | 3 +- azalea-core/src/delta.rs | 3 +- azalea-core/src/game_type.rs | 3 +- azalea-core/src/position.rs | 10 +-- azalea-core/src/registry_holder.rs | 3 +- azalea-core/src/resource_location.rs | 4 +- azalea-entity/src/data.rs | 3 +- azalea-entity/src/lib.rs | 11 +-- azalea-entity/src/metadata.rs | 12 ++-- azalea-entity/src/plugin/indexing.rs | 6 +- azalea-entity/src/plugin/mod.rs | 5 +- .../src/location_enum.rs | 3 +- .../azalea-inventory-macros/src/menu_enum.rs | 3 +- .../azalea-inventory-macros/src/menu_impl.rs | 7 +- azalea-inventory/src/slot.rs | 5 +- azalea-language/src/lib.rs | 3 +- azalea-physics/src/collision/blocks.rs | 5 +- azalea-physics/src/collision/mergers.rs | 3 +- azalea-physics/src/collision/shape.rs | 8 ++- .../src/collision/world_collisions.rs | 8 ++- azalea-physics/src/lib.rs | 3 +- azalea-protocol/examples/handshake_proxy.rs | 3 +- azalea-protocol/src/connect.rs | 30 +++++---- azalea-protocol/src/lib.rs | 5 +- .../clientbound_update_tags_packet.rs | 7 +- .../serverbound_client_information_packet.rs | 3 +- .../game/clientbound_award_stats_packet.rs | 3 +- .../game/clientbound_boss_event_packet.rs | 5 +- .../clientbound_command_suggestions_packet.rs | 6 +- .../game/clientbound_commands_packet.rs | 3 +- .../game/clientbound_delete_chat_packet.rs | 3 +- .../game/clientbound_disguised_chat_packet.rs | 3 +- .../packets/game/clientbound_login_packet.rs | 4 +- .../game/clientbound_open_book_packet.rs | 3 +- .../clientbound_player_abilities_packet.rs | 3 +- .../game/clientbound_player_chat_packet.rs | 3 +- .../clientbound_player_info_update_packet.rs | 9 +-- .../game/clientbound_set_equipment_packet.rs | 3 +- .../clientbound_set_player_team_packet.rs | 3 +- .../game/clientbound_stop_sound_packet.rs | 3 +- .../clientbound_update_advancements_packet.rs | 8 ++- .../game/clientbound_update_tags_packet.rs | 7 +- .../serverbound_chat_command_signed_packet.rs | 3 +- .../serverbound_container_click_packet.rs | 3 +- .../game/serverbound_interact_packet.rs | 6 +- .../serverbound_player_abilities_packet.rs | 6 +- .../serverbound_seen_advancements_packet.rs | 6 +- .../serverbound_set_command_block_packet.rs | 6 +- .../serverbound_set_jigsaw_block_packet.rs | 10 +-- .../serverbound_set_structure_block_packet.rs | 6 +- .../packets/game/serverbound_swing_packet.rs | 3 +- .../game/serverbound_use_item_on_packet.rs | 6 +- .../game/serverbound_use_item_packet.rs | 3 +- .../handshaking/client_intention_packet.rs | 6 +- .../login/clientbound_custom_query_packet.rs | 3 +- .../clientbound_login_compression_packet.rs | 3 +- .../serverbound_custom_query_answer_packet.rs | 3 +- .../packets/login/serverbound_hello_packet.rs | 3 +- azalea-protocol/src/packets/mod.rs | 6 +- .../clientbound_status_response_packet.rs | 3 +- azalea-protocol/src/read.rs | 14 ++-- azalea-protocol/src/resolver.rs | 6 +- azalea-protocol/src/write.rs | 6 +- azalea-registry/src/extra.rs | 3 +- azalea-registry/src/lib.rs | 1 - azalea-world/src/chunk_storage.rs | 22 +++--- azalea-world/src/container.rs | 9 +-- azalea-world/src/find_blocks.rs | 3 +- azalea-world/src/palette.rs | 3 +- azalea-world/src/world.rs | 14 ++-- azalea/examples/steal.rs | 3 +- azalea/examples/testbot/commands/movement.rs | 3 +- azalea/examples/testbot/main.rs | 11 +-- azalea/src/accept_resource_packs.rs | 3 +- azalea/src/auto_respawn.rs | 3 +- azalea/src/bot.rs | 25 +++---- azalea/src/container.rs | 2 +- azalea/src/lib.rs | 5 +- azalea/src/pathfinder/mining.rs | 3 +- azalea/src/pathfinder/mod.rs | 34 +++++----- azalea/src/pathfinder/moves/basic.rs | 3 +- azalea/src/pathfinder/moves/mod.rs | 14 ++-- azalea/src/pathfinder/moves/parkour.rs | 3 +- azalea/src/pathfinder/world.rs | 3 +- azalea/src/prelude.rs | 11 +-- azalea/src/swarm/chat.rs | 13 ++-- azalea/src/swarm/mod.rs | 3 +- rustfmt.toml | 1 + 128 files changed, 469 insertions(+), 357 deletions(-) diff --git a/azalea-auth/src/auth.rs b/azalea-auth/src/auth.rs index 667c9062c..e70be27d6 100755 --- a/azalea-auth/src/auth.rs +++ b/azalea-auth/src/auth.rs @@ -1,18 +1,20 @@ //! Handle Minecraft (Xbox) authentication. -use crate::cache::{self, CachedAccount, ExpiringValue}; -use chrono::{DateTime, Utc}; -use serde::{Deserialize, Serialize}; -use serde_json::json; use std::{ collections::HashMap, path::PathBuf, time::{Instant, SystemTime, UNIX_EPOCH}, }; + +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use serde_json::json; use thiserror::Error; use tracing::{error, trace}; use uuid::Uuid; +use crate::cache::{self, CachedAccount, ExpiringValue}; + #[derive(Default)] pub struct AuthOpts<'a> { /// Whether we should check if the user actually owns the game. This will diff --git a/azalea-auth/src/cache.rs b/azalea-auth/src/cache.rs index 210dbab6a..ca32958fa 100755 --- a/azalea-auth/src/cache.rs +++ b/azalea-auth/src/cache.rs @@ -1,8 +1,9 @@ //! Cache auth information -use serde::{Deserialize, Serialize}; use std::path::Path; use std::time::{SystemTime, UNIX_EPOCH}; + +use serde::{Deserialize, Serialize}; use thiserror::Error; use tokio::fs::File; use tokio::io::{AsyncReadExt, AsyncWriteExt}; diff --git a/azalea-auth/src/game_profile.rs b/azalea-auth/src/game_profile.rs index 6a34a87bd..31650754d 100755 --- a/azalea-auth/src/game_profile.rs +++ b/azalea-auth/src/game_profile.rs @@ -1,6 +1,7 @@ +use std::collections::HashMap; + use azalea_buf::McBuf; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; use uuid::Uuid; #[derive(McBuf, Debug, Clone, Default, Eq, PartialEq)] diff --git a/azalea-block/azalea-block-macros/src/lib.rs b/azalea-block/azalea-block-macros/src/lib.rs index 54b994791..742d1fc93 100755 --- a/azalea-block/azalea-block-macros/src/lib.rs +++ b/azalea-block/azalea-block-macros/src/lib.rs @@ -2,11 +2,12 @@ mod utils; +use std::collections::HashMap; +use std::fmt::Write; + use proc_macro::TokenStream; use proc_macro2::TokenTree; use quote::quote; -use std::collections::HashMap; -use std::fmt::Write; use syn::{ braced, ext::IdentExt, diff --git a/azalea-block/src/generated.rs b/azalea-block/src/generated.rs index 76dfb2dc6..18ee93fcc 100755 --- a/azalea-block/src/generated.rs +++ b/azalea-block/src/generated.rs @@ -1,7 +1,9 @@ -use crate::{Block, BlockBehavior, BlockState, BlockStates, Property}; -use azalea_block_macros::make_block_states; use std::fmt::Debug; +use azalea_block_macros::make_block_states; + +use crate::{Block, BlockBehavior, BlockState, BlockStates, Property}; + make_block_states! { Properties => { "snowy" => Snowy(bool), diff --git a/azalea-block/src/lib.rs b/azalea-block/src/lib.rs index 2a46fd010..7e6ccfaf6 100755 --- a/azalea-block/src/lib.rs +++ b/azalea-block/src/lib.rs @@ -5,17 +5,17 @@ mod behavior; mod generated; mod range; -pub use generated::{blocks, properties}; - -use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable}; -pub use behavior::BlockBehavior; use core::fmt::Debug; -pub use range::BlockStates; use std::{ any::Any, io::{Cursor, Write}, }; +use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable}; +pub use behavior::BlockBehavior; +pub use generated::{blocks, properties}; +pub use range::BlockStates; + pub trait Block: Debug + Any { fn behavior(&self) -> BlockBehavior; /// Get the Minecraft ID for this block. For example `stone` or diff --git a/azalea-brigadier/src/arguments/bool_argument_type.rs b/azalea-brigadier/src/arguments/bool_argument_type.rs index a73a9da52..efb865099 100644 --- a/azalea-brigadier/src/arguments/bool_argument_type.rs +++ b/azalea-brigadier/src/arguments/bool_argument_type.rs @@ -1,5 +1,6 @@ use std::{any::Any, sync::Arc}; +use super::ArgumentType; use crate::{ context::CommandContext, exceptions::CommandSyntaxException, @@ -7,8 +8,6 @@ use crate::{ suggestion::{Suggestions, SuggestionsBuilder}, }; -use super::ArgumentType; - #[derive(Default)] struct Boolean; diff --git a/azalea-brigadier/src/arguments/double_argument_type.rs b/azalea-brigadier/src/arguments/double_argument_type.rs index ea99f1cfc..559d1cf52 100644 --- a/azalea-brigadier/src/arguments/double_argument_type.rs +++ b/azalea-brigadier/src/arguments/double_argument_type.rs @@ -1,13 +1,12 @@ use std::{any::Any, sync::Arc}; +use super::ArgumentType; use crate::{ context::CommandContext, exceptions::{BuiltInExceptions, CommandSyntaxException}, string_reader::StringReader, }; -use super::ArgumentType; - #[derive(Default)] struct Double { pub minimum: Option, diff --git a/azalea-brigadier/src/arguments/float_argument_type.rs b/azalea-brigadier/src/arguments/float_argument_type.rs index 2333499a8..83e298ff8 100644 --- a/azalea-brigadier/src/arguments/float_argument_type.rs +++ b/azalea-brigadier/src/arguments/float_argument_type.rs @@ -1,13 +1,12 @@ use std::{any::Any, sync::Arc}; +use super::ArgumentType; use crate::{ context::CommandContext, exceptions::{BuiltInExceptions, CommandSyntaxException}, string_reader::StringReader, }; -use super::ArgumentType; - #[derive(Default)] struct Float { pub minimum: Option, diff --git a/azalea-brigadier/src/arguments/integer_argument_type.rs b/azalea-brigadier/src/arguments/integer_argument_type.rs index cc4755ee6..47d25e279 100644 --- a/azalea-brigadier/src/arguments/integer_argument_type.rs +++ b/azalea-brigadier/src/arguments/integer_argument_type.rs @@ -1,13 +1,12 @@ use std::{any::Any, sync::Arc}; +use super::ArgumentType; use crate::{ context::CommandContext, exceptions::{BuiltInExceptions, CommandSyntaxException}, string_reader::StringReader, }; -use super::ArgumentType; - #[derive(Default)] struct Integer { pub minimum: Option, diff --git a/azalea-brigadier/src/arguments/long_argument_type.rs b/azalea-brigadier/src/arguments/long_argument_type.rs index 4e36abee4..ba65479c1 100644 --- a/azalea-brigadier/src/arguments/long_argument_type.rs +++ b/azalea-brigadier/src/arguments/long_argument_type.rs @@ -1,13 +1,12 @@ use std::{any::Any, sync::Arc}; +use super::ArgumentType; use crate::{ context::CommandContext, exceptions::{BuiltInExceptions, CommandSyntaxException}, string_reader::StringReader, }; -use super::ArgumentType; - #[derive(Default)] struct Long { pub minimum: Option, diff --git a/azalea-brigadier/src/arguments/string_argument_type.rs b/azalea-brigadier/src/arguments/string_argument_type.rs index d38fbc79b..96b9c998e 100644 --- a/azalea-brigadier/src/arguments/string_argument_type.rs +++ b/azalea-brigadier/src/arguments/string_argument_type.rs @@ -1,11 +1,10 @@ use std::{any::Any, sync::Arc}; +use super::ArgumentType; use crate::{ context::CommandContext, exceptions::CommandSyntaxException, string_reader::StringReader, }; -use super::ArgumentType; - pub enum StringArgument { /// Match up until the next space. SingleWord, diff --git a/azalea-brigadier/src/builder/argument_builder.rs b/azalea-brigadier/src/builder/argument_builder.rs index 9d3e8cad5..9ebe6400d 100755 --- a/azalea-brigadier/src/builder/argument_builder.rs +++ b/azalea-brigadier/src/builder/argument_builder.rs @@ -1,14 +1,14 @@ +use std::{fmt::Debug, sync::Arc}; + use parking_lot::RwLock; +use super::{literal_argument_builder::Literal, required_argument_builder::Argument}; use crate::{ context::CommandContext, modifier::RedirectModifier, tree::{Command, CommandNode}, }; -use super::{literal_argument_builder::Literal, required_argument_builder::Argument}; -use std::{fmt::Debug, sync::Arc}; - #[derive(Debug, Clone)] pub enum ArgumentBuilderType { Literal(Literal), diff --git a/azalea-brigadier/src/builder/required_argument_builder.rs b/azalea-brigadier/src/builder/required_argument_builder.rs index 1c79f6195..51f0acec8 100755 --- a/azalea-brigadier/src/builder/required_argument_builder.rs +++ b/azalea-brigadier/src/builder/required_argument_builder.rs @@ -1,3 +1,5 @@ +use std::{any::Any, fmt::Debug, sync::Arc}; + use super::argument_builder::{ArgumentBuilder, ArgumentBuilderType}; use crate::{ arguments::ArgumentType, @@ -5,7 +7,6 @@ use crate::{ string_reader::StringReader, suggestion::{Suggestions, SuggestionsBuilder}, }; -use std::{any::Any, fmt::Debug, sync::Arc}; /// An argument node type. The `T` type parameter is the type of the argument, /// which can be anything. diff --git a/azalea-brigadier/src/command_dispatcher.rs b/azalea-brigadier/src/command_dispatcher.rs index 2f4d6ebdd..619131e29 100755 --- a/azalea-brigadier/src/command_dispatcher.rs +++ b/azalea-brigadier/src/command_dispatcher.rs @@ -1,3 +1,11 @@ +use std::{ + cmp::Ordering, + collections::{HashMap, HashSet}, + mem, + rc::Rc, + sync::Arc, +}; + use parking_lot::RwLock; use crate::{ @@ -9,13 +17,6 @@ use crate::{ suggestion::{Suggestions, SuggestionsBuilder}, tree::CommandNode, }; -use std::{ - cmp::Ordering, - collections::{HashMap, HashSet}, - mem, - rc::Rc, - sync::Arc, -}; /// The root of the command tree. You need to make this to register commands. /// diff --git a/azalea-brigadier/src/context/command_context.rs b/azalea-brigadier/src/context/command_context.rs index 4d93006e2..3d401f968 100755 --- a/azalea-brigadier/src/context/command_context.rs +++ b/azalea-brigadier/src/context/command_context.rs @@ -1,3 +1,5 @@ +use std::{any::Any, collections::HashMap, fmt::Debug, rc::Rc, sync::Arc}; + use parking_lot::RwLock; use super::{parsed_command_node::ParsedCommandNode, string_range::StringRange, ParsedArgument}; @@ -5,7 +7,6 @@ use crate::{ modifier::RedirectModifier, tree::{Command, CommandNode}, }; -use std::{any::Any, collections::HashMap, fmt::Debug, rc::Rc, sync::Arc}; /// A built `CommandContextBuilder`. pub struct CommandContext { diff --git a/azalea-brigadier/src/context/command_context_builder.rs b/azalea-brigadier/src/context/command_context_builder.rs index 95e1b5d8b..3fb8ec701 100755 --- a/azalea-brigadier/src/context/command_context_builder.rs +++ b/azalea-brigadier/src/context/command_context_builder.rs @@ -1,3 +1,5 @@ +use std::{collections::HashMap, fmt::Debug, rc::Rc, sync::Arc}; + use parking_lot::RwLock; use super::{ @@ -9,7 +11,6 @@ use crate::{ modifier::RedirectModifier, tree::{Command, CommandNode}, }; -use std::{collections::HashMap, fmt::Debug, rc::Rc, sync::Arc}; pub struct CommandContextBuilder<'a, S> { pub arguments: HashMap, diff --git a/azalea-brigadier/src/context/parsed_argument.rs b/azalea-brigadier/src/context/parsed_argument.rs index 428851a88..ef5596948 100755 --- a/azalea-brigadier/src/context/parsed_argument.rs +++ b/azalea-brigadier/src/context/parsed_argument.rs @@ -1,6 +1,7 @@ -use super::string_range::StringRange; use std::{any::Any, sync::Arc}; +use super::string_range::StringRange; + #[derive(Clone)] pub struct ParsedArgument { pub range: StringRange, diff --git a/azalea-brigadier/src/context/parsed_command_node.rs b/azalea-brigadier/src/context/parsed_command_node.rs index 2d69c72e9..62da13d84 100755 --- a/azalea-brigadier/src/context/parsed_command_node.rs +++ b/azalea-brigadier/src/context/parsed_command_node.rs @@ -1,8 +1,9 @@ +use std::sync::Arc; + use parking_lot::RwLock; use super::string_range::StringRange; use crate::tree::CommandNode; -use std::sync::Arc; #[derive(Debug)] pub struct ParsedCommandNode { diff --git a/azalea-brigadier/src/exceptions/builtin_exceptions.rs b/azalea-brigadier/src/exceptions/builtin_exceptions.rs index e60c697c1..bf2072c12 100755 --- a/azalea-brigadier/src/exceptions/builtin_exceptions.rs +++ b/azalea-brigadier/src/exceptions/builtin_exceptions.rs @@ -1,8 +1,7 @@ use std::fmt; -use crate::string_reader::StringReader; - use super::command_syntax_exception::CommandSyntaxException; +use crate::string_reader::StringReader; #[derive(Clone, PartialEq)] pub enum BuiltInExceptions { diff --git a/azalea-brigadier/src/exceptions/command_syntax_exception.rs b/azalea-brigadier/src/exceptions/command_syntax_exception.rs index 0254820d1..657649b06 100755 --- a/azalea-brigadier/src/exceptions/command_syntax_exception.rs +++ b/azalea-brigadier/src/exceptions/command_syntax_exception.rs @@ -1,9 +1,10 @@ -use super::builtin_exceptions::BuiltInExceptions; use std::{ cmp, fmt::{self, Write}, }; +use super::builtin_exceptions::BuiltInExceptions; + #[derive(Clone, PartialEq)] pub struct CommandSyntaxException { pub type_: BuiltInExceptions, diff --git a/azalea-brigadier/src/parse_results.rs b/azalea-brigadier/src/parse_results.rs index aa7d79ea7..a2cefcf78 100755 --- a/azalea-brigadier/src/parse_results.rs +++ b/azalea-brigadier/src/parse_results.rs @@ -1,8 +1,9 @@ +use std::{collections::HashMap, fmt::Debug, rc::Rc}; + use crate::{ context::CommandContextBuilder, exceptions::CommandSyntaxException, string_reader::StringReader, tree::CommandNode, }; -use std::{collections::HashMap, fmt::Debug, rc::Rc}; pub struct ParseResults<'a, S> { pub context: CommandContextBuilder<'a, S>, diff --git a/azalea-brigadier/src/string_reader.rs b/azalea-brigadier/src/string_reader.rs index 03e105dda..963a22440 100755 --- a/azalea-brigadier/src/string_reader.rs +++ b/azalea-brigadier/src/string_reader.rs @@ -1,6 +1,7 @@ -use crate::exceptions::{BuiltInExceptions, CommandSyntaxException}; use std::str::FromStr; +use crate::exceptions::{BuiltInExceptions, CommandSyntaxException}; + #[derive(Clone)] pub struct StringReader { string: String, diff --git a/azalea-brigadier/src/suggestion/mod.rs b/azalea-brigadier/src/suggestion/mod.rs index fbebfe8a0..753b1bc86 100755 --- a/azalea-brigadier/src/suggestion/mod.rs +++ b/azalea-brigadier/src/suggestion/mod.rs @@ -1,20 +1,22 @@ mod suggestions; mod suggestions_builder; -use crate::context::StringRange; -#[cfg(feature = "azalea-buf")] -use azalea_buf::McBufWritable; -#[cfg(feature = "azalea-buf")] -use azalea_chat::FormattedText; #[cfg(feature = "azalea-buf")] use std::io::Write; use std::{ fmt::{self, Display}, hash::Hash, }; + +#[cfg(feature = "azalea-buf")] +use azalea_buf::McBufWritable; +#[cfg(feature = "azalea-buf")] +use azalea_chat::FormattedText; pub use suggestions::Suggestions; pub use suggestions_builder::SuggestionsBuilder; +use crate::context::StringRange; + /// A suggestion given to the user for what they might want to type next. /// /// The `M` generic is the type of the tooltip, so for example a `String` or diff --git a/azalea-brigadier/src/suggestion/suggestions.rs b/azalea-brigadier/src/suggestion/suggestions.rs index 487e42336..5941aa7db 100755 --- a/azalea-brigadier/src/suggestion/suggestions.rs +++ b/azalea-brigadier/src/suggestion/suggestions.rs @@ -1,16 +1,18 @@ -use super::Suggestion; -use crate::context::StringRange; #[cfg(feature = "azalea-buf")] -use crate::suggestion::SuggestionValue; +use std::io::{Cursor, Write}; +use std::{collections::HashSet, hash::Hash}; + #[cfg(feature = "azalea-buf")] use azalea_buf::{ BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable, }; #[cfg(feature = "azalea-buf")] use azalea_chat::FormattedText; + +use super::Suggestion; +use crate::context::StringRange; #[cfg(feature = "azalea-buf")] -use std::io::{Cursor, Write}; -use std::{collections::HashSet, hash::Hash}; +use crate::suggestion::SuggestionValue; #[derive(Debug, Clone, Eq, PartialEq, Hash, Default)] pub struct Suggestions { diff --git a/azalea-brigadier/src/suggestion/suggestions_builder.rs b/azalea-brigadier/src/suggestion/suggestions_builder.rs index 4e6296dd1..85c8f4d8a 100755 --- a/azalea-brigadier/src/suggestion/suggestions_builder.rs +++ b/azalea-brigadier/src/suggestion/suggestions_builder.rs @@ -1,8 +1,7 @@ use std::collections::HashSet; -use crate::context::StringRange; - use super::{Suggestion, SuggestionValue, Suggestions}; +use crate::context::StringRange; #[derive(PartialEq, Debug)] pub struct SuggestionsBuilder { diff --git a/azalea-brigadier/src/tree/mod.rs b/azalea-brigadier/src/tree/mod.rs index a982e82b3..dfa3b375b 100755 --- a/azalea-brigadier/src/tree/mod.rs +++ b/azalea-brigadier/src/tree/mod.rs @@ -1,3 +1,11 @@ +use std::{ + collections::{BTreeMap, HashMap}, + fmt::Debug, + hash::Hash, + ptr, + sync::Arc, +}; + use parking_lot::RwLock; use crate::{ @@ -11,13 +19,6 @@ use crate::{ string_reader::StringReader, suggestion::{Suggestions, SuggestionsBuilder}, }; -use std::{ - collections::{BTreeMap, HashMap}, - fmt::Debug, - hash::Hash, - ptr, - sync::Arc, -}; pub type Command = Option) -> i32 + Send + Sync>>; diff --git a/azalea-buf/src/lib.rs b/azalea-buf/src/lib.rs index fbde36847..e1d1281fd 100755 --- a/azalea-buf/src/lib.rs +++ b/azalea-buf/src/lib.rs @@ -20,9 +20,10 @@ const MAX_STRING_LENGTH: u16 = 32767; #[cfg(test)] mod tests { - use super::*; use std::{collections::HashMap, io::Cursor}; + use super::*; + #[test] fn test_write_varint() { let mut buf = Vec::new(); diff --git a/azalea-buf/src/read.rs b/azalea-buf/src/read.rs index 882e2bcec..8e406acb7 100755 --- a/azalea-buf/src/read.rs +++ b/azalea-buf/src/read.rs @@ -1,14 +1,16 @@ -use super::{UnsizedByteArray, MAX_STRING_LENGTH}; -use byteorder::{ReadBytesExt, BE}; use std::{ backtrace::Backtrace, collections::HashMap, hash::Hash, io::{Cursor, Read}, }; + +use byteorder::{ReadBytesExt, BE}; use thiserror::Error; use tracing::warn; +use super::{UnsizedByteArray, MAX_STRING_LENGTH}; + #[derive(Error, Debug)] pub enum BufReadError { #[error("Invalid VarInt")] diff --git a/azalea-buf/src/serializable_uuid.rs b/azalea-buf/src/serializable_uuid.rs index f42eed868..d4ec0315f 100755 --- a/azalea-buf/src/serializable_uuid.rs +++ b/azalea-buf/src/serializable_uuid.rs @@ -1,7 +1,9 @@ -use crate::{read::BufReadError, McBufReadable, McBufWritable}; use std::io::{Cursor, Write}; + use uuid::Uuid; +use crate::{read::BufReadError, McBufReadable, McBufWritable}; + pub trait SerializableUuid { fn to_int_array(&self) -> [u32; 4]; fn from_int_array(array: [u32; 4]) -> Self; diff --git a/azalea-buf/src/write.rs b/azalea-buf/src/write.rs index 61dedfd86..49215a5af 100755 --- a/azalea-buf/src/write.rs +++ b/azalea-buf/src/write.rs @@ -1,7 +1,9 @@ -use super::{UnsizedByteArray, MAX_STRING_LENGTH}; -use byteorder::{BigEndian, WriteBytesExt}; use std::{collections::HashMap, io::Write}; +use byteorder::{BigEndian, WriteBytesExt}; + +use super::{UnsizedByteArray, MAX_STRING_LENGTH}; + fn write_utf_with_len( buf: &mut impl Write, string: &str, diff --git a/azalea-chat/src/base_component.rs b/azalea-chat/src/base_component.rs index 8f70ecb7f..b01f2eb32 100755 --- a/azalea-chat/src/base_component.rs +++ b/azalea-chat/src/base_component.rs @@ -1,6 +1,7 @@ -use crate::{style::Style, FormattedText}; use serde::Serialize; +use crate::{style::Style, FormattedText}; + #[derive(Clone, Debug, PartialEq, Serialize, Eq, Hash)] pub struct BaseComponent { // implements mutablecomponent diff --git a/azalea-chat/src/component.rs b/azalea-chat/src/component.rs index dff4d91d9..84b5ed170 100755 --- a/azalea-chat/src/component.rs +++ b/azalea-chat/src/component.rs @@ -1,18 +1,20 @@ -use crate::{ - base_component::BaseComponent, - style::{ChatFormatting, Style}, - text_component::TextComponent, - translatable_component::{StringOrComponent, TranslatableComponent}, -}; +use std::fmt::Display; + #[cfg(feature = "azalea-buf")] use azalea_buf::{BufReadError, McBufReadable, McBufWritable}; use once_cell::sync::Lazy; use serde::{de, Deserialize, Deserializer, Serialize}; #[cfg(feature = "simdnbt")] use simdnbt::{Deserialize as _, FromNbtTag as _, Serialize as _}; -use std::fmt::Display; use tracing::{debug, trace, warn}; +use crate::{ + base_component::BaseComponent, + style::{ChatFormatting, Style}, + text_component::TextComponent, + translatable_component::{StringOrComponent, TranslatableComponent}, +}; + /// A chat component, basically anything you can see in chat. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Hash)] #[serde(untagged)] diff --git a/azalea-chat/src/style.rs b/azalea-chat/src/style.rs index a8cf5935c..a27f3d2a1 100755 --- a/azalea-chat/src/style.rs +++ b/azalea-chat/src/style.rs @@ -605,9 +605,8 @@ impl simdnbt::Deserialize for Style { #[cfg(test)] mod tests { - use crate::component::DEFAULT_STYLE; - use super::*; + use crate::component::DEFAULT_STYLE; #[test] fn text_color_named_colors() { diff --git a/azalea-chat/src/text_component.rs b/azalea-chat/src/text_component.rs index 6f95840d9..d3418ad85 100755 --- a/azalea-chat/src/text_component.rs +++ b/azalea-chat/src/text_component.rs @@ -1,7 +1,9 @@ -use crate::{base_component::BaseComponent, style::ChatFormatting, FormattedText}; -use serde::{ser::SerializeMap, Serialize, Serializer, __private::ser::FlatMapSerializer}; use std::fmt::Display; +use serde::{ser::SerializeMap, Serialize, Serializer, __private::ser::FlatMapSerializer}; + +use crate::{base_component::BaseComponent, style::ChatFormatting, FormattedText}; + /// A component that contains text that's the same in all locales. #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct TextComponent { @@ -140,9 +142,8 @@ impl Display for TextComponent { #[cfg(test)] mod tests { - use crate::style::Ansi; - use super::*; + use crate::style::Ansi; #[test] fn test_hypixel_motd() { diff --git a/azalea-chat/src/translatable_component.rs b/azalea-chat/src/translatable_component.rs index 82c84d85c..ecd238a56 100755 --- a/azalea-chat/src/translatable_component.rs +++ b/azalea-chat/src/translatable_component.rs @@ -1,12 +1,13 @@ use std::fmt::{self, Display, Formatter}; -use crate::{ - base_component::BaseComponent, style::Style, text_component::TextComponent, FormattedText, -}; use serde::{ser::SerializeMap, Serialize, Serializer, __private::ser::FlatMapSerializer}; #[cfg(feature = "simdnbt")] use simdnbt::Serialize as _; +use crate::{ + base_component::BaseComponent, style::Style, text_component::TextComponent, FormattedText, +}; + #[derive(Clone, Debug, PartialEq, Serialize, Eq, Hash)] #[serde(untagged)] pub enum StringOrComponent { diff --git a/azalea-client/src/chat.rs b/azalea-client/src/chat.rs index 1b4b72282..751893b78 100755 --- a/azalea-client/src/chat.rs +++ b/azalea-client/src/chat.rs @@ -1,5 +1,10 @@ //! Implementations of chat-related features. +use std::{ + sync::Arc, + time::{SystemTime, UNIX_EPOCH}, +}; + use azalea_chat::FormattedText; use azalea_protocol::packets::game::{ clientbound_disguised_chat_packet::ClientboundDisguisedChatPacket, @@ -15,10 +20,6 @@ use bevy_ecs::{ prelude::Event, schedule::IntoSystemConfigs, }; -use std::{ - sync::Arc, - time::{SystemTime, UNIX_EPOCH}, -}; use uuid::Uuid; use crate::{ diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 7551aa9fc..caeca7fed 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -1,27 +1,11 @@ -use crate::{ - attack::{self, AttackPlugin}, - chat::ChatPlugin, - chunks::{ChunkBatchInfo, ChunkPlugin}, - configuration::ConfigurationPlugin, - disconnect::{DisconnectEvent, DisconnectPlugin}, - events::{Event, EventPlugin, LocalPlayerEvents}, - interact::{CurrentSequenceNumber, InteractPlugin}, - inventory::{Inventory, InventoryPlugin}, - local_player::{ - death_event, GameProfileComponent, Hunger, InstanceHolder, PermissionLevel, - PlayerAbilities, TabList, - }, - mining::{self, MinePlugin}, - movement::{LastSentLookDirection, PhysicsState, PlayerMovePlugin}, - packet_handling::{ - login::{self, LoginSendPacketQueue}, - PacketHandlerPlugin, - }, - player::retroactively_add_game_profile_component, - raw_connection::RawConnection, - respawn::RespawnPlugin, - task_pool::TaskPoolPlugin, - Account, PlayerInfo, +use std::{ + collections::HashMap, + fmt::Debug, + io, + net::SocketAddr, + ops::Deref, + sync::Arc, + time::{Duration, Instant}, }; use azalea_auth::{game_profile::GameProfile, sessionserver::ClientSessionServerError}; @@ -68,15 +52,6 @@ use bevy_ecs::{ use bevy_time::TimePlugin; use derive_more::Deref; use parking_lot::{Mutex, RwLock}; -use std::{ - collections::HashMap, - fmt::Debug, - io, - net::SocketAddr, - ops::Deref, - sync::Arc, - time::{Duration, Instant}, -}; use thiserror::Error; use tokio::{ sync::{broadcast, mpsc}, @@ -85,6 +60,32 @@ use tokio::{ use tracing::{debug, error}; use uuid::Uuid; +use crate::{ + attack::{self, AttackPlugin}, + chat::ChatPlugin, + chunks::{ChunkBatchInfo, ChunkPlugin}, + configuration::ConfigurationPlugin, + disconnect::{DisconnectEvent, DisconnectPlugin}, + events::{Event, EventPlugin, LocalPlayerEvents}, + interact::{CurrentSequenceNumber, InteractPlugin}, + inventory::{Inventory, InventoryPlugin}, + local_player::{ + death_event, GameProfileComponent, Hunger, InstanceHolder, PermissionLevel, + PlayerAbilities, TabList, + }, + mining::{self, MinePlugin}, + movement::{LastSentLookDirection, PhysicsState, PlayerMovePlugin}, + packet_handling::{ + login::{self, LoginSendPacketQueue}, + PacketHandlerPlugin, + }, + player::retroactively_add_game_profile_component, + raw_connection::RawConnection, + respawn::RespawnPlugin, + task_pool::TaskPoolPlugin, + Account, PlayerInfo, +}; + /// `Client` has the things that a user interacting with the library will want. /// /// To make a new client, use either [`azalea::ClientBuilder`] or diff --git a/azalea-client/src/movement.rs b/azalea-client/src/movement.rs index 8905d0ef9..806f87341 100644 --- a/azalea-client/src/movement.rs +++ b/azalea-client/src/movement.rs @@ -1,5 +1,5 @@ -use crate::client::Client; -use crate::packet_handling::game::SendPacketEvent; +use std::backtrace::Backtrace; + use azalea_core::position::Vec3; use azalea_core::tick::GameTick; use azalea_entity::{metadata::Sprinting, Attributes, Jumping}; @@ -20,9 +20,11 @@ use bevy_ecs::{ component::Component, entity::Entity, event::EventReader, query::With, schedule::IntoSystemConfigs, system::Query, }; -use std::backtrace::Backtrace; use thiserror::Error; +use crate::client::Client; +use crate::packet_handling::game::SendPacketEvent; + #[derive(Error, Debug)] pub enum MovePlayerError { #[error("Player is not in world")] diff --git a/azalea-client/src/packet_handling/mod.rs b/azalea-client/src/packet_handling/mod.rs index 19de27eb5..eb8f1d47a 100644 --- a/azalea-client/src/packet_handling/mod.rs +++ b/azalea-client/src/packet_handling/mod.rs @@ -2,8 +2,6 @@ use azalea_entity::{metadata::Health, EntityUpdateSet}; use bevy_app::{App, First, Plugin, PreUpdate, Update}; use bevy_ecs::prelude::*; -use crate::{chat::ChatReceivedEvent, events::death_listener}; - use self::{ game::{ AddPlayerEvent, DeathEvent, InstanceLoadedEvent, KeepAliveEvent, RemovePlayerEvent, @@ -11,6 +9,7 @@ use self::{ }, login::{LoginPacketEvent, SendLoginPacketEvent}, }; +use crate::{chat::ChatReceivedEvent, events::death_listener}; pub mod configuration; pub mod game; diff --git a/azalea-client/src/ping.rs b/azalea-client/src/ping.rs index d06123923..ded1b5217 100755 --- a/azalea-client/src/ping.rs +++ b/azalea-client/src/ping.rs @@ -1,5 +1,7 @@ //! Ping Minecraft servers. +use std::io; + use azalea_protocol::{ connect::{Connection, ConnectionError, Proxy}, packets::{ @@ -16,7 +18,6 @@ use azalea_protocol::{ }, resolver, ServerAddress, }; -use std::io; use thiserror::Error; #[derive(Error, Debug)] diff --git a/azalea-core/src/delta.rs b/azalea-core/src/delta.rs index 646bcc955..2dd670052 100755 --- a/azalea-core/src/delta.rs +++ b/azalea-core/src/delta.rs @@ -1,6 +1,7 @@ -use crate::position::Vec3; pub use azalea_buf::McBuf; +use crate::position::Vec3; + pub trait PositionDeltaTrait { fn x(&self) -> f64; fn y(&self) -> f64; diff --git a/azalea-core/src/game_type.rs b/azalea-core/src/game_type.rs index 7c7a43a82..1e4940351 100644 --- a/azalea-core/src/game_type.rs +++ b/azalea-core/src/game_type.rs @@ -1,5 +1,6 @@ -use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufWritable}; use std::io::{Cursor, Write}; + +use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufWritable}; use tracing::debug; /// A Minecraft gamemode, like survival or creative. diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs index d87e21a71..de0276a32 100755 --- a/azalea-core/src/position.rs +++ b/azalea-core/src/position.rs @@ -3,10 +3,6 @@ //! The most common ones are [`Vec3`] and [`BlockPos`], which are usually used //! for entity positions and block positions, respectively. -use crate::resource_location::ResourceLocation; -use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable}; -#[cfg(feature = "serde")] -use serde::{Deserialize, Serialize}; use std::{ fmt, hash::Hash, @@ -15,6 +11,12 @@ use std::{ str::FromStr, }; +use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable}; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + +use crate::resource_location::ResourceLocation; + macro_rules! vec3_impl { ($name:ident, $type:ty) => { impl $name { diff --git a/azalea-core/src/registry_holder.rs b/azalea-core/src/registry_holder.rs index 119a13177..8b3dd4e6a 100644 --- a/azalea-core/src/registry_holder.rs +++ b/azalea-core/src/registry_holder.rs @@ -5,11 +5,12 @@ //! the game, including the types of chat messages, dimensions, and //! biomes. +use std::{collections::HashMap, io::Cursor}; + use simdnbt::{ owned::{NbtCompound, NbtTag}, Deserialize, FromNbtTag, Serialize, ToNbtTag, }; -use std::{collections::HashMap, io::Cursor}; use tracing::error; use crate::resource_location::ResourceLocation; diff --git a/azalea-core/src/resource_location.rs b/azalea-core/src/resource_location.rs index 2b0feb712..7e1e48fe0 100755 --- a/azalea-core/src/resource_location.rs +++ b/azalea-core/src/resource_location.rs @@ -1,15 +1,15 @@ //! A resource, like minecraft:stone -use azalea_buf::{BufReadError, McBufReadable, McBufWritable}; -use simdnbt::{owned::NbtTag, FromNbtTag, ToNbtTag}; use std::{ fmt, io::{Cursor, Write}, str::FromStr, }; +use azalea_buf::{BufReadError, McBufReadable, McBufWritable}; #[cfg(feature = "serde")] use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; +use simdnbt::{owned::NbtTag, FromNbtTag, ToNbtTag}; #[derive(Hash, Clone, PartialEq, Eq)] pub struct ResourceLocation { diff --git a/azalea-entity/src/data.rs b/azalea-entity/src/data.rs index 45c761e75..533bb49af 100755 --- a/azalea-entity/src/data.rs +++ b/azalea-entity/src/data.rs @@ -1,5 +1,7 @@ //! Define some types needed for entity metadata. +use std::io::{Cursor, Write}; + use azalea_buf::{ BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable, }; @@ -13,7 +15,6 @@ use bevy_ecs::component::Component; use derive_more::Deref; use enum_as_inner::EnumAsInner; use nohash_hasher::IntSet; -use std::io::{Cursor, Write}; use uuid::Uuid; use crate::particle::Particle; diff --git a/azalea-entity/src/lib.rs b/azalea-entity/src/lib.rs index 8761fa249..c009198c9 100644 --- a/azalea-entity/src/lib.rs +++ b/azalea-entity/src/lib.rs @@ -10,7 +10,11 @@ pub mod mining; pub mod particle; mod plugin; -use self::attributes::AttributeInstance; +use std::{ + fmt::Debug, + hash::{Hash, Hasher}, +}; + pub use attributes::Attributes; use azalea_block::BlockState; use azalea_core::{ @@ -25,12 +29,9 @@ pub use data::*; use derive_more::{Deref, DerefMut}; pub use dimensions::EntityDimensions; use plugin::indexing::EntityChunkPos; -use std::{ - fmt::Debug, - hash::{Hash, Hasher}, -}; use uuid::Uuid; +use self::attributes::AttributeInstance; pub use crate::plugin::*; pub fn move_relative( diff --git a/azalea-entity/src/metadata.rs b/azalea-entity/src/metadata.rs index 74bc571d5..2a6f996ed 100644 --- a/azalea-entity/src/metadata.rs +++ b/azalea-entity/src/metadata.rs @@ -3,12 +3,6 @@ // This file is generated from codegen/lib/code/entity.py. // Don't change it manually! -use crate::particle::Particle; - -use super::{ - ArmadilloStateKind, EntityDataItem, EntityDataValue, OptionalUnsignedInt, Pose, Quaternion, - Rotations, SnifferState, VillagerData, -}; use azalea_chat::FormattedText; use azalea_core::{ direction::Direction, @@ -20,6 +14,12 @@ use derive_more::{Deref, DerefMut}; use thiserror::Error; use uuid::Uuid; +use super::{ + ArmadilloStateKind, EntityDataItem, EntityDataValue, OptionalUnsignedInt, Pose, Quaternion, + Rotations, SnifferState, VillagerData, +}; +use crate::particle::Particle; + #[derive(Error, Debug)] pub enum UpdateMetadataError { #[error("Wrong type ({0:?})")] diff --git a/azalea-entity/src/plugin/indexing.rs b/azalea-entity/src/plugin/indexing.rs index f04f5ef28..c4879c4f0 100644 --- a/azalea-entity/src/plugin/indexing.rs +++ b/azalea-entity/src/plugin/indexing.rs @@ -1,5 +1,7 @@ //! Stuff related to entity indexes and keeping track of entities in the world. +use std::{collections::HashMap, fmt::Debug}; + use azalea_core::position::ChunkPos; use azalea_world::{Instance, InstanceContainer, InstanceName, MinecraftEntityId}; use bevy_ecs::{ @@ -10,13 +12,11 @@ use bevy_ecs::{ }; use derive_more::{Deref, DerefMut}; use nohash_hasher::IntMap; -use std::{collections::HashMap, fmt::Debug}; use tracing::{debug, warn}; use uuid::Uuid; -use crate::{EntityUuid, Position}; - use super::LoadedBy; +use crate::{EntityUuid, Position}; #[derive(Resource, Default)] pub struct EntityUuidIndex { diff --git a/azalea-entity/src/plugin/mod.rs b/azalea-entity/src/plugin/mod.rs index de18cbd3e..67763484b 100644 --- a/azalea-entity/src/plugin/mod.rs +++ b/azalea-entity/src/plugin/mod.rs @@ -9,6 +9,8 @@ use azalea_world::{InstanceContainer, InstanceName, MinecraftEntityId}; use bevy_app::{App, Plugin, PreUpdate, Update}; use bevy_ecs::prelude::*; use derive_more::{Deref, DerefMut}; +use indexing::EntityUuidIndex; +pub use relative_updates::RelativeEntityUpdate; use tracing::debug; use crate::{ @@ -16,9 +18,6 @@ use crate::{ Physics, Position, }; -use indexing::EntityUuidIndex; -pub use relative_updates::RelativeEntityUpdate; - /// A Bevy [`SystemSet`] for various types of entity updates. #[derive(SystemSet, Debug, Hash, Eq, PartialEq, Clone)] pub enum EntityUpdateSet { diff --git a/azalea-inventory/azalea-inventory-macros/src/location_enum.rs b/azalea-inventory/azalea-inventory-macros/src/location_enum.rs index 5f2086b77..615f07e5e 100644 --- a/azalea-inventory/azalea-inventory-macros/src/location_enum.rs +++ b/azalea-inventory/azalea-inventory-macros/src/location_enum.rs @@ -1,8 +1,9 @@ -use crate::{parse_macro::DeclareMenus, utils::to_pascal_case}; use proc_macro2::TokenStream; use quote::quote; use syn::Ident; +use crate::{parse_macro::DeclareMenus, utils::to_pascal_case}; + pub fn generate(input: &DeclareMenus) -> TokenStream { // pub enum MenuLocation { // Player(PlayerMenuLocation), diff --git a/azalea-inventory/azalea-inventory-macros/src/menu_enum.rs b/azalea-inventory/azalea-inventory-macros/src/menu_enum.rs index a9e4f4308..2b31f86c8 100644 --- a/azalea-inventory/azalea-inventory-macros/src/menu_enum.rs +++ b/azalea-inventory/azalea-inventory-macros/src/menu_enum.rs @@ -1,10 +1,11 @@ //! Generate the `enum menu` and nothing else. Implementations are in //! impl_menu.rs -use crate::parse_macro::{DeclareMenus, Field, Menu}; use proc_macro2::TokenStream; use quote::quote; +use crate::parse_macro::{DeclareMenus, Field, Menu}; + pub fn generate(input: &DeclareMenus) -> TokenStream { let mut variants = quote! {}; let mut player_fields = None; diff --git a/azalea-inventory/azalea-inventory-macros/src/menu_impl.rs b/azalea-inventory/azalea-inventory-macros/src/menu_impl.rs index ef8f86418..f3cc5d5ce 100644 --- a/azalea-inventory/azalea-inventory-macros/src/menu_impl.rs +++ b/azalea-inventory/azalea-inventory-macros/src/menu_impl.rs @@ -1,10 +1,11 @@ +use proc_macro2::TokenStream; +use quote::quote; +use syn::Ident; + use crate::{ parse_macro::{DeclareMenus, Menu}, utils::{to_pascal_case, to_snake_case}, }; -use proc_macro2::TokenStream; -use quote::quote; -use syn::Ident; pub fn generate(input: &DeclareMenus) -> TokenStream { let mut slot_mut_match_variants = quote! {}; diff --git a/azalea-inventory/src/slot.rs b/azalea-inventory/src/slot.rs index 9aa33263c..601c28e28 100644 --- a/azalea-inventory/src/slot.rs +++ b/azalea-inventory/src/slot.rs @@ -1,11 +1,12 @@ -use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable}; -use azalea_registry::DataComponentKind; use std::{ collections::HashMap, fmt, io::{Cursor, Write}, }; +use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable}; +use azalea_registry::DataComponentKind; + use crate::components::{self}; /// Either an item in an inventory or nothing. diff --git a/azalea-language/src/lib.rs b/azalea-language/src/lib.rs index ad9da43a3..7b6a6decf 100755 --- a/azalea-language/src/lib.rs +++ b/azalea-language/src/lib.rs @@ -1,8 +1,9 @@ #![doc = include_str!("../README.md")] -use once_cell::sync::Lazy; use std::collections::HashMap; +use once_cell::sync::Lazy; + pub static STORAGE: Lazy> = Lazy::new(|| serde_json::from_str(include_str!("en_us.json")).unwrap()); diff --git a/azalea-physics/src/collision/blocks.rs b/azalea-physics/src/collision/blocks.rs index 9394bbc70..01784963d 100644 --- a/azalea-physics/src/collision/blocks.rs +++ b/azalea-physics/src/collision/blocks.rs @@ -6,11 +6,12 @@ #![allow(clippy::explicit_auto_deref)] #![allow(clippy::redundant_closure)] -use super::VoxelShape; -use crate::collision::{self, Shapes}; use azalea_block::*; use once_cell::sync::Lazy; +use super::VoxelShape; +use crate::collision::{self, Shapes}; + pub trait BlockWithShape { fn shape(&self) -> &'static VoxelShape; /// Tells you whether the block has an empty shape. diff --git a/azalea-physics/src/collision/mergers.rs b/azalea-physics/src/collision/mergers.rs index c43412d12..85fd28263 100755 --- a/azalea-physics/src/collision/mergers.rs +++ b/azalea-physics/src/collision/mergers.rs @@ -1,8 +1,9 @@ use std::cmp::{self, Ordering}; -use super::CubePointRange; use azalea_core::math::{gcd, lcm, EPSILON}; +use super::CubePointRange; + #[derive(Debug)] pub enum IndexMerger { Identical { diff --git a/azalea-physics/src/collision/shape.rs b/azalea-physics/src/collision/shape.rs index edcfbf24d..fab8d8dc0 100755 --- a/azalea-physics/src/collision/shape.rs +++ b/azalea-physics/src/collision/shape.rs @@ -1,12 +1,14 @@ -use super::mergers::IndexMerger; -use crate::collision::{BitSetDiscreteVoxelShape, DiscreteVoxelShape, AABB}; +use std::{cmp, num::NonZeroU32, sync::LazyLock}; + use azalea_core::{ block_hit_result::BlockHitResult, direction::{Axis, AxisCycle, Direction}, math::{binary_search, EPSILON}, position::{BlockPos, Vec3}, }; -use std::{cmp, num::NonZeroU32, sync::LazyLock}; + +use super::mergers::IndexMerger; +use crate::collision::{BitSetDiscreteVoxelShape, DiscreteVoxelShape, AABB}; pub struct Shapes; diff --git a/azalea-physics/src/collision/world_collisions.rs b/azalea-physics/src/collision/world_collisions.rs index 9d25e9880..991721b2a 100644 --- a/azalea-physics/src/collision/world_collisions.rs +++ b/azalea-physics/src/collision/world_collisions.rs @@ -1,5 +1,5 @@ -use super::{Shapes, BLOCK_SHAPE}; -use crate::collision::{BlockWithShape, VoxelShape, AABB}; +use std::sync::Arc; + use azalea_block::BlockState; use azalea_core::{ cursor3d::{Cursor3d, CursorIterationType}, @@ -8,7 +8,9 @@ use azalea_core::{ }; use azalea_world::{Chunk, Instance}; use parking_lot::RwLock; -use std::sync::Arc; + +use super::{Shapes, BLOCK_SHAPE}; +use crate::collision::{BlockWithShape, VoxelShape, AABB}; pub fn get_block_collisions(world: &Instance, aabb: AABB) -> Vec { let mut state = BlockCollisionsState::new(world, aabb); diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs index 35f7f1d02..702603960 100644 --- a/azalea-physics/src/lib.rs +++ b/azalea-physics/src/lib.rs @@ -422,12 +422,13 @@ fn jump_boost_power() -> f64 { #[cfg(test)] mod tests { - use super::*; use azalea_core::{position::ChunkPos, resource_location::ResourceLocation}; use azalea_entity::{EntityBundle, EntityPlugin}; use azalea_world::{Chunk, MinecraftEntityId, PartialInstance}; use uuid::Uuid; + use super::*; + /// You need an app to spawn entities in the world and do updates. fn make_test_app() -> App { let mut app = App::new(); diff --git a/azalea-protocol/examples/handshake_proxy.rs b/azalea-protocol/examples/handshake_proxy.rs index 442db3869..8e675c588 100644 --- a/azalea-protocol/examples/handshake_proxy.rs +++ b/azalea-protocol/examples/handshake_proxy.rs @@ -1,6 +1,8 @@ //! A "simple" server that gets login information and proxies connections. //! After login all connections are encrypted and Azalea cannot read them. +use std::error::Error; + use azalea_protocol::{ connect::Connection, packets::{ @@ -22,7 +24,6 @@ use azalea_protocol::{ }; use futures::FutureExt; use once_cell::sync::Lazy; -use std::error::Error; use tokio::{ io::{self, AsyncWriteExt}, net::{TcpListener, TcpStream}, diff --git a/azalea-protocol/src/connect.rs b/azalea-protocol/src/connect.rs index 20a6f4039..0a449bfd7 100755 --- a/azalea-protocol/src/connect.rs +++ b/azalea-protocol/src/connect.rs @@ -1,5 +1,21 @@ //! Connect to remote servers/clients. +use std::fmt::Debug; +use std::io::Cursor; +use std::marker::PhantomData; +use std::net::SocketAddr; + +use azalea_auth::game_profile::GameProfile; +use azalea_auth::sessionserver::{ClientSessionServerError, ServerSessionServerError}; +use azalea_crypto::{Aes128CfbDec, Aes128CfbEnc}; +use bytes::BytesMut; +use thiserror::Error; +use tokio::io::{AsyncWriteExt, BufStream}; +use tokio::net::tcp::{OwnedReadHalf, OwnedWriteHalf, ReuniteError}; +use tokio::net::TcpStream; +use tracing::{error, info}; +use uuid::Uuid; + use crate::packets::configuration::{ ClientboundConfigurationPacket, ServerboundConfigurationPacket, }; @@ -11,20 +27,6 @@ use crate::packets::status::{ClientboundStatusPacket, ServerboundStatusPacket}; use crate::packets::ProtocolPacket; use crate::read::{deserialize_packet, read_raw_packet, try_read_raw_packet, ReadPacketError}; use crate::write::{serialize_packet, write_raw_packet}; -use azalea_auth::game_profile::GameProfile; -use azalea_auth::sessionserver::{ClientSessionServerError, ServerSessionServerError}; -use azalea_crypto::{Aes128CfbDec, Aes128CfbEnc}; -use bytes::BytesMut; -use std::fmt::Debug; -use std::io::Cursor; -use std::marker::PhantomData; -use std::net::SocketAddr; -use thiserror::Error; -use tokio::io::{AsyncWriteExt, BufStream}; -use tokio::net::tcp::{OwnedReadHalf, OwnedWriteHalf, ReuniteError}; -use tokio::net::TcpStream; -use tracing::{error, info}; -use uuid::Uuid; pub struct RawReadConnection { pub read_stream: OwnedReadHalf, diff --git a/azalea-protocol/src/lib.rs b/azalea-protocol/src/lib.rs index 8683233ed..0b2db1cf3 100644 --- a/azalea-protocol/src/lib.rs +++ b/azalea-protocol/src/lib.rs @@ -103,6 +103,9 @@ impl serde::Serialize for ServerAddress { mod tests { use std::io::Cursor; + use bytes::BytesMut; + use uuid::Uuid; + use crate::{ packets::{ game::serverbound_chat_packet::{LastSeenMessagesUpdate, ServerboundChatPacket}, @@ -111,8 +114,6 @@ mod tests { read::{compression_decoder, read_packet}, write::{compression_encoder, serialize_packet, write_packet}, }; - use bytes::BytesMut; - use uuid::Uuid; #[tokio::test] async fn test_hello_packet() { diff --git a/azalea-protocol/src/packets/configuration/clientbound_update_tags_packet.rs b/azalea-protocol/src/packets/configuration/clientbound_update_tags_packet.rs index 8ef42a76b..10f66e23f 100644 --- a/azalea-protocol/src/packets/configuration/clientbound_update_tags_packet.rs +++ b/azalea-protocol/src/packets/configuration/clientbound_update_tags_packet.rs @@ -1,10 +1,11 @@ +use std::io::Cursor; +use std::ops::Deref; +use std::{collections::HashMap, io::Write}; + use azalea_buf::{BufReadError, McBuf, McBufVarReadable, McBufVarWritable}; use azalea_buf::{McBufReadable, McBufWritable}; use azalea_core::resource_location::ResourceLocation; use azalea_protocol_macros::ClientboundConfigurationPacket; -use std::io::Cursor; -use std::ops::Deref; -use std::{collections::HashMap, io::Write}; #[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)] pub struct ClientboundUpdateTagsPacket { diff --git a/azalea-protocol/src/packets/configuration/serverbound_client_information_packet.rs b/azalea-protocol/src/packets/configuration/serverbound_client_information_packet.rs index d00c30ec4..b5fd6a355 100644 --- a/azalea-protocol/src/packets/configuration/serverbound_client_information_packet.rs +++ b/azalea-protocol/src/packets/configuration/serverbound_client_information_packet.rs @@ -146,9 +146,10 @@ impl McBufWritable for ModelCustomization { #[cfg(test)] mod tests { - use super::*; use std::io::Cursor; + use super::*; + #[test] fn test_client_information_packet() { { diff --git a/azalea-protocol/src/packets/game/clientbound_award_stats_packet.rs b/azalea-protocol/src/packets/game/clientbound_award_stats_packet.rs index aaec18494..32e2c8aa1 100755 --- a/azalea-protocol/src/packets/game/clientbound_award_stats_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_award_stats_packet.rs @@ -1,6 +1,7 @@ +use std::collections::HashMap; + use azalea_buf::McBuf; use azalea_protocol_macros::ClientboundGamePacket; -use std::collections::HashMap; #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] pub struct ClientboundAwardStatsPacket { diff --git a/azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs index 16fb6f613..65240edf4 100755 --- a/azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs @@ -1,11 +1,12 @@ +use std::io::Cursor; +use std::io::Write; + use azalea_buf::{ BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable, }; use azalea_chat::FormattedText; use azalea_core::bitset::FixedBitSet; use azalea_protocol_macros::ClientboundGamePacket; -use std::io::Cursor; -use std::io::Write; use uuid::Uuid; #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] diff --git a/azalea-protocol/src/packets/game/clientbound_command_suggestions_packet.rs b/azalea-protocol/src/packets/game/clientbound_command_suggestions_packet.rs index 13887331a..c9752ee95 100755 --- a/azalea-protocol/src/packets/game/clientbound_command_suggestions_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_command_suggestions_packet.rs @@ -11,10 +11,12 @@ pub struct ClientboundCommandSuggestionsPacket { #[cfg(test)] mod tests { - use super::*; + use std::io::Cursor; + use azalea_brigadier::{context::StringRange, suggestion::Suggestion}; use azalea_buf::{McBufReadable, McBufWritable}; - use std::io::Cursor; + + use super::*; #[test] fn test_suggestions() { diff --git a/azalea-protocol/src/packets/game/clientbound_commands_packet.rs b/azalea-protocol/src/packets/game/clientbound_commands_packet.rs index 822f62df5..10055e376 100755 --- a/azalea-protocol/src/packets/game/clientbound_commands_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_commands_packet.rs @@ -1,9 +1,10 @@ +use std::io::{Cursor, Write}; + use azalea_buf::{ BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable, }; use azalea_core::{bitset::FixedBitSet, resource_location::ResourceLocation}; use azalea_protocol_macros::ClientboundGamePacket; -use std::io::{Cursor, Write}; use tracing::warn; #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] diff --git a/azalea-protocol/src/packets/game/clientbound_delete_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_delete_chat_packet.rs index b8377afe0..eef9b561e 100755 --- a/azalea-protocol/src/packets/game/clientbound_delete_chat_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_delete_chat_packet.rs @@ -1,7 +1,8 @@ -use super::clientbound_player_chat_packet::PackedMessageSignature; use azalea_buf::McBuf; use azalea_protocol_macros::ClientboundGamePacket; +use super::clientbound_player_chat_packet::PackedMessageSignature; + #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] pub struct ClientboundDeleteChatPacket { pub signature: PackedMessageSignature, diff --git a/azalea-protocol/src/packets/game/clientbound_disguised_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_disguised_chat_packet.rs index e1ccff7e2..24e1a9927 100644 --- a/azalea-protocol/src/packets/game/clientbound_disguised_chat_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_disguised_chat_packet.rs @@ -1,4 +1,3 @@ -use super::clientbound_player_chat_packet::ChatTypeBound; use azalea_buf::McBuf; use azalea_chat::{ translatable_component::{StringOrComponent, TranslatableComponent}, @@ -6,6 +5,8 @@ use azalea_chat::{ }; use azalea_protocol_macros::ClientboundGamePacket; +use super::clientbound_player_chat_packet::ChatTypeBound; + // A disguised chat packet is basically the same as a normal // [`ClientboundPlayerChatPacket`], except that it doesn't have any of the chat // signing things. Vanilla servers use this when messages are sent from the diff --git a/azalea-protocol/src/packets/game/clientbound_login_packet.rs b/azalea-protocol/src/packets/game/clientbound_login_packet.rs index 20ed30f00..234439d5d 100755 --- a/azalea-protocol/src/packets/game/clientbound_login_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_login_packet.rs @@ -1,9 +1,9 @@ -use crate::packets::common::CommonPlayerSpawnInfo; - use azalea_buf::McBuf; use azalea_core::resource_location::ResourceLocation; use azalea_protocol_macros::ClientboundGamePacket; +use crate::packets::common::CommonPlayerSpawnInfo; + /// The first packet sent by the server to the client after login. /// /// This packet contains information about the state of the player, the diff --git a/azalea-protocol/src/packets/game/clientbound_open_book_packet.rs b/azalea-protocol/src/packets/game/clientbound_open_book_packet.rs index bf27d4e05..1b450b80e 100755 --- a/azalea-protocol/src/packets/game/clientbound_open_book_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_open_book_packet.rs @@ -1,7 +1,8 @@ -use super::serverbound_interact_packet::InteractionHand; use azalea_buf::McBuf; use azalea_protocol_macros::ClientboundGamePacket; +use super::serverbound_interact_packet::InteractionHand; + #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] pub struct ClientboundOpenBookPacket { pub hand: InteractionHand, diff --git a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs index edb5f949f..48c8b41a7 100755 --- a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs @@ -1,8 +1,9 @@ +use std::io::{Cursor, Write}; + use azalea_buf::{BufReadError, McBuf}; use azalea_buf::{McBufReadable, McBufWritable}; use azalea_core::bitset::FixedBitSet; use azalea_protocol_macros::ClientboundGamePacket; -use std::io::{Cursor, Write}; #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] pub struct ClientboundPlayerAbilitiesPacket { diff --git a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs index 31f18dde2..9cd20efcc 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs @@ -1,3 +1,5 @@ +use std::io::{Cursor, Write}; + use azalea_buf::{ BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable, }; @@ -8,7 +10,6 @@ use azalea_chat::{ use azalea_core::bitset::BitSet; use azalea_crypto::MessageSignature; use azalea_protocol_macros::ClientboundGamePacket; -use std::io::{Cursor, Write}; use uuid::Uuid; #[derive(Clone, Debug, McBuf, ClientboundGamePacket, PartialEq)] diff --git a/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs index 2024f082f..2b286e64b 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs @@ -1,3 +1,8 @@ +use std::{ + collections::HashMap, + io::{Cursor, Write}, +}; + use azalea_auth::game_profile::{GameProfile, ProfilePropertyValue}; use azalea_buf::{ BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable, @@ -5,10 +10,6 @@ use azalea_buf::{ use azalea_chat::FormattedText; use azalea_core::{bitset::FixedBitSet, game_type::GameMode}; use azalea_protocol_macros::ClientboundGamePacket; -use std::{ - collections::HashMap, - io::{Cursor, Write}, -}; use uuid::Uuid; use super::serverbound_chat_session_update_packet::RemoteChatSessionData; diff --git a/azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs index 00f3980ae..165d05dbf 100755 --- a/azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs @@ -1,8 +1,9 @@ +use std::io::Cursor; + use azalea_buf::{BufReadError, McBuf}; use azalea_buf::{McBufReadable, McBufWritable}; use azalea_inventory::ItemSlot; use azalea_protocol_macros::ClientboundGamePacket; -use std::io::Cursor; #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] pub struct ClientboundSetEquipmentPacket { diff --git a/azalea-protocol/src/packets/game/clientbound_set_player_team_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_player_team_packet.rs index 1a09aeb50..724b86aa8 100755 --- a/azalea-protocol/src/packets/game/clientbound_set_player_team_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_player_team_packet.rs @@ -1,7 +1,8 @@ +use std::io::{Cursor, Write}; + use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable}; use azalea_chat::{style::ChatFormatting, FormattedText}; use azalea_protocol_macros::ClientboundGamePacket; -use std::io::{Cursor, Write}; #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] pub struct ClientboundSetPlayerTeamPacket { diff --git a/azalea-protocol/src/packets/game/clientbound_stop_sound_packet.rs b/azalea-protocol/src/packets/game/clientbound_stop_sound_packet.rs index dd601da99..48c802371 100755 --- a/azalea-protocol/src/packets/game/clientbound_stop_sound_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_stop_sound_packet.rs @@ -1,7 +1,8 @@ +use std::io::{Cursor, Write}; + use azalea_buf::{BufReadError, McBufReadable, McBufWritable}; use azalea_core::{bitset::FixedBitSet, resource_location::ResourceLocation}; use azalea_protocol_macros::ClientboundGamePacket; -use std::io::{Cursor, Write}; use super::clientbound_sound_packet::SoundSource; diff --git a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs index 00a846e8f..5934b4436 100755 --- a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs @@ -1,10 +1,11 @@ +use std::collections::HashMap; +use std::io::Cursor; + use azalea_buf::McBuf; use azalea_chat::FormattedText; use azalea_core::resource_location::ResourceLocation; use azalea_inventory::ItemSlot; use azalea_protocol_macros::ClientboundGamePacket; -use std::collections::HashMap; -use std::io::Cursor; #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] pub struct ClientboundUpdateAdvancementsPacket { @@ -117,9 +118,10 @@ pub struct AdvancementHolder { #[cfg(test)] mod tests { - use super::*; use azalea_buf::{McBufReadable, McBufWritable}; + use super::*; + #[test] fn test() { let packet = ClientboundUpdateAdvancementsPacket { diff --git a/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs index e861e5752..bcdef64a9 100755 --- a/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs @@ -1,10 +1,11 @@ +use std::io::Cursor; +use std::ops::Deref; +use std::{collections::HashMap, io::Write}; + use azalea_buf::{BufReadError, McBuf, McBufVarReadable, McBufVarWritable}; use azalea_buf::{McBufReadable, McBufWritable}; use azalea_core::resource_location::ResourceLocation; use azalea_protocol_macros::ClientboundGamePacket; -use std::io::Cursor; -use std::ops::Deref; -use std::{collections::HashMap, io::Write}; #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] pub struct ClientboundUpdateTagsPacket { diff --git a/azalea-protocol/src/packets/game/serverbound_chat_command_signed_packet.rs b/azalea-protocol/src/packets/game/serverbound_chat_command_signed_packet.rs index bb814d550..f64b79ccf 100755 --- a/azalea-protocol/src/packets/game/serverbound_chat_command_signed_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_chat_command_signed_packet.rs @@ -1,8 +1,9 @@ -use super::serverbound_chat_packet::LastSeenMessagesUpdate; use azalea_buf::McBuf; use azalea_crypto::MessageSignature; use azalea_protocol_macros::ServerboundGamePacket; +use super::serverbound_chat_packet::LastSeenMessagesUpdate; + #[derive(Clone, Debug, McBuf, ServerboundGamePacket)] pub struct ServerboundChatCommandSignedPacket { pub command: String, diff --git a/azalea-protocol/src/packets/game/serverbound_container_click_packet.rs b/azalea-protocol/src/packets/game/serverbound_container_click_packet.rs index 119af2200..e29547205 100755 --- a/azalea-protocol/src/packets/game/serverbound_container_click_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_container_click_packet.rs @@ -1,7 +1,8 @@ +use std::collections::HashMap; + use azalea_buf::McBuf; use azalea_inventory::{operations::ClickType, ItemSlot}; use azalea_protocol_macros::ServerboundGamePacket; -use std::collections::HashMap; #[derive(Clone, Debug, McBuf, ServerboundGamePacket)] pub struct ServerboundContainerClickPacket { diff --git a/azalea-protocol/src/packets/game/serverbound_interact_packet.rs b/azalea-protocol/src/packets/game/serverbound_interact_packet.rs index 315134c99..e393920c9 100755 --- a/azalea-protocol/src/packets/game/serverbound_interact_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_interact_packet.rs @@ -1,8 +1,10 @@ -use crate::packets::BufReadError; +use std::io::{Cursor, Write}; + use azalea_buf::{McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable}; use azalea_core::position::Vec3; use azalea_protocol_macros::ServerboundGamePacket; -use std::io::{Cursor, Write}; + +use crate::packets::BufReadError; #[derive(Clone, Debug, McBuf, ServerboundGamePacket)] pub struct ServerboundInteractPacket { diff --git a/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs b/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs index 384f7dcc8..900d18247 100755 --- a/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs @@ -1,8 +1,10 @@ -use crate::packets::BufReadError; +use std::io::Cursor; + use azalea_buf::{McBufReadable, McBufWritable}; use azalea_core::bitset::FixedBitSet; use azalea_protocol_macros::ServerboundGamePacket; -use std::io::Cursor; + +use crate::packets::BufReadError; #[derive(Clone, Debug, ServerboundGamePacket)] pub struct ServerboundPlayerAbilitiesPacket { diff --git a/azalea-protocol/src/packets/game/serverbound_seen_advancements_packet.rs b/azalea-protocol/src/packets/game/serverbound_seen_advancements_packet.rs index fb15293b9..54fd4cc9f 100755 --- a/azalea-protocol/src/packets/game/serverbound_seen_advancements_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_seen_advancements_packet.rs @@ -1,8 +1,10 @@ -use crate::packets::BufReadError; +use std::io::Cursor; + use azalea_buf::{McBuf, McBufReadable, McBufWritable}; use azalea_core::resource_location::ResourceLocation; use azalea_protocol_macros::ServerboundGamePacket; -use std::io::Cursor; + +use crate::packets::BufReadError; #[derive(Clone, Debug, ServerboundGamePacket)] pub struct ServerboundSeenAdvancementsPacket { diff --git a/azalea-protocol/src/packets/game/serverbound_set_command_block_packet.rs b/azalea-protocol/src/packets/game/serverbound_set_command_block_packet.rs index c5feb2138..db6557fd3 100755 --- a/azalea-protocol/src/packets/game/serverbound_set_command_block_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_set_command_block_packet.rs @@ -1,8 +1,10 @@ -use crate::packets::McBufWritable; +use std::io::Cursor; + use azalea_buf::{BufReadError, McBuf, McBufReadable}; use azalea_core::{bitset::FixedBitSet, position::BlockPos}; use azalea_protocol_macros::ServerboundGamePacket; -use std::io::Cursor; + +use crate::packets::McBufWritable; #[derive(Clone, Debug, ServerboundGamePacket)] pub struct ServerboundSetCommandBlockPacket { diff --git a/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs b/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs index a4b6f7262..33a823112 100755 --- a/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs @@ -1,12 +1,14 @@ -use crate::packets::BufReadError; -use crate::packets::McBufWritable; +use std::io::Cursor; +use std::io::Write; + use azalea_buf::McBuf; use azalea_buf::McBufReadable; use azalea_core::position::BlockPos; use azalea_core::resource_location::ResourceLocation; use azalea_protocol_macros::ServerboundGamePacket; -use std::io::Cursor; -use std::io::Write; + +use crate::packets::BufReadError; +use crate::packets::McBufWritable; #[derive(Clone, Debug, McBuf, ServerboundGamePacket)] pub struct ServerboundSetJigsawBlockPacket { diff --git a/azalea-protocol/src/packets/game/serverbound_set_structure_block_packet.rs b/azalea-protocol/src/packets/game/serverbound_set_structure_block_packet.rs index c10966c98..c2872812b 100755 --- a/azalea-protocol/src/packets/game/serverbound_set_structure_block_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_set_structure_block_packet.rs @@ -1,9 +1,11 @@ -use crate::packets::BufReadError; +use std::io::{Cursor, Write}; + use azalea_buf::McBuf; use azalea_buf::{McBufReadable, McBufWritable}; use azalea_core::{bitset::FixedBitSet, position::BlockPos}; use azalea_protocol_macros::ServerboundGamePacket; -use std::io::{Cursor, Write}; + +use crate::packets::BufReadError; #[derive(Clone, Debug, McBuf, ServerboundGamePacket)] pub struct ServerboundSetStructureBlockPacket { diff --git a/azalea-protocol/src/packets/game/serverbound_swing_packet.rs b/azalea-protocol/src/packets/game/serverbound_swing_packet.rs index a31908438..53b4a6c18 100755 --- a/azalea-protocol/src/packets/game/serverbound_swing_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_swing_packet.rs @@ -1,7 +1,8 @@ -use crate::packets::game::serverbound_interact_packet::InteractionHand; use azalea_buf::McBuf; use azalea_protocol_macros::ServerboundGamePacket; +use crate::packets::game::serverbound_interact_packet::InteractionHand; + #[derive(Clone, Debug, McBuf, ServerboundGamePacket)] pub struct ServerboundSwingPacket { pub hand: InteractionHand, diff --git a/azalea-protocol/src/packets/game/serverbound_use_item_on_packet.rs b/azalea-protocol/src/packets/game/serverbound_use_item_on_packet.rs index 2d4711146..660483271 100755 --- a/azalea-protocol/src/packets/game/serverbound_use_item_on_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_use_item_on_packet.rs @@ -1,11 +1,13 @@ -use crate::packets::game::serverbound_interact_packet::InteractionHand; +use std::io::{Cursor, Write}; + use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable}; use azalea_core::{ direction::Direction, position::{BlockPos, Vec3}, }; use azalea_protocol_macros::ServerboundGamePacket; -use std::io::{Cursor, Write}; + +use crate::packets::game::serverbound_interact_packet::InteractionHand; #[derive(Clone, Debug, McBuf, ServerboundGamePacket)] pub struct ServerboundUseItemOnPacket { diff --git a/azalea-protocol/src/packets/game/serverbound_use_item_packet.rs b/azalea-protocol/src/packets/game/serverbound_use_item_packet.rs index 3129244ab..b9f12f238 100755 --- a/azalea-protocol/src/packets/game/serverbound_use_item_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_use_item_packet.rs @@ -1,7 +1,8 @@ -use crate::packets::game::serverbound_interact_packet::InteractionHand; use azalea_buf::McBuf; use azalea_protocol_macros::ServerboundGamePacket; +use crate::packets::game::serverbound_interact_packet::InteractionHand; + #[derive(Clone, Debug, McBuf, ServerboundGamePacket)] pub struct ServerboundUseItemPacket { pub hand: InteractionHand, diff --git a/azalea-protocol/src/packets/handshaking/client_intention_packet.rs b/azalea-protocol/src/packets/handshaking/client_intention_packet.rs index 82be621a3..c0b694c8a 100755 --- a/azalea-protocol/src/packets/handshaking/client_intention_packet.rs +++ b/azalea-protocol/src/packets/handshaking/client_intention_packet.rs @@ -1,7 +1,9 @@ -use crate::packets::ClientIntention; +use std::hash::Hash; + use azalea_buf::McBuf; use azalea_protocol_macros::ServerboundHandshakePacket; -use std::hash::Hash; + +use crate::packets::ClientIntention; #[derive(Hash, Clone, Debug, McBuf, ServerboundHandshakePacket)] pub struct ClientIntentionPacket { diff --git a/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs b/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs index 50d2e2d35..75993fd9d 100755 --- a/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs @@ -1,7 +1,8 @@ +use std::hash::Hash; + use azalea_buf::{McBuf, UnsizedByteArray}; use azalea_core::resource_location::ResourceLocation; use azalea_protocol_macros::ClientboundLoginPacket; -use std::hash::Hash; #[derive(Hash, Clone, Debug, McBuf, ClientboundLoginPacket)] pub struct ClientboundCustomQueryPacket { diff --git a/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs b/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs index 6976298ae..4b8fb0c8b 100755 --- a/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs @@ -1,6 +1,7 @@ +use std::hash::Hash; + use azalea_buf::McBuf; use azalea_protocol_macros::ClientboundLoginPacket; -use std::hash::Hash; #[derive(Hash, Clone, Debug, ClientboundLoginPacket, McBuf)] pub struct ClientboundLoginCompressionPacket { diff --git a/azalea-protocol/src/packets/login/serverbound_custom_query_answer_packet.rs b/azalea-protocol/src/packets/login/serverbound_custom_query_answer_packet.rs index 7eb8b28f5..fe9460a24 100644 --- a/azalea-protocol/src/packets/login/serverbound_custom_query_answer_packet.rs +++ b/azalea-protocol/src/packets/login/serverbound_custom_query_answer_packet.rs @@ -1,6 +1,7 @@ +use std::hash::Hash; + use azalea_buf::{McBuf, UnsizedByteArray}; use azalea_protocol_macros::ServerboundLoginPacket; -use std::hash::Hash; #[derive(Hash, Clone, Debug, McBuf, ServerboundLoginPacket)] pub struct ServerboundCustomQueryAnswerPacket { diff --git a/azalea-protocol/src/packets/login/serverbound_hello_packet.rs b/azalea-protocol/src/packets/login/serverbound_hello_packet.rs index d46fe3087..51ff18306 100755 --- a/azalea-protocol/src/packets/login/serverbound_hello_packet.rs +++ b/azalea-protocol/src/packets/login/serverbound_hello_packet.rs @@ -12,9 +12,10 @@ pub struct ServerboundHelloPacket { mod tests { use std::io::Cursor; - use super::*; use azalea_buf::{McBufReadable, McBufWritable}; + use super::*; + #[test] fn test_read_write() { let packet = ServerboundHelloPacket { diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs index 6cec015fe..1dabe1751 100755 --- a/azalea-protocol/src/packets/mod.rs +++ b/azalea-protocol/src/packets/mod.rs @@ -5,10 +5,12 @@ pub mod handshaking; pub mod login; pub mod status; -use crate::read::ReadPacketError; -use azalea_buf::{BufReadError, McBufVarReadable, McBufVarWritable, McBufWritable}; use std::io::{Cursor, Write}; +use azalea_buf::{BufReadError, McBufVarReadable, McBufVarWritable, McBufWritable}; + +use crate::read::ReadPacketError; + // TODO: rename the packet files to just like clientbound_add_entity instead of // clientbound_add_entity_packet diff --git a/azalea-protocol/src/packets/status/clientbound_status_response_packet.rs b/azalea-protocol/src/packets/status/clientbound_status_response_packet.rs index 332bfdc44..1316894ed 100755 --- a/azalea-protocol/src/packets/status/clientbound_status_response_packet.rs +++ b/azalea-protocol/src/packets/status/clientbound_status_response_packet.rs @@ -1,9 +1,10 @@ +use std::io::{Cursor, Write}; + use azalea_buf::{BufReadError, McBufReadable, McBufWritable}; use azalea_chat::FormattedText; use azalea_protocol_macros::ClientboundStatusPacket; use serde::{Deserialize, Serialize}; use serde_json::value::Serializer; -use std::io::{Cursor, Write}; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Version { diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs index 434cc74a9..558e1072e 100755 --- a/azalea-protocol/src/read.rs +++ b/azalea-protocol/src/read.rs @@ -1,6 +1,11 @@ //! Read packets from a stream. -use crate::packets::ProtocolPacket; +use std::backtrace::Backtrace; +use std::{ + fmt::Debug, + io::{Cursor, Read}, +}; + use azalea_buf::BufReadError; use azalea_buf::McBufVarReadable; use azalea_crypto::Aes128CfbDec; @@ -9,16 +14,13 @@ use bytes::BytesMut; use flate2::read::ZlibDecoder; use futures::StreamExt; use futures_lite::future; -use std::backtrace::Backtrace; -use std::{ - fmt::Debug, - io::{Cursor, Read}, -}; use thiserror::Error; use tokio::io::AsyncRead; use tokio_util::codec::{BytesCodec, FramedRead}; use tracing::trace; +use crate::packets::ProtocolPacket; + #[derive(Error, Debug)] pub enum ReadPacketError { #[error("Error reading packet {packet_name} (id {packet_id}): {source}")] diff --git a/azalea-protocol/src/resolver.rs b/azalea-protocol/src/resolver.rs index af59be72c..43f15dce6 100755 --- a/azalea-protocol/src/resolver.rs +++ b/azalea-protocol/src/resolver.rs @@ -1,14 +1,16 @@ //! Resolve IPs from hostnames. -use crate::ServerAddress; -use async_recursion::async_recursion; use std::net::{IpAddr, SocketAddr}; + +use async_recursion::async_recursion; use thiserror::Error; use trust_dns_resolver::{ config::{ResolverConfig, ResolverOpts}, Name, TokioAsyncResolver, }; +use crate::ServerAddress; + #[derive(Error, Debug)] pub enum ResolverError { #[error("No SRV record found")] diff --git a/azalea-protocol/src/write.rs b/azalea-protocol/src/write.rs index 532f46518..0ec4308bb 100755 --- a/azalea-protocol/src/write.rs +++ b/azalea-protocol/src/write.rs @@ -1,14 +1,16 @@ //! Write packets to a stream. -use crate::{packets::ProtocolPacket, read::MAXIMUM_UNCOMPRESSED_LENGTH}; +use std::{fmt::Debug, io::Read}; + use azalea_buf::McBufVarWritable; use azalea_crypto::Aes128CfbEnc; use flate2::{bufread::ZlibEncoder, Compression}; -use std::{fmt::Debug, io::Read}; use thiserror::Error; use tokio::io::{AsyncWrite, AsyncWriteExt}; use tracing::trace; +use crate::{packets::ProtocolPacket, read::MAXIMUM_UNCOMPRESSED_LENGTH}; + /// Prepend the length of the packet to it. fn frame_prepender(mut data: Vec) -> Result, std::io::Error> { let mut buf = Vec::new(); diff --git a/azalea-registry/src/extra.rs b/azalea-registry/src/extra.rs index 795336529..d5816e3b7 100644 --- a/azalea-registry/src/extra.rs +++ b/azalea-registry/src/extra.rs @@ -2,9 +2,10 @@ //! you should be relying on those if possible, but these are provided for your //! convenience anyways. -use crate::Registry; use azalea_registry_macros::registry; +use crate::Registry; + registry! { enum WolfVariant { Pale => "minecraft:wolf", diff --git a/azalea-registry/src/lib.rs b/azalea-registry/src/lib.rs index e66ccabc1..e4287b1c1 100755 --- a/azalea-registry/src/lib.rs +++ b/azalea-registry/src/lib.rs @@ -13,7 +13,6 @@ use std::io::{Cursor, Write}; use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable}; use azalea_registry_macros::registry; - pub use extra::*; pub trait Registry: McBufReadable + McBufWritable diff --git a/azalea-world/src/chunk_storage.rs b/azalea-world/src/chunk_storage.rs index f1239f8ac..5f8b89518 100755 --- a/azalea-world/src/chunk_storage.rs +++ b/azalea-world/src/chunk_storage.rs @@ -1,13 +1,3 @@ -use crate::heightmap::Heightmap; -use crate::heightmap::HeightmapKind; -use crate::palette::PalettedContainer; -use crate::palette::PalettedContainerKind; -use azalea_block::BlockState; -use azalea_buf::{BufReadError, McBufReadable, McBufWritable}; -use azalea_core::position::{BlockPos, ChunkBlockPos, ChunkPos, ChunkSectionBlockPos}; -use nohash_hasher::IntMap; -use parking_lot::RwLock; -use simdnbt::owned::NbtCompound; use std::collections::hash_map::Entry; use std::str::FromStr; use std::{ @@ -16,8 +6,20 @@ use std::{ io::{Cursor, Write}, sync::{Arc, Weak}, }; + +use azalea_block::BlockState; +use azalea_buf::{BufReadError, McBufReadable, McBufWritable}; +use azalea_core::position::{BlockPos, ChunkBlockPos, ChunkPos, ChunkSectionBlockPos}; +use nohash_hasher::IntMap; +use parking_lot::RwLock; +use simdnbt::owned::NbtCompound; use tracing::{debug, trace, warn}; +use crate::heightmap::Heightmap; +use crate::heightmap::HeightmapKind; +use crate::palette::PalettedContainer; +use crate::palette::PalettedContainerKind; + const SECTION_HEIGHT: u32 = 16; /// An efficient storage of chunks for a client that has a limited render diff --git a/azalea-world/src/container.rs b/azalea-world/src/container.rs index 69b8f9084..0b3a13fd0 100644 --- a/azalea-world/src/container.rs +++ b/azalea-world/src/container.rs @@ -1,13 +1,14 @@ +use std::{ + collections::HashMap, + sync::{Arc, Weak}, +}; + use azalea_core::{registry_holder::RegistryHolder, resource_location::ResourceLocation}; use bevy_ecs::{component::Component, system::Resource}; use derive_more::{Deref, DerefMut}; use nohash_hasher::IntMap; use parking_lot::RwLock; use rustc_hash::FxHashMap; -use std::{ - collections::HashMap, - sync::{Arc, Weak}, -}; use tracing::error; use crate::{ChunkStorage, Instance}; diff --git a/azalea-world/src/find_blocks.rs b/azalea-world/src/find_blocks.rs index 2d2c6d7ac..39f57eec7 100644 --- a/azalea-world/src/find_blocks.rs +++ b/azalea-world/src/find_blocks.rs @@ -246,9 +246,8 @@ impl<'a> Iterator for FindBlocks<'a> { mod tests { use azalea_registry::Block; - use crate::{Chunk, PartialChunkStorage}; - use super::*; + use crate::{Chunk, PartialChunkStorage}; #[test] fn find_block() { diff --git a/azalea-world/src/palette.rs b/azalea-world/src/palette.rs index 2b3cdc536..27e017c40 100755 --- a/azalea-world/src/palette.rs +++ b/azalea-world/src/palette.rs @@ -1,6 +1,7 @@ +use std::io::{Cursor, Write}; + use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable}; use azalea_core::math; -use std::io::{Cursor, Write}; use tracing::warn; use crate::BitStorage; diff --git a/azalea-world/src/world.rs b/azalea-world/src/world.rs index 84a5857ce..066981e56 100644 --- a/azalea-world/src/world.rs +++ b/azalea-world/src/world.rs @@ -1,15 +1,17 @@ -use crate::{ChunkStorage, PartialChunkStorage}; +use std::fmt::Formatter; +use std::{ + collections::{HashMap, HashSet}, + fmt::Debug, +}; + use azalea_block::{BlockState, FluidState}; use azalea_core::position::{BlockPos, ChunkPos}; use azalea_core::registry_holder::RegistryHolder; use bevy_ecs::{component::Component, entity::Entity}; use derive_more::{Deref, DerefMut}; use nohash_hasher::IntMap; -use std::fmt::Formatter; -use std::{ - collections::{HashMap, HashSet}, - fmt::Debug, -}; + +use crate::{ChunkStorage, PartialChunkStorage}; /// PartialInstances are usually owned by clients, and hold strong references to /// chunks and entities in [`Instance`]s. diff --git a/azalea/examples/steal.rs b/azalea/examples/steal.rs index c6ab46397..b0586f19c 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 4957533f2..3c66fefa9 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>) { commands.register( diff --git a/azalea/examples/testbot/main.rs b/azalea/examples/testbot/main.rs index 6795e6cf5..e7d68d5e8 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 02953d9e8..c9765c77e 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 07b3e0f5b..43ec4821a 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 529bb251a..eee0f8802 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 c9283b6b3..980210aea 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 c78b6ef1b..5e412f52c 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 = Box BoxFuture<'static, Result<(), anyhow::Error>>>; pub type HandleFn = fn(Client, azalea_client::Event, S) -> Fut; diff --git a/azalea/src/pathfinder/mining.rs b/azalea/src/pathfinder/mining.rs index 1bc08c436..31b37b49e 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>, diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index cb6ba2bbf..1f864526b 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 54a6dc6a8..bb931caf9 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 bb10b1928..289741322 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; pub type SuccessorsFn = fn(&mut PathfinderCtx, BlockPos); diff --git a/azalea/src/pathfinder/moves/parkour.rs b/azalea/src/pathfinder/moves/parkour.rs index 66f02197d..0f279dcaf 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 2d8590266..3a004f658 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 b4d66aaf9..d1442b104 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 7425293bf..cf01c60b3 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 451d887c6..8c2d23f63 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; diff --git a/rustfmt.toml b/rustfmt.toml index b2715b268..35672d06b 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1 +1,2 @@ wrap_comments = true +group_imports = "StdExternalCrate"