Skip to content

Commit

Permalink
Merge branch 'main' into custom_auth
Browse files Browse the repository at this point in the history
  • Loading branch information
1zun4 committed Jun 27, 2024
2 parents 157e711 + 350e32d commit 0e87706
Show file tree
Hide file tree
Showing 32 changed files with 707 additions and 195 deletions.
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A collection of Rust crates for making Minecraft bots, clients, and tools.

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

_Currently supported Minecraft version: `1.20.6`._
_Currently supported Minecraft version: `1.21`._

> [!WARNING]
> Azalea is still very unfinished, though most crates are in a somewhat useable state
Expand Down Expand Up @@ -51,8 +51,11 @@ If you'd like to chat about Azalea, you can join the Matrix space at [#azalea:ma

## Branches

There are several branches in the Azalea repository that target older Minecraft versions. It is not guaranteed that they will be up-to-date with the latest version of Azalea. If you'd like to update them or add more, please open a PR.
There are several branches in the Azalea repository that target older Minecraft versions.
Most of them are severely outdated compared to the latest version of Azalea.
If you'd like to update them or add more, please open a PR.

- [1.20.5-1.20.6](https://github.com/azalea-rs/azalea/tree/1.20.6)
- [1.20.4](https://github.com/azalea-rs/azalea/tree/1.20.4)
- [1.20.2](https://github.com/azalea-rs/azalea/tree/1.20.2)
- [1.20-1.20.1](https://github.com/azalea-rs/azalea/tree/1.20.1)
Expand Down
2 changes: 1 addition & 1 deletion azalea-block/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-block"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-block"
version = "0.10.0"
version = "0.10.2"

[lib]

Expand Down
2 changes: 1 addition & 1 deletion azalea-block/azalea-block-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-block-macros"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-block/azalea-block-macros"
version = "0.10.0"
version = "0.10.2"

[lib]
proc-macro = true
Expand Down
32 changes: 22 additions & 10 deletions azalea-block/azalea-block-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ struct PropertyDefinitions {
/// `"snowy": Snowy(false)` or `"axis": properties::Axis::Y`
#[derive(Debug)]
struct PropertyWithNameAndDefault {
// "snowy" / "axis"
// "snowy" "axis"
name: String,
/// The property name, potentially modified so it works better as a struct
/// field.
name_ident: Ident,
// Snowy / Axis
property_type: Ident,
property_value_type: Ident,
Expand Down Expand Up @@ -100,8 +103,11 @@ impl Parse for PropertyWithNameAndDefault {
}
};

let property_name_ident = name_to_ident(&property_name);

Ok(PropertyWithNameAndDefault {
name: property_name,
name_ident: property_name_ident,
property_type,
property_value_type,
is_enum,
Expand Down Expand Up @@ -433,6 +439,7 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
write!(property_name, "_{index}").unwrap();
}
properties_with_name.push(PropertyWithNameAndDefault {
name_ident: name_to_ident(&property_name),
name: property_name,
property_type: property.property_type.clone(),
property_value_type: property.property_value_type.clone(),
Expand All @@ -452,12 +459,11 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
let mut block_struct_fields = quote! {};
for PropertyWithNameAndDefault {
property_value_type,
name,
name_ident,
is_enum,
..
} in &properties_with_name
{
let name_ident = Ident::new_raw(name, proc_macro2::Span::call_site());
block_struct_fields.extend(if *is_enum {
quote! { pub #name_ident: properties::#property_value_type, }
} else {
Expand Down Expand Up @@ -496,7 +502,7 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
let mut from_block_to_state_combination_match_inner = quote! {};
for i in 0..properties_with_name.len() {
let property = &properties_with_name[i];
let property_name = &property.name;
let property_name_ident = &property.name_ident;
let property_value_name_ident = &property.property_type;
let variant =
Ident::new(&combination[i].to_string(), proc_macro2::Span::call_site());
Expand All @@ -519,8 +525,6 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
quote! {#variant}
};

let property_name_ident =
Ident::new_raw(property_name, proc_macro2::Span::call_site());
from_block_to_state_combination_match_inner.extend(quote! {
#property_name_ident: #property_variant,
});
Expand Down Expand Up @@ -582,7 +586,7 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
for i in (0..properties_with_name.len()).rev() {
let PropertyWithNameAndDefault {
property_type: property_struct_name_ident,
name: property_name,
name_ident: property_name_ident,
property_value_type,
..
} = &properties_with_name[i];
Expand All @@ -598,7 +602,6 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
quote! {properties::#property_struct_name_ident::from((b / #division) % #property_variants_count)}
}
};
let property_name_ident = Ident::new_raw(property_name, proc_macro2::Span::call_site());
from_state_to_block_inner.extend(quote! {
#property_name_ident: #conversion_code,
});
Expand Down Expand Up @@ -627,12 +630,11 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {

let mut block_default_fields = quote! {};
for PropertyWithNameAndDefault {
name,
name_ident,
default: property_default,
..
} in properties_with_name
{
let name_ident = Ident::new_raw(&name, proc_macro2::Span::call_site());
block_default_fields.extend(quote! { #name_ident: #property_default, });
}

Expand Down Expand Up @@ -821,3 +823,13 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {

generated.into()
}

/// Convert a name to a Rust identifier, replacing some Rust keywords with
/// alternatives (e.g. `type` -> `kind`).
fn name_to_ident(name: &str) -> Ident {
let ident_str = match name {
"type" => "kind",
_ => &name,

Check warning on line 832 in azalea-block/azalea-block-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> azalea-block/azalea-block-macros/src/lib.rs:832:14 | 832 | _ => &name, | ^^^^^ help: change this to: `name` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default

Check warning on line 832 in azalea-block/azalea-block-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> azalea-block/azalea-block-macros/src/lib.rs:832:14 | 832 | _ => &name, | ^^^^^ help: change this to: `name` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
};
Ident::new(ident_str, proc_macro2::Span::call_site())
}
2 changes: 1 addition & 1 deletion azalea-brigadier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-brigadier"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-brigadier"
version = "0.10.0"
version = "0.10.2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion azalea-buf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-buf"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-buf"
version = "0.10.1"
version = "0.10.2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion azalea-buf/src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl McBufVarReadable for i64 {
fn var_read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
let mut buffer = [0];
let mut ans = 0;
for i in 0..8 {
for i in 0..10 {
buf.read_exact(&mut buffer)
.map_err(|_| BufReadError::InvalidVarLong)?;
ans |= ((buffer[0] & 0b0111_1111) as i64) << (7 * i);
Expand Down
2 changes: 1 addition & 1 deletion azalea-chat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-chat"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-chat"
version = "0.10.1"
version = "0.10.2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion azalea-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-client"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-client"
version = "0.10.1"
version = "0.10.2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
14 changes: 1 addition & 13 deletions azalea-client/src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,7 @@ fn handle_send_chat_kind_event(
.get(),
ChatPacketKind::Command => {
// TODO: chat signing
ServerboundChatCommandPacket {
command: content,
timestamp: SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("Time shouldn't be before epoch")
.as_millis()
.try_into()
.expect("Instant should fit into a u64"),
salt: azalea_crypto::make_salt(),
argument_signatures: vec![],
last_seen_messages: LastSeenMessagesUpdate::default(),
}
.get()
ServerboundChatCommandPacket { command: content }.get()
}
};

Expand Down
5 changes: 1 addition & 4 deletions azalea-client/src/interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,7 @@ fn update_modifiers_for_held_item(
};
attributes
.attack_speed
.remove(&azalea_entity::attributes::BASE_ATTACK_SPEED_UUID);
attributes
.attack_speed
.insert(azalea_entity::attributes::tool_attack_speed_modifier(
.insert(azalea_entity::attributes::base_attack_speed_modifier(
added_attack_speed,
))
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion azalea-client/src/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ fn set_sprinting(
} else {
attributes
.speed
.remove(&azalea_entity::attributes::sprinting_modifier().uuid)
.remove(&azalea_entity::attributes::sprinting_modifier().id)
.is_none()
}
}
Expand Down
2 changes: 1 addition & 1 deletion azalea-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea-core"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-core"
version = "0.10.0"
version = "0.10.2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion azalea-entity/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "azalea-entity"
version = "0.10.1"
version = "0.10.2"
edition = "2021"
description = "Things related to Minecraft entities used by Azalea"
repository = "https://github.com/azalea-rs/azalea/tree/main/azalea-entity"
Expand Down
Loading

0 comments on commit 0e87706

Please sign in to comment.