mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
replace once_cell with std:;sync::LazyLock
This commit is contained in:
parent
dfdc3144b6
commit
0817382098
23 changed files with 989 additions and 978 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -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",
|
||||||
]
|
]
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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"] }
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -15,10 +15,11 @@ azalea-buf = ["dep:azalea-buf", "simdnbt"]
|
||||||
numbers = ["dep:azalea-registry", "dep:simdnbt"]
|
numbers = ["dep:azalea-registry", "dep:simdnbt"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
azalea-buf = { path = "../azalea-buf", features = ["serde_json"], version = "0.10.0", optional = true }
|
azalea-buf = { path = "../azalea-buf", features = [
|
||||||
|
"serde_json",
|
||||||
|
], 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 }
|
||||||
|
|
|
@ -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::{BufReadError, McBufReadable, McBufWritable};
|
use azalea_buf::{BufReadError, McBufReadable, McBufWritable};
|
||||||
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()
|
||||||
});
|
});
|
||||||
|
|
|
@ -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::McBuf;
|
use azalea_buf::McBuf;
|
||||||
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());
|
||||||
|
|
|
@ -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"] }
|
||||||
|
|
|
@ -37,8 +37,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())
|
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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"] }
|
|
||||||
|
|
|
@ -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())
|
||||||
|
|
|
@ -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
|
@ -12,10 +12,17 @@ version = "0.10.3+mc1.21.1"
|
||||||
async-recursion = { workspace = true }
|
async-recursion = { 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", default-features = false, version = "0.10.0" }
|
azalea-block = { path = "../azalea-block", default-features = false, version = "0.10.0" }
|
||||||
azalea-brigadier = { path = "../azalea-brigadier", version = "0.10.0", features = ["azalea-buf"] }
|
azalea-brigadier = { path = "../azalea-brigadier", version = "0.10.0", features = [
|
||||||
|
"azalea-buf",
|
||||||
|
] }
|
||||||
azalea-buf = { path = "../azalea-buf", version = "0.10.0" }
|
azalea-buf = { path = "../azalea-buf", version = "0.10.0" }
|
||||||
azalea-chat = { path = "../azalea-chat", version = "0.10.0", features = ["numbers", "azalea-buf"] }
|
azalea-chat = { path = "../azalea-chat", version = "0.10.0", features = [
|
||||||
azalea-core = { path = "../azalea-core", optional = true, version = "0.10.0", features = ["serde"] }
|
"numbers",
|
||||||
|
"azalea-buf",
|
||||||
|
] }
|
||||||
|
azalea-core = { path = "../azalea-core", optional = true, version = "0.10.0", features = [
|
||||||
|
"serde",
|
||||||
|
] }
|
||||||
azalea-crypto = { path = "../azalea-crypto", version = "0.10.0" }
|
azalea-crypto = { path = "../azalea-crypto", version = "0.10.0" }
|
||||||
azalea-entity = { version = "0.10.0", path = "../azalea-entity" }
|
azalea-entity = { version = "0.10.0", path = "../azalea-entity" }
|
||||||
azalea-inventory = { version = "0.10.0", path = "../azalea-inventory" }
|
azalea-inventory = { version = "0.10.0", path = "../azalea-inventory" }
|
||||||
|
@ -48,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 }
|
||||||
|
|
|
@ -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,
|
||||||
|
@ -23,7 +23,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},
|
||||||
|
@ -37,9 +36,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,
|
||||||
});
|
});
|
||||||
|
|
|
@ -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
|
@ -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
|
@ -11,20 +11,18 @@ version = "0.10.3+mc1.21.1"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
azalea-block = { path = "../azalea-block", default-features = false, version = "0.10.0" }
|
azalea-block = { path = "../azalea-block", default-features = false, version = "0.10.0" }
|
||||||
azalea-buf = { path = "../azalea-buf", version = "0.10.0" }
|
azalea-buf = { path = "../azalea-buf", version = "0.10.0" }
|
||||||
azalea-core = { path = "../azalea-core", version = "0.10.0", features = ["bevy_ecs"] }
|
azalea-core = { path = "../azalea-core", version = "0.10.0", features = [
|
||||||
|
"bevy_ecs",
|
||||||
|
] }
|
||||||
azalea-registry = { path = "../azalea-registry", version = "0.10.0" }
|
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" }
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
//! The goals that a pathfinder can try to reach.
|
//! The goals that a pathfinder can try to reach.
|
||||||
|
|
||||||
|
use std::f32::consts::SQRT_2;
|
||||||
|
|
||||||
use azalea_core::position::{BlockPos, Vec3};
|
use azalea_core::position::{BlockPos, Vec3};
|
||||||
use azalea_world::ChunkStorage;
|
use azalea_world::ChunkStorage;
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::f32::consts::SQRT_2;
|
|
||||||
|
|
||||||
use super::costs::{COST_HEURISTIC, FALL_N_BLOCKS_COST, JUMP_ONE_BLOCK_COST};
|
use super::costs::{COST_HEURISTIC, FALL_N_BLOCKS_COST, JUMP_ONE_BLOCK_COST};
|
||||||
|
|
||||||
|
|
|
@ -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 = []
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ def generate_block_shapes_code(blocks: dict, shapes: dict, block_states_report,
|
||||||
block_state_ids_to_shape_ids.append((block_state_id, shape_id))
|
block_state_ids_to_shape_ids.append((block_state_id, shape_id))
|
||||||
|
|
||||||
|
|
||||||
generated_map_code = f'static SHAPES_MAP: [&Lazy<VoxelShape>; {len(block_state_ids_to_shape_ids)}] = ['
|
generated_map_code = f'static SHAPES_MAP: [&LazyLock<VoxelShape>; {len(block_state_ids_to_shape_ids)}] = ['
|
||||||
|
|
||||||
block_state_ids_to_shape_ids = sorted(block_state_ids_to_shape_ids, key=lambda x: x[0])
|
block_state_ids_to_shape_ids = sorted(block_state_ids_to_shape_ids, key=lambda x: x[0])
|
||||||
|
|
||||||
|
@ -118,7 +118,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;
|
||||||
|
@ -156,7 +156,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()')
|
||||||
|
|
|
@ -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 != []:
|
||||||
|
|
Loading…
Add table
Reference in a new issue