1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00

merge main

This commit is contained in:
mat 2024-11-27 10:37:55 +00:00
commit 0ba1dfdb8d
23 changed files with 986 additions and 985 deletions

7
Cargo.lock generated
View file

@ -237,7 +237,6 @@ dependencies = [
"chrono", "chrono",
"env_logger", "env_logger",
"md-5", "md-5",
"once_cell",
"reqwest", "reqwest",
"rsa", "rsa",
"serde", "serde",
@ -306,7 +305,6 @@ dependencies = [
"azalea-buf", "azalea-buf",
"azalea-language", "azalea-language",
"azalea-registry", "azalea-registry",
"once_cell",
"serde", "serde",
"serde_json", "serde_json",
"simdnbt", "simdnbt",
@ -337,7 +335,6 @@ dependencies = [
"bevy_time", "bevy_time",
"derive_more", "derive_more",
"minecraft_folder_path", "minecraft_folder_path",
"once_cell",
"parking_lot", "parking_lot",
"regex", "regex",
"reqwest", "reqwest",
@ -428,7 +425,6 @@ dependencies = [
name = "azalea-language" name = "azalea-language"
version = "0.10.3+mc1.21.1" version = "0.10.3+mc1.21.1"
dependencies = [ dependencies = [
"once_cell",
"serde", "serde",
"serde_json", "serde_json",
] ]
@ -445,7 +441,6 @@ dependencies = [
"azalea-world", "azalea-world",
"bevy_app", "bevy_app",
"bevy_ecs", "bevy_ecs",
"once_cell",
"parking_lot", "parking_lot",
"uuid", "uuid",
] ]
@ -474,7 +469,6 @@ dependencies = [
"futures", "futures",
"futures-lite", "futures-lite",
"log", "log",
"once_cell",
"serde", "serde",
"serde_json", "serde_json",
"simdnbt", "simdnbt",
@ -503,7 +497,6 @@ version = "0.10.3+mc1.21.1"
dependencies = [ dependencies = [
"azalea-buf", "azalea-buf",
"azalea-registry-macros", "azalea-registry-macros",
"once_cell",
"serde", "serde",
"simdnbt", "simdnbt",
] ]

View file

@ -48,7 +48,6 @@ minecraft_folder_path = "0.1.2"
nohash-hasher = "0.2.0" nohash-hasher = "0.2.0"
num-bigint = "0.4.6" num-bigint = "0.4.6"
num-traits = "0.2.19" num-traits = "0.2.19"
once_cell = "1.20.2"
parking_lot = "0.12.3" parking_lot = "0.12.3"
priority-queue = "2.1.1" priority-queue = "2.1.1"
proc-macro2 = "1.0.92" proc-macro2 = "1.0.92"

View file

@ -14,8 +14,6 @@ azalea-crypto = { path = "../azalea-crypto", version = "0.10.0" }
base64 = { workspace = true } base64 = { workspace = true }
chrono = { workspace = true, features = ["serde"] } chrono = { workspace = true, features = ["serde"] }
md-5 = { workspace = true } md-5 = { workspace = true }
#num-bigint = { workspace = true }
once_cell = { workspace = true }
reqwest = { workspace = true, features = ["json", "rustls-tls"] } reqwest = { workspace = true, features = ["json", "rustls-tls"] }
rsa = { workspace = true } rsa = { workspace = true }
serde = { workspace = true, features = ["derive"] } serde = { workspace = true, features = ["derive"] }

View file

@ -1,5 +1,6 @@
//! Tell Mojang you're joining a multiplayer server. //! Tell Mojang you're joining a multiplayer server.
use once_cell::sync::Lazy; use std::sync::LazyLock;
use reqwest::StatusCode; use reqwest::StatusCode;
use serde::Deserialize; use serde::Deserialize;
use serde_json::json; use serde_json::json;
@ -49,7 +50,7 @@ pub struct ForbiddenError {
pub path: String, pub path: String,
} }
static REQWEST_CLIENT: Lazy<reqwest::Client> = Lazy::new(reqwest::Client::new); static REQWEST_CLIENT: LazyLock<reqwest::Client> = LazyLock::new(reqwest::Client::new);
/// Tell Mojang's servers that you are going to join a multiplayer server, /// Tell Mojang's servers that you are going to join a multiplayer server,
/// which is required to join online-mode servers. The server ID is an empty /// which is required to join online-mode servers. The server ID is an empty

View file

@ -20,7 +20,6 @@ azalea-buf = { path = "../azalea-buf", features = [
], version = "0.10.0", optional = true } ], version = "0.10.0", optional = true }
azalea-language = { path = "../azalea-language", version = "0.10.0" } azalea-language = { path = "../azalea-language", version = "0.10.0" }
azalea-registry = { path = "../azalea-registry", version = "0.10.0", optional = true } azalea-registry = { path = "../azalea-registry", version = "0.10.0", optional = true }
once_cell = { workspace = true }
serde = { workspace = true, features = ["derive"] } serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true } serde_json = { workspace = true }
simdnbt = { workspace = true, optional = true } simdnbt = { workspace = true, optional = true }

