Skip to content

Commit acd97a9

Browse files
committed
merge main
2 parents 9b30642 + 6c110f2 commit acd97a9

File tree

15 files changed

+138
-70
lines changed

15 files changed

+138
-70
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ is breaking anyways, semantic versioning is not followed.
1212

1313
- Add `Client::query_entity` and `try_query_entity` to complement `query_self`.
1414
- Add `Client::entity_interact` and `EntityInteractEvent` to interact with entities without checking that they're in the crosshair.
15-
- Initial support for mob effects, including jump boost, haste, conduit power, and mining fatigue. (@ShayBox)
15+
- Allow disabling dependencies related to Microsoft auth with the `online-mode` cargo feature.
16+
- Implement mob effects, including jump boost, haste, conduit power, and mining fatigue. (@ShayBox)
1617
- Support for the efficiency enchantment.
1718
- Support for items with attribute modifiers.
1819

@@ -44,7 +45,6 @@ is breaking anyways, semantic versioning is not followed.
4445
- The WritableBookContent and ResolvableProfile data components had the wrong protocol implementations.
4546
- Resolving server addresses shouldn't be recursive.
4647

47-
4848
## [0.14.0+mc1.21.8] - 2025-09-28
4949

5050
### Added

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ uuid = "1.18.1"
9090

9191
azalea-block-macros = { path = "azalea-block/azalea-block-macros", version = "0.14.0" }
9292
azalea-block = { path = "azalea-block", version = "0.14.0" }
93-
azalea-auth = { path = "azalea-auth", version = "0.14.0" }
93+
azalea-auth = { path = "azalea-auth", version = "0.14.0", default-features = false }
9494
azalea-brigadier = { path = "azalea-brigadier", version = "0.14.0" }
9595
azalea-buf-macros = { path = "azalea-buf/azalea-buf-macros", version = "0.14.0" }
9696
azalea-buf = { path = "azalea-buf", version = "0.14.0" }
@@ -104,7 +104,7 @@ azalea-inventory = { path = "azalea-inventory", version = "0.14.0" }
104104
azalea-language = { path = "azalea-language", version = "0.14.0" }
105105
azalea-physics = { path = "azalea-physics", version = "0.14.0" }
106106
azalea-protocol-macros = { path = "azalea-protocol/azalea-protocol-macros", version = "0.14.0" }
107-
azalea-protocol = { path = "azalea-protocol", version = "0.14.0" }
107+
azalea-protocol = { path = "azalea-protocol", version = "0.14.0", default-features = false }
108108
azalea-registry-macros = { path = "azalea-registry/azalea-registry-macros", version = "0.14.0" }
109109
azalea-registry = { path = "azalea-registry", version = "0.14.0" }
110110
azalea-world = { path = "azalea-world", version = "0.14.0" }

azalea-auth/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ crypto-bigint.workspace = true # TODO: Remove when rsa is fixed.
1515
crypto-primes.workspace = true # TODO: Remove when rsa is fixed.
1616
indexmap.workspace = true
1717
md-5.workspace = true
18-
reqwest = { workspace = true, default-features = false, features = [
18+
reqwest = { workspace = true, optional = true, default-features = false, features = [
1919
"json",
2020
"rustls-tls",
2121
] }
@@ -32,5 +32,9 @@ uuid = { workspace = true, features = ["serde", "v3"] }
3232
env_logger.workspace = true
3333
tokio = { workspace = true, features = ["full"] }
3434

35+
[features]
36+
default = ["online-mode"]
37+
online-mode = ["dep:reqwest"]
38+
3539
[lints]
3640
workspace = true

azalea-auth/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
#![doc = include_str!("../README.md")]
22

3+
#[cfg(feature = "online-mode")]
34
mod auth;
5+
#[cfg(feature = "online-mode")]
46
pub mod cache;
7+
#[cfg(feature = "online-mode")]
58
pub mod certs;
6-
pub mod game_profile;
7-
pub mod offline;
9+
#[cfg(feature = "online-mode")]
810
pub mod sessionserver;
9-
11+
#[cfg(feature = "online-mode")]
1012
pub use auth::*;
13+
14+
pub mod game_profile;
15+
pub mod offline;

azalea-auth/src/sessionserver.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Tell Mojang you're joining a multiplayer server.
2+
23
use std::sync::LazyLock;
34

45
use reqwest::StatusCode;

azalea-client/Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ azalea-crypto.workspace = true
1717
azalea-entity.workspace = true
1818
azalea-inventory.workspace = true
1919
azalea-physics.workspace = true
20-
azalea-protocol.workspace = true
20+
azalea-protocol = { workspace = true, features = ["packets", "connecting"] }
2121
azalea-registry.workspace = true
2222
azalea-world.workspace = true
2323
bevy_app.workspace = true
@@ -32,7 +32,7 @@ minecraft_folder_path.workspace = true
3232
parking_lot.workspace = true
3333
pastey.workspace = true
3434
regex.workspace = true
35-
reqwest.workspace = true
35+
reqwest = { workspace = true, optional = true }
3636
simdnbt.workspace = true
3737
thiserror.workspace = true
3838
tokio = { workspace = true, features = ["sync"] }
@@ -43,10 +43,15 @@ uuid.workspace = true
4343
anyhow.workspace = true
4444

4545
[features]
46-
default = ["log", "packet-event"]
46+
default = ["log", "packet-event", "online-mode"]
4747
# enables bevy_log::LogPlugin by default
4848
log = ["bevy_log"]
4949
packet-event = []
50+
online-mode = [
51+
"azalea-auth/online-mode",
52+
"azalea-protocol/online-mode",
53+
"dep:reqwest",
54+
]
5055

5156
[lints]
5257
workspace = true

azalea-client/src/account.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
33
use std::sync::Arc;
44

5-
use azalea_auth::{
6-
AccessTokenResponse,
7-
certs::{Certificates, FetchCertificatesError},
8-
};
5+
#[cfg(feature = "online-mode")]
6+
use azalea_auth::AccessTokenResponse;
7+
#[cfg(feature = "online-mode")]
8+
use azalea_auth::certs::{Certificates, FetchCertificatesError};
99
use bevy_ecs::component::Component;
1010
use parking_lot::Mutex;
11+
#[cfg(feature = "online-mode")]
1112
use thiserror::Error;
12-
use tracing::trace;
1313
use uuid::Uuid;
1414

1515
/// Something that can join Minecraft servers.
@@ -58,6 +58,7 @@ pub struct Account {
5858
///
5959
/// This is set when you call [`Self::request_certs`], but you only
6060
/// need to if the servers you're joining require it.
61+
#[cfg(feature = "online-mode")]
6162
pub certs: Arc<Mutex<Option<Certificates>>>,
6263
}
6364

@@ -67,9 +68,11 @@ pub enum AccountOpts {
6768
Offline {
6869
username: String,
6970
},
71+
#[cfg(feature = "online-mode")]
7072
Microsoft {
7173
email: String,
7274
},
75+
#[cfg(feature = "online-mode")]
7376
MicrosoftWithAccessToken {
7477
msa: Arc<Mutex<azalea_auth::cache::ExpiringValue<AccessTokenResponse>>>,
7578
},
@@ -88,6 +91,7 @@ impl Account {
8891
account_opts: AccountOpts::Offline {
8992
username: username.to_string(),
9093
},
94+
#[cfg(feature = "online-mode")]
9195
certs: Arc::new(Mutex::new(None)),
9296
}
9397
}
@@ -97,6 +101,7 @@ impl Account {
97101
///
98102
/// The cache key is used for avoiding having to log in every time. This is
99103
/// typically set to the account email, but it can be any string.
104+
#[cfg(feature = "online-mode")]
100105
pub async fn microsoft(cache_key: &str) -> Result<Self, azalea_auth::AuthError> {
101106
Self::microsoft_with_custom_client_id_and_scope(cache_key, None, None).await
102107
}
@@ -105,6 +110,7 @@ impl Account {
105110
/// and `scope`.
106111
///
107112
/// Pass `None` if you want to use default ones.
113+
#[cfg(feature = "online-mode")]
108114
pub async fn microsoft_with_custom_client_id_and_scope(
109115
cache_key: &str,
110116
client_id: Option<&str>,
@@ -162,6 +168,7 @@ impl Account {
162168
/// # Ok(())
163169
/// # }
164170
/// ```
171+
#[cfg(feature = "online-mode")]
165172
pub async fn with_microsoft_access_token(
166173
msa: azalea_auth::cache::ExpiringValue<AccessTokenResponse>,
167174
) -> Result<Self, azalea_auth::AuthError> {
@@ -170,6 +177,7 @@ impl Account {
170177

171178
/// Similar to [`Account::with_microsoft_access_token`] but you can use
172179
/// custom `client_id` and `scope`.
180+
#[cfg(feature = "online-mode")]
173181
pub async fn with_microsoft_access_token_and_custom_client_id_and_scope(
174182
mut msa: azalea_auth::cache::ExpiringValue<AccessTokenResponse>,
175183
client_id: Option<&str>,
@@ -178,6 +186,8 @@ impl Account {
178186
let client = reqwest::Client::new();
179187

180188
if msa.is_expired() {
189+
use tracing::trace;
190+
181191
trace!("refreshing Microsoft auth token");
182192
msa = azalea_auth::refresh_ms_auth_token(
183193
&client,
@@ -209,6 +219,7 @@ impl Account {
209219
/// This requires the `auth_opts` field to be set correctly (which is done
210220
/// by default if you used the constructor functions). Note that if the
211221
/// Account is offline-mode then this function won't do anything.
222+
#[cfg(feature = "online-mode")]
212223
pub async fn refresh(&self) -> Result<(), azalea_auth::AuthError> {
213224
match &self.account_opts {
214225
// offline mode doesn't need to refresh so just don't do anything lol
@@ -240,6 +251,13 @@ impl Account {
240251
}
241252
}
242253

254+
/// Stub function that does nothing when the `online-mode` feature is
255+
/// disabled.
256+
#[cfg(not(feature = "online-mode"))]
257+
pub async fn refresh(&self) -> Result<(), ()> {
258+
Ok(())
259+
}
260+
243261
/// Get the UUID of this account.
244262
///
245263
/// If the `uuid` field is None, the UUID will be determined by using
@@ -250,6 +268,7 @@ impl Account {
250268
}
251269
}
252270

271+
#[cfg(feature = "online-mode")]
253272
#[derive(Error, Debug)]
254273
pub enum RequestCertError {
255274
#[error("Failed to fetch certificates")]
@@ -261,6 +280,7 @@ pub enum RequestCertError {
261280
impl Account {
262281
/// Request the certificates used for chat signing and set it in
263282
/// [`Self::certs`].
283+
#[cfg(feature = "online-mode")]
264284
pub async fn request_certs(&mut self) -> Result<(), RequestCertError> {
265285
let access_token = self
266286
.access_token

azalea-client/src/plugins/chat/handler.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
use std::time::{SystemTime, UNIX_EPOCH};
22

3-
use azalea_crypto::SignChatMessageOptions;
43
use azalea_protocol::packets::{
54
Packet,
65
game::{ServerboundChat, ServerboundChatCommand, s_chat::LastSeenMessagesUpdate},
76
};
87
use bevy_ecs::prelude::*;
98

109
use super::ChatKind;
11-
use crate::{Account, chat_signing::ChatSigningSession, packet::game::SendGamePacketEvent};
10+
use crate::packet::game::SendGamePacketEvent;
11+
#[cfg(feature = "online-mode")]
12+
use crate::{Account, chat_signing::ChatSigningSession};
1213

1314
/// Send a chat packet to the server of a specific kind (chat message or
1415
/// command). Usually you just want [`SendChatEvent`] instead.
@@ -31,7 +32,7 @@ pub struct SendChatKindEvent {
3132
pub fn handle_send_chat_kind_event(
3233
mut events: MessageReader<SendChatKindEvent>,
3334
mut commands: Commands,
34-
mut query: Query<(&Account, &mut ChatSigningSession)>,
35+
#[cfg(feature = "online-mode")] mut query: Query<(&Account, &mut ChatSigningSession)>,
3536
) {
3637
for event in events.read() {
3738
let content = event
@@ -47,6 +48,7 @@ pub fn handle_send_chat_kind_event(
4748
ChatKind::Message => {
4849
let salt = azalea_crypto::make_salt();
4950

51+
#[cfg(feature = "online-mode")]
5052
let signature = if let Ok((account, mut chat_session)) = query.get_mut(event.entity)
5153
{
5254
Some(create_signature(
@@ -59,6 +61,8 @@ pub fn handle_send_chat_kind_event(
5961
} else {
6062
None
6163
};
64+
#[cfg(not(feature = "online-mode"))]
65+
let signature = None;
6266

6367
ServerboundChat {
6468
message: content,
@@ -85,13 +89,16 @@ pub fn handle_send_chat_kind_event(
8589
}
8690
}
8791

92+
#[cfg(feature = "online-mode")]
8893
pub fn create_signature(
8994
account: &Account,
9095
chat_session: &mut ChatSigningSession,
9196
salt: u64,
9297
timestamp: SystemTime,
9398
message: &str,
9499
) -> azalea_crypto::MessageSignature {
100+
use azalea_crypto::SignChatMessageOptions;
101+
95102
let certs = account.certs.lock();
96103
let certs = certs.as_ref().expect("certs shouldn't be set back to None");
97104

azalea-client/src/plugins/chat_signing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ pub struct RequestCertsTask(pub Task<Result<Certificates, FetchCertificatesError
4343
pub struct OnlyRefreshCertsAfter {
4444
pub refresh_at: Instant,
4545
}
46-
/// A component that's present when that this client has sent its certificates
47-
/// to the server.
46+
/// A component that's present when this client has sent its certificates to the
47+
/// server.
4848
///
4949
/// This should be removed if you want to re-send the certs.
5050
///

azalea-client/src/plugins/disconnect.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ use derive_more::Deref;
1111
use tracing::info;
1212

1313
use super::login::IsAuthenticated;
14+
#[cfg(feature = "online-mode")]
15+
use crate::chat_signing;
1416
use crate::{
15-
chat_signing, client::JoinedClientBundle, connection::RawConnection,
16-
local_player::InstanceHolder, tick_counter::TicksConnected,
17+
client::JoinedClientBundle, connection::RawConnection, local_player::InstanceHolder,
18+
tick_counter::TicksConnected,
1719
};
1820

1921
pub struct DisconnectPlugin;
@@ -69,6 +71,7 @@ pub struct RemoveOnDisconnectBundle {
6971
/// This makes it not send [`DisconnectEvent`] again.
7072
pub is_connection_alive: IsConnectionAlive,
7173
/// Resend our chat signing certs next time.
74+
#[cfg(feature = "online-mode")]
7275
pub chat_signing_session: chat_signing::ChatSigningSession,
7376
/// They're not authenticated anymore if they disconnected.
7477
pub is_authenticated: IsAuthenticated,

0 commit comments

Comments
 (0)