Skip to content

Commit

Permalink
Merge branch 'main' into socks5
Browse files Browse the repository at this point in the history
  • Loading branch information
1zun4 committed Apr 10, 2024
2 parents 7824dc2 + b66b5b6 commit d094614
Show file tree
Hide file tree
Showing 92 changed files with 2,091 additions and 1,173 deletions.
498 changes: 271 additions & 227 deletions Cargo.lock

Large diffs are not rendered by default.

Empty file modified Cargo.toml
100755 → 100644
Empty file.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
A collection of Rust crates for making Minecraft bots, clients, and tools.

<p align="center">
<img src="https://cdn.matdoes.dev/images/flowering_azalea.webp" alt="Azalea" height="200">
<img src="https://github.com/azalea-rs/azalea/assets/27899617/b98a42df-5cf0-4d1f-ae7c-ecca333e3cab" alt="Azalea" height="200">
</p>


<!-- The line below is automatically read and updated by the migrate script, so don't change it manually. -->

_Currently supported Minecraft version: `1.20.4`._
Expand Down
22 changes: 11 additions & 11 deletions azalea-auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ version = "0.9.0"
[dependencies]
azalea-buf = { path = "../azalea-buf", version = "0.9.0" }
azalea-crypto = { path = "../azalea-crypto", version = "0.9.0" }
base64 = "0.21.5"
chrono = { version = "0.4.31", default-features = false, features = ["serde"] }
base64 = "0.21.7"
chrono = { version = "0.4.34", default-features = false, features = ["serde"] }
tracing = "0.1.40"
num-bigint = "0.4.4"
once_cell = "1.18.0"
reqwest = { version = "0.11.22", default-features = false, features = [
once_cell = "1.19.0"
reqwest = { version = "0.11.24", default-features = false, features = [
"json",
"rustls-tls",
] }
rsa = "0.9.6"
serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0.108"
thiserror = "1.0.50"
tokio = { version = "1.34.0", features = ["fs"] }
uuid = { version = "1.6.1", features = ["serde", "v3"] }
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.113"
thiserror = "1.0.57"
tokio = { version = "1.36.0", features = ["fs"] }
uuid = { version = "1.7.0", features = ["serde", "v3"] }
md-5 = "0.10.6"

[dev-dependencies]
env_logger = "0.10.1"
tokio = { version = "1.34.0", features = ["full"] }
env_logger = "0.11.2"
tokio = { version = "1.36.0", features = ["full"] }
10 changes: 7 additions & 3 deletions azalea-auth/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ pub async fn auth(email: &str, opts: AuthOpts) -> Result<AuthResult, AuthError>
///
/// If you don't have a Microsoft auth token, you can get it from
/// [`get_ms_link_code`] and then [`get_ms_auth_token`].
///
/// If you got the MSA token from your own app (as opposed to the default
/// Nintendo Switch one), you may have to prepend "d=" to the token.
pub async fn get_minecraft_token(
client: &reqwest::Client,
msa: &str,
Expand Down Expand Up @@ -235,6 +238,7 @@ pub struct MinecraftAuthResponse {
pub struct GameOwnershipResponse {
pub items: Vec<GameOwnershipItem>,
pub signature: String,
#[serde(rename = "keyId")]
pub key_id: String,
}

Expand Down Expand Up @@ -418,9 +422,9 @@ async fn auth_with_xbox_live(
"Properties": {
"AuthMethod": "RPS",
"SiteName": "user.auth.xboxlive.com",
// i thought this was supposed to be d={} but it doesn't work for
// me when i add it ??????
"RpsTicket": format!("{access_token}")
// this value should have "d=" prepended if you're using your own app (as opposed to
// the default nintendo switch one)
"RpsTicket": access_token
},
"RelyingParty": "http://auth.xboxlive.com",
"TokenType": "JWT"
Expand Down
6 changes: 3 additions & 3 deletions azalea-block/azalea-block-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ proc-macro = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
proc-macro2 = "1.0.70"
quote = "1.0.33"
syn = "2.0.39"
proc-macro2 = "1.0.78"
quote = "1.0.35"
syn = "2.0.49"
2 changes: 1 addition & 1 deletion azalea-block/azalea-block-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use quote::quote;
use std::collections::HashMap;
use std::fmt::Write;
use syn::{
self, braced,
braced,
ext::IdentExt,
parenthesized,
parse::{Parse, ParseStream, Result},
Expand Down
1 change: 0 additions & 1 deletion azalea-block/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5380,4 +5380,3 @@ make_block_states! {
},
}
}

3 changes: 3 additions & 0 deletions azalea-block/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![doc = include_str!("../README.md")]
#![feature(trait_upcasting)]

mod behavior;
mod generated;
Expand Down Expand Up @@ -58,6 +59,8 @@ impl BlockState {
state_id <= Self::max_state()
}

/// Returns true if the block is air. This only checks for normal air, not
/// other types like cave air.
#[inline]
pub fn is_air(&self) -> bool {
self == &Self::AIR
Expand Down
6 changes: 3 additions & 3 deletions azalea-buf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ version = "0.9.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
simdnbt = { version = "0.3", git = "https://github.com/azalea-rs/simdnbt" }
simdnbt = { version = "0.4", git = "https://github.com/azalea-rs/simdnbt" }
azalea-buf-macros = { path = "./azalea-buf-macros", version = "0.9.0" }
byteorder = "^1.5.0"
tracing = "0.1.40"
serde_json = { version = "^1.0", optional = true }
thiserror = "1.0.50"
uuid = "^1.6.1"
thiserror = "1.0.57"
uuid = "^1.7.0"

[features]
serde_json = ["dep:serde_json"]
6 changes: 3 additions & 3 deletions azalea-buf/azalea-buf-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ proc-macro = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
proc-macro2 = "^1.0.70"
quote = "^1.0.33"
syn = { version = "^2.0.39", features = ["extra-traits"] }
proc-macro2 = "^1.0.78"
quote = "^1.0.35"
syn = { version = "^2.0.49", features = ["extra-traits"] }
2 changes: 1 addition & 1 deletion azalea-buf/azalea-buf-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod write;

use proc_macro::TokenStream;
use quote::quote;
use syn::{self, parse_macro_input, DeriveInput};
use syn::{parse_macro_input, DeriveInput};

#[proc_macro_derive(McBufReadable, attributes(var))]
pub fn derive_mcbufreadable(input: TokenStream) -> TokenStream {
Expand Down
2 changes: 1 addition & 1 deletion azalea-buf/azalea-buf-macros/src/read.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use quote::{quote, ToTokens};
use syn::{self, punctuated::Punctuated, token::Comma, Data, Field, FieldsNamed, Ident};
use syn::{punctuated::Punctuated, token::Comma, Data, Field, FieldsNamed, Ident};

fn read_named_fields(
named: &Punctuated<Field, Comma>,
Expand Down
2 changes: 1 addition & 1 deletion azalea-buf/azalea-buf-macros/src/write.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use proc_macro2::Span;
use quote::{quote, ToTokens};
use syn::{self, punctuated::Punctuated, token::Comma, Data, Field, FieldsNamed, Ident};
use syn::{punctuated::Punctuated, token::Comma, Data, Field, FieldsNamed, Ident};

fn write_named_fields(
named: &Punctuated<Field, Comma>,
Expand Down
6 changes: 3 additions & 3 deletions azalea-chat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ azalea-buf = { path = "../azalea-buf", features = [
"serde_json",
], version = "0.9.0", optional = true }
azalea-language = { path = "../azalea-language", version = "0.9.0" }
simdnbt = { version = "0.3", optional = true, git = "https://github.com/azalea-rs/simdnbt" }
simdnbt = { version = "0.4", optional = true, git = "https://github.com/azalea-rs/simdnbt" }
tracing = "0.1.40"
once_cell = "1.18.0"
once_cell = "1.19.0"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0.108"
serde_json = "^1.0.113"
azalea-registry = { path = "../azalea-registry", version = "0.9.0", optional = true }
78 changes: 57 additions & 21 deletions azalea-chat/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use serde::{de, Deserialize, Deserializer, Serialize};
#[cfg(feature = "simdnbt")]
use simdnbt::{Deserialize as _, FromNbtTag as _, Serialize as _};
use std::fmt::Display;
use tracing::{trace, warn};

/// A chat component, basically anything you can see in chat.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Hash)]
Expand Down Expand Up @@ -313,22 +314,60 @@ impl simdnbt::FromNbtTag for FormattedText {
// if it's a string component with no styling and no siblings, just add
// a string to with_array otherwise add the
// component to the array
let c = FormattedText::from_nbt_tag(
if let Some(primitive) = item.get("") {
// minecraft does this sometimes, for example
// for the /give system messages
match primitive {
simdnbt::borrow::NbtTag::Byte(b) => {
// interpreted as boolean
with_array.push(StringOrComponent::String(
if *b != 0 { "true" } else { "false" }.to_string(),
));
}
simdnbt::borrow::NbtTag::Short(s) => {
with_array.push(StringOrComponent::String(s.to_string()));
}
simdnbt::borrow::NbtTag::Int(i) => {
with_array.push(StringOrComponent::String(i.to_string()));
}
simdnbt::borrow::NbtTag::Long(l) => {
with_array.push(StringOrComponent::String(l.to_string()));
}
simdnbt::borrow::NbtTag::Float(f) => {
with_array.push(StringOrComponent::String(f.to_string()));
}
simdnbt::borrow::NbtTag::Double(d) => {
with_array.push(StringOrComponent::String(d.to_string()));
}
simdnbt::borrow::NbtTag::String(s) => {
with_array.push(StringOrComponent::String(s.to_string()));
}
_ => {
warn!("couldn't parse {item:?} as FormattedText because it has a disallowed primitive");
with_array.push(StringOrComponent::String("?".to_string()));
}
}
} else if let Some(c) = FormattedText::from_nbt_tag(
&simdnbt::borrow::NbtTag::Compound(item.clone()),
)?;
if let FormattedText::Text(text_component) = c {
if text_component.base.siblings.is_empty()
&& text_component.base.style.is_empty()
{
with_array.push(StringOrComponent::String(text_component.text));
continue;
) {
if let FormattedText::Text(text_component) = c {
if text_component.base.siblings.is_empty()
&& text_component.base.style.is_empty()
{
with_array
.push(StringOrComponent::String(text_component.text));
continue;
}
}
with_array.push(StringOrComponent::FormattedText(
FormattedText::from_nbt_tag(
&simdnbt::borrow::NbtTag::Compound(item.clone()),
)?,
));
} else {
warn!("couldn't parse {item:?} as FormattedText");
with_array.push(StringOrComponent::String("?".to_string()));
}
with_array.push(StringOrComponent::FormattedText(
FormattedText::from_nbt_tag(&simdnbt::borrow::NbtTag::Compound(
item.clone(),
))?,
));
}
component = FormattedText::Translatable(TranslatableComponent::new(
translate, with_array,
Expand All @@ -344,32 +383,29 @@ impl simdnbt::FromNbtTag for FormattedText {
// object = GsonHelper.getAsJsonObject(jsonObject, "score");
if score.get("name").is_none() || score.get("objective").is_none() {
// A score component needs at least a name and an objective
tracing::trace!("A score component needs at least a name and an objective");
trace!("A score component needs at least a name and an objective");
return None;
}
// TODO, score text components aren't yet supported
return None;
} else if compound.get("selector").is_some() {
// selector text components aren't yet supported
tracing::trace!("selector text components aren't yet supported");
trace!("selector text components aren't yet supported");
return None;
} else if compound.get("keybind").is_some() {
// keybind text components aren't yet supported
tracing::trace!("keybind text components aren't yet supported");
trace!("keybind text components aren't yet supported");
return None;
} else {
let Some(_nbt) = compound.get("nbt") else {
// Don't know how to turn 'nbt' into a FormattedText
return None;
};
let _nbt = compound.get("nbt")?;
let _separator = FormattedText::parse_separator_nbt(compound)?;

let _interpret = match compound.get("interpret") {
Some(v) => v.byte().unwrap_or_default() != 0,
None => false,
};
if let Some(_block) = compound.get("block") {}
// nbt text components aren't yet supported
trace!("nbt text components aren't yet supported");
return None;
}
if let Some(extra) = compound.get("extra") {
Expand Down
36 changes: 18 additions & 18 deletions azalea-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ version = "0.9.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
simdnbt = { version = "0.3", git = "https://github.com/azalea-rs/simdnbt" }
reqwest = { version = "0.11.22", default-features = false }
anyhow = "1.0.75"
async-trait = "0.1.74"
simdnbt = { version = "0.4", git = "https://github.com/azalea-rs/simdnbt" }
reqwest = { version = "0.11.24", default-features = false }
anyhow = "1.0.79"
async-trait = "0.1.77"
azalea-auth = { path = "../azalea-auth", version = "0.9.0" }
azalea-block = { path = "../azalea-block", version = "0.9.0" }
azalea-chat = { path = "../azalea-chat", version = "0.9.0" }
Expand All @@ -23,27 +23,27 @@ azalea-buf = { path = "../azalea-buf", version = "0.9.0" }
azalea-protocol = { path = "../azalea-protocol", version = "0.9.0" }
azalea-registry = { path = "../azalea-registry", version = "0.9.0" }
azalea-world = { path = "../azalea-world", version = "0.9.0" }
bevy_app = "0.12.1"
bevy_ecs = "0.12.1"
bevy_log = { version = "0.12.1", optional = true }
bevy_tasks = "0.12.1"
bevy_time = "0.12.1"
bevy_app = "0.13.0"
bevy_ecs = "0.13.0"
bevy_log = { version = "0.13.0", optional = true }
bevy_tasks = "0.13.0"
bevy_time = "0.13.0"
azalea-inventory = { path = "../azalea-inventory", version = "0.9.0" }
derive_more = { version = "0.99.17", features = ["deref", "deref_mut"] }
futures = "0.3.29"
futures = "0.3.30"
tracing = "0.1.40"
nohash-hasher = "0.2.0"
once_cell = "1.18.0"
once_cell = "1.19.0"
parking_lot = { version = "^0.12.1", features = ["deadlock_detection"] }
regex = "1.10.2"
thiserror = "^1.0.50"
tokio = { version = "^1.34.0", features = ["sync"] }
uuid = "^1.6.1"
regex = "1.10.3"
thiserror = "^1.0.57"
tokio = { version = "^1.36.0", features = ["sync"] }
uuid = "^1.7.0"
azalea-entity = { version = "0.9.0", path = "../azalea-entity" }
serde_json = "1.0.108"
serde = "1.0.192"
serde_json = "1.0.113"
serde = "1.0.196"
minecraft_folder_path = "0.1.2"
socks5-impl = "0.5.6"
minecraft_folder_path = "0.1.1"

[features]
default = ["log"]
Expand Down
Loading

0 comments on commit d094614

Please sign in to comment.