Skip to content

Commit 6c0be69

Browse files
committed
warn if pathfinder is running without optimizations, and other minor fixes
1 parent b0d0bd1 commit 6c0be69

File tree

8 files changed

+38
-13
lines changed

8 files changed

+38
-13
lines changed

azalea-client/src/account/microsoft.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use std::path::PathBuf;
22

33
use azalea_auth::{
4-
AccessTokenResponse,
5-
AuthOpts,
4+
AccessTokenResponse, AuthOpts,
65
certs::Certificates,
76
sessionserver::{self, ClientSessionServerError, SessionServerJoinOpts},
87
};
@@ -117,7 +116,8 @@ impl AccountTrait for MicrosoftAccount {
117116
}
118117
fn refresh(&self) -> BoxFuture<'_, Result<(), azalea_auth::AuthError>> {
119118
Box::pin(async {
120-
let new_account = MicrosoftAccount::new(&self.cache_key, self.auth_opts.clone()).await?;
119+
let new_account =
120+
MicrosoftAccount::new(&self.cache_key, self.auth_opts.clone()).await?;
121121
let new_access_token = new_account.access_token().unwrap();
122122
*self.access_token.lock() = new_access_token;
123123
Ok(())

azalea-client/src/local_player.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use derive_more::{Deref, DerefMut};
77
use parking_lot::RwLock;
88
use uuid::Uuid;
99

10-
use crate::{player::PlayerInfo, ClientInformation};
10+
use crate::{ClientInformation, player::PlayerInfo};
1111

1212
/// A component that keeps strong references to our [`PartialWorld`] and
1313
/// [`World`] for local players.

azalea-client/src/plugins/packet/game/events.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::sync::{Arc, Weak};
22

33
use azalea_chat::FormattedText;
44
use azalea_protocol::packets::{
5-
game::{ClientboundGamePacket, ClientboundPlayerCombatKill, ServerboundGamePacket},
65
Packet,
6+
game::{ClientboundGamePacket, ClientboundPlayerCombatKill, ServerboundGamePacket},
77
};
88
use azalea_world::{World, WorldName};
99
use bevy_ecs::prelude::*;

azalea-client/src/plugins/packet/game/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ use azalea_core::{
88
position::{ChunkPos, Vec3},
99
};
1010
use azalea_entity::{
11-
indexing::{EntityIdIndex, EntityUuidIndex},
12-
inventory::Inventory,
13-
metadata::{apply_metadata, Health},
1411
ActiveEffects, Dead, EntityBundle, EntityKindComponent, HasClientLoaded, LoadedBy, LocalEntity,
1512
LookDirection, Physics, PlayerAbilities, Position, RelativeEntityUpdate,
13+
indexing::{EntityIdIndex, EntityUuidIndex},
14+
inventory::Inventory,
15+
metadata::{Health, apply_metadata},
1616
};
1717
use azalea_protocol::{
1818
common::movements::MoveFlags,
19-
packets::{game::*, ConnectionProtocol},
19+
packets::{ConnectionProtocol, game::*},
2020
};
2121
use azalea_registry::builtin::EntityKind;
2222
use azalea_world::{PartialWorld, WorldName, Worlds};
@@ -25,6 +25,7 @@ pub use events::*;
2525
use tracing::{debug, error, trace, warn};
2626

2727
use crate::{
28+
ClientInformation,
2829
block_update::QueuedServerBlockUpdates,
2930
chat::{ChatPacket, ChatReceivedEvent},
3031
chunks,
@@ -38,7 +39,6 @@ use crate::{
3839
packet::{as_system, declare_packet_handlers},
3940
player::{GameProfileComponent, PlayerInfo},
4041
tick_counter::TicksConnected,
41-
ClientInformation,
4242
};
4343

4444
pub fn process_packet(ecs: &mut World, player: Entity, packet: &ClientboundGamePacket) {

azalea-registry/azalea-registry-macros/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ pub fn registry(input: TokenStream) -> TokenStream {
153153
});
154154
}
155155
generated.extend(quote! {
156+
/// Convert the value to a stringified identifier, formatted like
157+
/// `"minecraft:air"`.
156158
impl std::fmt::Display for #name {
157159
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
158160
match self {
@@ -170,6 +172,8 @@ pub fn registry(input: TokenStream) -> TokenStream {
170172
}
171173
}
172174
}
175+
/// Parse the value from a stringified identifier, formatted like
176+
/// either `"air"` or `"minecraft:air"`.
173177
impl std::str::FromStr for #name {
174178
type Err = ();
175179

azalea-registry/src/tags/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ impl<R: Registry + 'static> RegistryTag<R> {
4141
// TODO: tune this number; when does binary search actually start making a
4242
// difference?
4343
if self.entries.len() > 64 {
44-
self.linear_search_find(value)
45-
} else {
4644
self.binary_search_find(value)
45+
} else {
46+
self.linear_search_find(value)
4747
}
4848
}
4949
fn linear_search_find(&self, value: &R) -> Option<usize> {

azalea/build.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
use std::{env, process::Command};
22

33
fn main() {
4+
check_nightly();
5+
6+
// save the optimization level, used by the pathfinder to warn if optimizations
7+
// are off
8+
println!(
9+
"cargo::rustc-env=OPT_LEVEL={}",
10+
env::var("OPT_LEVEL").unwrap()
11+
);
12+
}
13+
14+
fn check_nightly() {
415
// If using `rustup`, check the toolchain via `RUSTUP_TOOLCHAIN`
516
if let Ok(toolchain) = env::var("RUSTUP_TOOLCHAIN") {
617
if toolchain.contains("nightly") {

azalea/src/pathfinder/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use std::{
3232
collections::VecDeque,
3333
sync::{
3434
Arc,
35-
atomic::{self, AtomicUsize},
35+
atomic::{self, AtomicBool, AtomicUsize},
3636
},
3737
thread,
3838
time::{Duration, Instant},
@@ -306,6 +306,16 @@ pub fn goto_listener(
306306
continue;
307307
};
308308

309+
// this env variable is set from the build.rs
310+
if env!("OPT_LEVEL") == "0" {
311+
static WARNED: AtomicBool = AtomicBool::new(false);
312+
if !WARNED.swap(true, atomic::Ordering::Relaxed) {
313+
warn!(
314+
"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."
315+
)
316+
}
317+
}
318+
309319
let cur_pos = player_pos_to_block_pos(**position);
310320

311321
if event.goal.success(cur_pos) {

0 commit comments

Comments
 (0)