diff options
| -rw-r--r-- | azalea-client/src/account/microsoft.rs | 6 | ||||
| -rw-r--r-- | azalea-client/src/local_player.rs | 2 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/game/events.rs | 2 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/game/mod.rs | 10 | ||||
| -rw-r--r-- | azalea-registry/azalea-registry-macros/src/lib.rs | 4 | ||||
| -rw-r--r-- | azalea-registry/src/tags/mod.rs | 4 | ||||
| -rw-r--r-- | azalea/build.rs | 11 | ||||
| -rw-r--r-- | azalea/src/pathfinder/mod.rs | 12 |
8 files changed, 38 insertions, 13 deletions
diff --git a/azalea-client/src/account/microsoft.rs b/azalea-client/src/account/microsoft.rs index 7546ac13..37ca6f05 100644 --- a/azalea-client/src/account/microsoft.rs +++ b/azalea-client/src/account/microsoft.rs @@ -1,8 +1,7 @@ use std::path::PathBuf; use azalea_auth::{ - AccessTokenResponse, - AuthOpts, + AccessTokenResponse, AuthOpts, certs::Certificates, sessionserver::{self, ClientSessionServerError, SessionServerJoinOpts}, }; @@ -117,7 +116,8 @@ impl AccountTrait for MicrosoftAccount { } fn refresh(&self) -> BoxFuture<'_, Result<(), azalea_auth::AuthError>> { Box::pin(async { - let new_account = MicrosoftAccount::new(&self.cache_key, self.auth_opts.clone()).await?; + let new_account = + MicrosoftAccount::new(&self.cache_key, self.auth_opts.clone()).await?; let new_access_token = new_account.access_token().unwrap(); *self.access_token.lock() = new_access_token; Ok(()) diff --git a/azalea-client/src/local_player.rs b/azalea-client/src/local_player.rs index 1a2f059f..e19ffd1f 100644 --- a/azalea-client/src/local_player.rs +++ b/azalea-client/src/local_player.rs @@ -7,7 +7,7 @@ use derive_more::{Deref, DerefMut}; use parking_lot::RwLock; use uuid::Uuid; -use crate::{player::PlayerInfo, ClientInformation}; +use crate::{ClientInformation, player::PlayerInfo}; /// A component that keeps strong references to our [`PartialWorld`] and /// [`World`] for local players. diff --git a/azalea-client/src/plugins/packet/game/events.rs b/azalea-client/src/plugins/packet/game/events.rs index 4a919382..bc070ec8 100644 --- a/azalea-client/src/plugins/packet/game/events.rs +++ b/azalea-client/src/plugins/packet/game/events.rs @@ -2,8 +2,8 @@ use std::sync::{Arc, Weak}; use azalea_chat::FormattedText; use azalea_protocol::packets::{ - game::{ClientboundGamePacket, ClientboundPlayerCombatKill, ServerboundGamePacket}, Packet, + game::{ClientboundGamePacket, ClientboundPlayerCombatKill, ServerboundGamePacket}, }; use azalea_world::{World, WorldName}; use bevy_ecs::prelude::*; diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs index 1fdceddf..9a1c022b 100644 --- a/azalea-client/src/plugins/packet/game/mod.rs +++ b/azalea-client/src/plugins/packet/game/mod.rs @@ -8,15 +8,15 @@ use azalea_core::{ position::{ChunkPos, Vec3}, }; use azalea_entity::{ - indexing::{EntityIdIndex, EntityUuidIndex}, - inventory::Inventory, - metadata::{apply_metadata, Health}, ActiveEffects, Dead, EntityBundle, EntityKindComponent, HasClientLoaded, LoadedBy, LocalEntity, LookDirection, Physics, PlayerAbilities, Position, RelativeEntityUpdate, + indexing::{EntityIdIndex, EntityUuidIndex}, + inventory::Inventory, + metadata::{Health, apply_metadata}, }; use azalea_protocol::{ common::movements::MoveFlags, - packets::{game::*, ConnectionProtocol}, + packets::{ConnectionProtocol, game::*}, }; use azalea_registry::builtin::EntityKind; use azalea_world::{PartialWorld, WorldName, Worlds}; @@ -25,6 +25,7 @@ pub use events::*; use tracing::{debug, error, trace, warn}; use crate::{ + ClientInformation, block_update::QueuedServerBlockUpdates, chat::{ChatPacket, ChatReceivedEvent}, chunks, @@ -38,7 +39,6 @@ use crate::{ packet::{as_system, declare_packet_handlers}, player::{GameProfileComponent, PlayerInfo}, tick_counter::TicksConnected, - ClientInformation, }; pub fn process_packet(ecs: &mut World, player: Entity, packet: &ClientboundGamePacket) { diff --git a/azalea-registry/azalea-registry-macros/src/lib.rs b/azalea-registry/azalea-registry-macros/src/lib.rs index c4caa55e..6c7d4840 100644 --- a/azalea-registry/azalea-registry-macros/src/lib.rs +++ b/azalea-registry/azalea-registry-macros/src/lib.rs @@ -153,6 +153,8 @@ pub fn registry(input: TokenStream) -> TokenStream { }); } generated.extend(quote! { + /// Convert the value to a stringified identifier, formatted like + /// `"minecraft:air"`. impl std::fmt::Display for #name { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { @@ -170,6 +172,8 @@ pub fn registry(input: TokenStream) -> TokenStream { } } } + /// Parse the value from a stringified identifier, formatted like + /// either `"air"` or `"minecraft:air"`. impl std::str::FromStr for #name { type Err = (); diff --git a/azalea-registry/src/tags/mod.rs b/azalea-registry/src/tags/mod.rs index 640d119b..f2cb6fe3 100644 --- a/azalea-registry/src/tags/mod.rs +++ b/azalea-registry/src/tags/mod.rs @@ -41,9 +41,9 @@ impl<R: Registry + 'static> RegistryTag<R> { // TODO: tune this number; when does binary search actually start making a // difference? if self.entries.len() > 64 { - self.linear_search_find(value) - } else { self.binary_search_find(value) + } else { + self.linear_search_find(value) } } fn linear_search_find(&self, value: &R) -> Option<usize> { diff --git a/azalea/build.rs b/azalea/build.rs index faed1365..9dd6b738 100644 --- a/azalea/build.rs +++ b/azalea/build.rs @@ -1,6 +1,17 @@ use std::{env, process::Command}; fn main() { + check_nightly(); + + // save the optimization level, used by the pathfinder to warn if optimizations + // are off + println!( + "cargo::rustc-env=OPT_LEVEL={}", + env::var("OPT_LEVEL").unwrap() + ); +} + +fn check_nightly() { // If using `rustup`, check the toolchain via `RUSTUP_TOOLCHAIN` if let Ok(toolchain) = env::var("RUSTUP_TOOLCHAIN") { if toolchain.contains("nightly") { diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index 8df04b14..6f1a0d8a 100644 --- a/azalea/src/pathfinder/mod.rs +++ b/azalea/src/pathfinder/mod.rs @@ -32,7 +32,7 @@ use std::{ collections::VecDeque, sync::{ Arc, - atomic::{self, AtomicUsize}, + atomic::{self, AtomicBool, AtomicUsize}, }, thread, time::{Duration, Instant}, @@ -306,6 +306,16 @@ pub fn goto_listener( continue; }; + // this env variable is set from the build.rs + if env!("OPT_LEVEL") == "0" { + static WARNED: AtomicBool = AtomicBool::new(false); + if !WARNED.swap(true, atomic::Ordering::Relaxed) { + warn!( + "Azalea was compiled with no optimizations, which may result in significantly reduced pathfinding performance. Consider following the steps at https://azalea.matdoes.dev/azalea/#optimization for faster performance in debug mode." + ) + } + } + let cur_pos = player_pos_to_block_pos(**position); if event.goal.success(cur_pos) { |