View file

@ -1,8 +1,7 @@
use std::fmt::Display; use std::{fmt::Display, sync::LazyLock};
#[cfg(feature = "azalea-buf")] #[cfg(feature = "azalea-buf")]
use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError}; use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError};
use once_cell::sync::Lazy;
use serde::{de, Deserialize, Deserializer, Serialize}; use serde::{de, Deserialize, Deserializer, Serialize};
#[cfg(feature = "simdnbt")] #[cfg(feature = "simdnbt")]
use simdnbt::{Deserialize as _, FromNbtTag as _, Serialize as _}; use simdnbt::{Deserialize as _, FromNbtTag as _, Serialize as _};
@ -23,7 +22,7 @@ pub enum FormattedText {
Translatable(TranslatableComponent), Translatable(TranslatableComponent),
} }
pub static DEFAULT_STYLE: Lazy<Style> = Lazy::new(|| Style { pub static DEFAULT_STYLE: LazyLock<Style> = LazyLock::new(|| Style {
color: Some(ChatFormatting::White.try_into().unwrap()), color: Some(ChatFormatting::White.try_into().unwrap()),
..Style::default() ..Style::default()
}); });

View file

@ -1,8 +1,7 @@
use std::{collections::HashMap, fmt}; use std::{collections::HashMap, fmt, sync::LazyLock};
#[cfg(feature = "azalea-buf")] #[cfg(feature = "azalea-buf")]
use azalea_buf::AzBuf; use azalea_buf::AzBuf;
use once_cell::sync::Lazy;
use serde::{ser::SerializeStruct, Serialize, Serializer}; use serde::{ser::SerializeStruct, Serialize, Serializer};
use serde_json::Value; use serde_json::Value;
#[cfg(feature = "simdnbt")] #[cfg(feature = "simdnbt")]
@ -57,8 +56,8 @@ impl TextColor {
} }
} }
static LEGACY_FORMAT_TO_COLOR: Lazy<HashMap<&'static ChatFormatting, TextColor>> = static LEGACY_FORMAT_TO_COLOR: LazyLock<HashMap<&'static ChatFormatting, TextColor>> =
Lazy::new(|| { LazyLock::new(|| {
let mut legacy_format_to_color = HashMap::new(); let mut legacy_format_to_color = HashMap::new();
for formatter in &ChatFormatting::FORMATTERS { for formatter in &ChatFormatting::FORMATTERS {
if !formatter.is_format() && *formatter != ChatFormatting::Reset { if !formatter.is_format() && *formatter != ChatFormatting::Reset {
@ -73,7 +72,7 @@ static LEGACY_FORMAT_TO_COLOR: Lazy<HashMap<&'static ChatFormatting, TextColor>>
} }
legacy_format_to_color legacy_format_to_color
}); });
static NAMED_COLORS: Lazy<HashMap<String, TextColor>> = Lazy::new(|| { static NAMED_COLORS: LazyLock<HashMap<String, TextColor>> = LazyLock::new(|| {
let mut named_colors = HashMap::new(); let mut named_colors = HashMap::new();
for color in LEGACY_FORMAT_TO_COLOR.values() { for color in LEGACY_FORMAT_TO_COLOR.values() {
named_colors.insert(color.name.clone().unwrap(), color.clone()); named_colors.insert(color.name.clone().unwrap(), color.clone());

View file

@ -10,7 +10,6 @@ version = "0.10.3+mc1.21.1"
[dependencies] [dependencies]
anyhow = { workspace = true } anyhow = { workspace = true }
#async-trait = { workspace = true }
azalea-auth = { path = "../azalea-auth", version = "0.10.0" } azalea-auth = { path = "../azalea-auth", version = "0.10.0" }
azalea-block = { path = "../azalea-block", version = "0.10.0" } azalea-block = { path = "../azalea-block", version = "0.10.0" }
azalea-buf = { path = "../azalea-buf", version = "0.10.0" } azalea-buf = { path = "../azalea-buf", version = "0.10.0" }
@ -29,15 +28,10 @@ bevy_log = { workspace = true, optional = true }
bevy_tasks = { workspace = true } bevy_tasks = { workspace = true }
bevy_time = { workspace = true } bevy_time = { workspace = true }
derive_more = { workspace = true, features = ["deref", "deref_mut"] } derive_more = { workspace = true, features = ["deref", "deref_mut"] }
#futures = { workspace = true }
minecraft_folder_path = { workspace = true } minecraft_folder_path = { workspace = true }
#nohash-hasher = { workspace = true }
once_cell = { workspace = true }
parking_lot = { workspace = true, features = ["deadlock_detection"] } parking_lot = { workspace = true, features = ["deadlock_detection"] }
regex = { workspace = true } regex = { workspace = true }
reqwest = { workspace = true } reqwest = { workspace = true }
#serde = { workspace = true }
#serde_json = { workspace = true }
simdnbt = { workspace = true } simdnbt = { workspace = true }
thiserror = { workspace = true } thiserror = { workspace = true }
tokio = { workspace = true, features = ["sync"] } tokio = { workspace = true, features = ["sync"] }

View file

@ -40,8 +40,7 @@ pub enum ChatPacket {
macro_rules! regex { macro_rules! regex {
($re:literal $(,)?) => {{ ($re:literal $(,)?) => {{
static RE: once_cell::sync::OnceCell<regex::Regex> = once_cell::sync::OnceCell::new(); std::sync::LazyLock::new(|| regex::Regex::new($re).unwrap())
RE.get_or_init(|| regex::Regex::new($re).unwrap())
}}; }};
} }

View file

@ -9,7 +9,5 @@ version = "0.10.3+mc1.21.1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
once_cell = { workspace = true }
serde = { workspace = true } serde = { workspace = true }
serde_json = { workspace = true } serde_json = { workspace = true }
#tokio = { workspace = true, features = ["fs"] }

View file

@ -1,11 +1,9 @@
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
use std::collections::HashMap; use std::{collections::HashMap, sync::LazyLock};
use once_cell::sync::Lazy; pub static STORAGE: LazyLock<HashMap<String, String>> =
LazyLock::new(|| serde_json::from_str(include_str!("en_us.json")).unwrap());
pub static STORAGE: Lazy<HashMap<String, String>> =
Lazy::new(|| serde_json::from_str(include_str!("en_us.json")).unwrap());
pub fn get(key: &str) -> Option<&str> { pub fn get(key: &str) -> Option<&str> {
STORAGE.get(key).map(|s| s.as_str()) STORAGE.get(key).map(|s| s.as_str())

View file

@ -17,12 +17,7 @@ azalea-registry = { path = "../azalea-registry", version = "0.10.0" }
azalea-world = { path = "../azalea-world", version = "0.10.0" } azalea-world = { path = "../azalea-world", version = "0.10.0" }
bevy_app = { workspace = true } bevy_app = { workspace = true }
bevy_ecs = { workspace = true } bevy_ecs = { workspace = true }
#nohash-hasher = { workspace = true }
once_cell = { workspace = true }
parking_lot = { workspace = true } parking_lot = { workspace = true }
#smallvec = { workspace = true }
#tracing = { workspace = true }
[dev-dependencies] [dev-dependencies]
#bevy_time = { workspace = true }
uuid = { workspace = true } uuid = { workspace = true }

File diff suppressed because it is too large Load diff

View file

@ -55,6 +55,5 @@ packets = ["connecting", "dep:azalea-core"]
[dev-dependencies] [dev-dependencies]
anyhow = { workspace = true } anyhow = { workspace = true }
once_cell = { workspace = true }
tracing = { workspace = true } tracing = { workspace = true }
tracing-subscriber = { workspace = true } tracing-subscriber = { workspace = true }

View file

@ -1,7 +1,7 @@
//! A "simple" server that gets login information and proxies connections. //! A "simple" server that gets login information and proxies connections.
//! After login all connections are encrypted and Azalea cannot read them. //! After login all connections are encrypted and Azalea cannot read them.
use std::error::Error; use std::{error::Error, sync::LazyLock};
use azalea_protocol::{ use azalea_protocol::{
connect::Connection, connect::Connection,
@ -21,7 +21,6 @@ use azalea_protocol::{
read::ReadPacketError, read::ReadPacketError,
}; };
use futures::FutureExt; use futures::FutureExt;
use once_cell::sync::Lazy;
use tokio::{ use tokio::{
io::{self, AsyncWriteExt}, io::{self, AsyncWriteExt},
net::{TcpListener, TcpStream}, net::{TcpListener, TcpStream},
@ -35,9 +34,9 @@ const PROXY_ADDR: &str = "127.0.0.1:25565";
const PROXY_DESC: &str = "An Azalea Minecraft Proxy"; const PROXY_DESC: &str = "An Azalea Minecraft Proxy";
// String must be formatted like "data:image/png;base64,<data>" // String must be formatted like "data:image/png;base64,<data>"
static PROXY_FAVICON: Lazy<Option<String>> = Lazy::new(|| None); static PROXY_FAVICON: LazyLock<Option<String>> = LazyLock::new(|| None);
static PROXY_VERSION: Lazy<Version> = Lazy::new(|| Version { static PROXY_VERSION: LazyLock<Version> = LazyLock::new(|| Version {
name: "1.19.3".to_string(), name: "1.19.3".to_string(),
protocol: PROTOCOL_VERSION, protocol: PROTOCOL_VERSION,
}); });

View file

@ -11,7 +11,6 @@ version = "0.10.3+mc1.21.1"
[dependencies] [dependencies]
azalea-buf = { path = "../azalea-buf", version = "0.10.0" } azalea-buf = { path = "../azalea-buf", version = "0.10.0" }
azalea-registry-macros = { path = "./azalea-registry-macros", version = "0.10.0" } azalea-registry-macros = { path = "./azalea-registry-macros", version = "0.10.0" }
once_cell = { workspace = true }
serde = { workspace = true, optional = true } serde = { workspace = true, optional = true }
simdnbt = { workspace = true } simdnbt = { workspace = true }

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,11 @@
// This file was generated by codegen/lib/code/tags.py, don't edit it manually! // This file was generated by codegen/lib/code/tags.py, don't edit it manually!
use std::collections::HashSet; use std::collections::HashSet;
use std::sync::LazyLock;
use once_cell::sync::Lazy;
use crate::Fluid; use crate::Fluid;
pub static LAVA: Lazy<HashSet<Fluid>> = pub static LAVA: LazyLock<HashSet<Fluid>> =
Lazy::new(|| HashSet::from_iter(vec![Fluid::Lava, Fluid::FlowingLava])); LazyLock::new(|| HashSet::from_iter(vec![Fluid::Lava, Fluid::FlowingLava]));
pub static WATER: Lazy<HashSet<Fluid>> = pub static WATER: LazyLock<HashSet<Fluid>> =
Lazy::new(|| HashSet::from_iter(vec![Fluid::Water, Fluid::FlowingWater])); LazyLock::new(|| HashSet::from_iter(vec![Fluid::Water, Fluid::FlowingWater]));

File diff suppressed because it is too large Load diff

View file

@ -18,15 +18,11 @@ azalea-registry = { path = "../azalea-registry", version = "0.10.0" }
bevy_ecs = { workspace = true } bevy_ecs = { workspace = true }
derive_more = { workspace = true, features = ["deref", "deref_mut"] } derive_more = { workspace = true, features = ["deref", "deref_mut"] }
nohash-hasher = { workspace = true } nohash-hasher = { workspace = true }
#once_cell = { workspace = true }
parking_lot = { workspace = true } parking_lot = { workspace = true }
rustc-hash = { workspace = true } rustc-hash = { workspace = true }
#serde = { workspace = true }
#serde_json = { workspace = true }
simdnbt = { workspace = true } simdnbt = { workspace = true }
thiserror = { workspace = true } thiserror = { workspace = true }
tracing = { workspace = true } tracing = { workspace = true }
#uuid = { workspace = true }
[dev-dependencies] [dev-dependencies]
azalea-client = { path = "../azalea-client" } azalea-client = { path = "../azalea-client" }

View file

@ -229,8 +229,9 @@ fn execute_descend_move(mut ctx: ExecuteCtx) {
let center = target.center(); let center = target.center();
let horizontal_distance_from_target = (center - position).horizontal_distance_squared().sqrt(); let horizontal_distance_from_target = (center - position).horizontal_distance_squared().sqrt();
let horizontal_distance_from_start = let horizontal_distance_from_start = (start.center() - position)
(start.center() - position).horizontal_distance_squared().sqrt(); .horizontal_distance_squared()
.sqrt();
let dest_ahead = Vec3::new( let dest_ahead = Vec3::new(
start_center.x + (center.x - start_center.x) * 1.5, start_center.x + (center.x - start_center.x) * 1.5,
@ -401,8 +402,9 @@ fn execute_downward_move(mut ctx: ExecuteCtx) {
let target_center = target.center(); let target_center = target.center();
let horizontal_distance_from_target = let horizontal_distance_from_target = (target_center - position)
(target_center - position).horizontal_distance_squared().sqrt(); .horizontal_distance_squared()
.sqrt();
if horizontal_distance_from_target > 0.25 { if horizontal_distance_from_target > 0.25 {
ctx.look_at(target_center); ctx.look_at(target_center);

View file

@ -71,7 +71,7 @@ def generate_block_shapes_code(blocks: dict, shapes: dict, block_states_report):
generated_shape_code += generate_code_for_shape(shape_id, shape) generated_shape_code += generate_code_for_shape(shape_id, shape)
# static SHAPES_MAP: [&Lazy<VoxelShape>; 26644] = [&SHAPE0, &SHAPE1, &SHAPE1, ...] # static SHAPES_MAP: [&LazyLock<VoxelShape>; 26644] = [&SHAPE0, &SHAPE1, &SHAPE1, ...]
empty_shapes = [] empty_shapes = []
full_shapes = [] full_shapes = []
@ -98,7 +98,7 @@ def generate_block_shapes_code(blocks: dict, shapes: dict, block_states_report):
generated_map_code = f'static SHAPES_MAP: [&Lazy<VoxelShape>; {len(shapes_map)}] = [' generated_map_code = f'static SHAPES_MAP: [&LazyLock<VoxelShape>; {len(shapes_map)}] = ['
empty_shape_match_code = convert_ints_to_rust_ranges(empty_shapes) empty_shape_match_code = convert_ints_to_rust_ranges(empty_shapes)
block_shape_match_code = convert_ints_to_rust_ranges(full_shapes) block_shape_match_code = convert_ints_to_rust_ranges(full_shapes)
@ -122,7 +122,7 @@ def generate_block_shapes_code(blocks: dict, shapes: dict, block_states_report):
use super::VoxelShape; use super::VoxelShape;
use crate::collision::{{self, Shapes}}; use crate::collision::{{self, Shapes}};
use azalea_block::*; use azalea_block::*;
use once_cell::sync::Lazy; use std::sync::LazyLock;
pub trait BlockWithShape {{ pub trait BlockWithShape {{
fn shape(&self) -> &'static VoxelShape; fn shape(&self) -> &'static VoxelShape;
@ -160,7 +160,7 @@ def generate_code_for_shape(shape_id: str, parts: list[list[float]]):
def make_arguments(part: list[float]): def make_arguments(part: list[float]):
return ', '.join(map(lambda n: str(n).rstrip('0'), part)) return ', '.join(map(lambda n: str(n).rstrip('0'), part))
code = '' code = ''
code += f'static SHAPE{shape_id}: Lazy<VoxelShape> = Lazy::new(|| {{' code += f'static SHAPE{shape_id}: LazyLock<VoxelShape> = LazyLock::new(|| {{'
steps = [] steps = []
if parts == (): if parts == ():
steps.append('collision::EMPTY_SHAPE.clone()') steps.append('collision::EMPTY_SHAPE.clone()')

View file

@ -9,8 +9,7 @@ def generate_tags(registries: dict, file_name: str, struct_name: str):
generated = f'''// This file was generated by codegen/lib/code/tags.py, don't edit it manually! generated = f'''// This file was generated by codegen/lib/code/tags.py, don't edit it manually!
use std::collections::HashSet; use std::collections::HashSet;
use std::sync::LazyLock;
use once_cell::sync::Lazy;
use crate::{struct_name}; use crate::{struct_name};
@ -19,7 +18,7 @@ use crate::{struct_name};
for tag_name, tag in sorted(registries.items(), key=lambda x: x[0]): for tag_name, tag in sorted(registries.items(), key=lambda x: x[0]):
tag_name = tag_name.replace('/', '_') tag_name = tag_name.replace('/', '_')
static_set_name = to_snake_case(tag_name).upper() static_set_name = to_snake_case(tag_name).upper()
generated += f'pub static {static_set_name}: Lazy<HashSet<{struct_name}>> = Lazy::new(|| HashSet::from_iter(vec![' generated += f'pub static {static_set_name}: LazyLock<HashSet<{struct_name}>> = LazyLock::new(|| HashSet::from_iter(vec!['
queue = tag['values'].copy() queue = tag['values'].copy()
while queue != []: while queue != []: