diff --git a/Cargo.lock b/Cargo.lock index b204a8850..7fa6f7335 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2031,7 +2031,6 @@ dependencies = [ "flate2", "futures", "itertools 0.13.0", - "lazy_static", "log", "num-derive", "num-traits", diff --git a/pumpkin-world/Cargo.toml b/pumpkin-world/Cargo.toml index 4008eaa84..7a5d04191 100644 --- a/pumpkin-world/Cargo.toml +++ b/pumpkin-world/Cargo.toml @@ -15,7 +15,6 @@ thiserror = "1.0.63" futures = "0.3.30" flate2 = "1.0.33" serde = { version = "1.0", features = ["derive"] } -lazy_static = "1.5.0" serde_json = "1.0" static_assertions = "1.1.0" log.workspace = true diff --git a/pumpkin-world/src/block/block_registry.rs b/pumpkin-world/src/block/block_registry.rs index c6c9b96f4..7d7b3f69f 100644 --- a/pumpkin-world/src/block/block_registry.rs +++ b/pumpkin-world/src/block/block_registry.rs @@ -1,15 +1,13 @@ -use std::collections::HashMap; +use std::{collections::HashMap, sync::LazyLock}; -use lazy_static::lazy_static; use serde::Deserialize; use super::block_id::BlockId; -lazy_static! { - pub static ref BLOCKS: HashMap = - serde_json::from_str(include_str!("../../assets/blocks.json")) - .expect("Could not parse block.json registry."); -} +pub static BLOCKS: LazyLock> = LazyLock::new(|| { + serde_json::from_str(include_str!("../../assets/blocks.json")) + .expect("Could not parse block.json registry.") +}); #[derive(Deserialize, Debug, Clone, PartialEq, Eq)] pub struct RegistryBlockDefinition { diff --git a/pumpkin-world/src/global_registry.rs b/pumpkin-world/src/global_registry.rs index 6a7aeafa1..1723cb8f8 100644 --- a/pumpkin-world/src/global_registry.rs +++ b/pumpkin-world/src/global_registry.rs @@ -1,6 +1,4 @@ -use std::collections::HashMap; - -use lazy_static::lazy_static; +use std::{collections::HashMap, sync::LazyLock}; pub const ITEM_REGISTRY: &str = "minecraft:item"; @@ -12,10 +10,9 @@ pub struct RegistryElement { pub entries: HashMap>, } -lazy_static! { - pub static ref REGISTRY: HashMap = - serde_json::from_str(REGISTRY_JSON).expect("Could not parse registry.json registry."); -} +pub static REGISTRY: LazyLock> = LazyLock::new(|| { + serde_json::from_str(REGISTRY_JSON).expect("Could not parse registry.json registry.") +}); pub fn get_protocol_id(category: &str, entry: &str) -> u32 { *REGISTRY diff --git a/pumpkin-world/src/item/item_registry.rs b/pumpkin-world/src/item/item_registry.rs index 81794c063..9f3f64ab4 100644 --- a/pumpkin-world/src/item/item_registry.rs +++ b/pumpkin-world/src/item/item_registry.rs @@ -1,13 +1,14 @@ -use std::collections::HashMap; - -use lazy_static::lazy_static; - -use crate::global_registry::{self, ITEM_REGISTRY}; +use std::{collections::HashMap, sync::LazyLock}; use super::Rarity; +use crate::global_registry::{self, ITEM_REGISTRY}; const ITEMS_JSON: &str = include_str!("../../assets/items.json"); +pub static ITEMS: LazyLock> = LazyLock::new(|| { + serde_json::from_str(ITEMS_JSON).expect("Could not parse items.json registry.") +}); + #[derive(serde::Deserialize, Debug, Clone, PartialEq, Eq)] pub struct ItemComponents { // TODO: attribute_modifiers @@ -27,11 +28,6 @@ pub struct ItemElement { components: ItemComponents, } -lazy_static! { - pub static ref ITEMS: HashMap = - serde_json::from_str(ITEMS_JSON).expect("Could not parse items.json registry."); -} - #[allow(dead_code)] pub fn get_item_element(item_id: &str) -> &ItemComponents { &ITEMS.get(item_id).expect("Item not found").components