diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-12-12 00:56:02 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-12 00:56:02 -0600 |
| commit | f9c25665c203d6377ace62f1e95381d037d8fd9e (patch) | |
| tree | 8b4131d20fe661d3cc1175ec27f801fe61df41ea /azalea-core/src/registry_holder | |
| parent | 82ad975242292d5875780b4398b62637674bf50a (diff) | |
| download | azalea-drasl-f9c25665c203d6377ace62f1e95381d037d8fd9e.tar.xz | |
Refactor azalea-registry (#294)
* move registries in azalea-registry into separate modules
* rename Item and Block to ItemKind and BlockKind
* remove 'extra' registries from azalea-registry
* hide deprecated items from docs
* use DamageKindKey instead of Identifier when parsing registries
* store tag entries as a Vec instead of a HashSet
* sort tag values by protocol id
* update changelog
Diffstat (limited to 'azalea-core/src/registry_holder')
| -rw-r--r-- | azalea-core/src/registry_holder/components.rs | 2 | ||||
| -rw-r--r-- | azalea-core/src/registry_holder/dimension_type.rs | 13 | ||||
| -rw-r--r-- | azalea-core/src/registry_holder/enchantment.rs | 2 | ||||
| -rw-r--r-- | azalea-core/src/registry_holder/entity_effect.rs | 14 | ||||
| -rw-r--r-- | azalea-core/src/registry_holder/float_provider.rs | 2 | ||||
| -rw-r--r-- | azalea-core/src/registry_holder/mod.rs | 8 | ||||
| -rw-r--r-- | azalea-core/src/registry_holder/value.rs | 8 |
7 files changed, 26 insertions, 23 deletions
diff --git a/azalea-core/src/registry_holder/components.rs b/azalea-core/src/registry_holder/components.rs index e7f94cd8..cbd6384d 100644 --- a/azalea-core/src/registry_holder/components.rs +++ b/azalea-core/src/registry_holder/components.rs @@ -1,6 +1,6 @@ use std::{any::Any, fmt::Debug, mem::ManuallyDrop, str::FromStr}; -use azalea_registry::{EnchantmentEffectComponentKind, SoundEvent}; +use azalea_registry::builtin::{EnchantmentEffectComponentKind, SoundEvent}; use simdnbt::{ DeserializeError, borrow::{NbtCompound, NbtList, NbtTag}, diff --git a/azalea-core/src/registry_holder/dimension_type.rs b/azalea-core/src/registry_holder/dimension_type.rs index ca158277..86dd2b3e 100644 --- a/azalea-core/src/registry_holder/dimension_type.rs +++ b/azalea-core/src/registry_holder/dimension_type.rs @@ -1,12 +1,13 @@ use std::collections::HashMap; use azalea_buf::AzBuf; +use azalea_registry::{builtin::SoundEvent, identifier::Identifier}; use simdnbt::{ Deserialize, FromNbtTag, Serialize, ToNbtTag, owned::{NbtCompound, NbtTag}, }; -use crate::{codec_utils::*, identifier::Identifier}; +use crate::codec_utils::*; #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "strict_registry", simdnbt(deny_unknown_fields))] @@ -51,7 +52,7 @@ pub struct ChatTypeStyle { #[cfg(feature = "strict_registry")] #[derive(Debug, Clone, Serialize, Deserialize)] #[simdnbt(deny_unknown_fields)] -pub struct DimensionTypeElement { +pub struct DimensionKindElement { pub ambient_light: f32, pub bed_works: bool, pub coordinate_scale: f32, @@ -75,7 +76,7 @@ pub struct DimensionTypeElement { /// Dimension attributes. #[cfg(not(feature = "strict_registry"))] #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct DimensionTypeElement { +pub struct DimensionKindElement { pub height: u32, pub min_y: i32, pub ultrawarm: Option<bool>, @@ -208,7 +209,7 @@ pub struct BiomeMusic { pub replace_current_music: bool, pub max_delay: u32, pub min_delay: u32, - pub sound: azalea_registry::SoundEvent, + pub sound: SoundEvent, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -217,14 +218,14 @@ pub struct BiomeMoodSound { pub tick_delay: u32, pub block_search_extent: u32, pub offset: f32, - pub sound: azalea_registry::SoundEvent, + pub sound: SoundEvent, } #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "strict_registry", simdnbt(deny_unknown_fields))] pub struct AdditionsSound { pub tick_chance: f32, - pub sound: azalea_registry::SoundEvent, + pub sound: SoundEvent, } /// Biome particles. diff --git a/azalea-core/src/registry_holder/enchantment.rs b/azalea-core/src/registry_holder/enchantment.rs index 0f78843c..8d825baf 100644 --- a/azalea-core/src/registry_holder/enchantment.rs +++ b/azalea-core/src/registry_holder/enchantment.rs @@ -1,6 +1,6 @@ use std::{any::Any, fmt::Debug, str::FromStr}; -use azalea_registry::EnchantmentEffectComponentKind; +use azalea_registry::builtin::EnchantmentEffectComponentKind; use indexmap::IndexMap; use simdnbt::{DeserializeError, borrow::NbtCompound}; diff --git a/azalea-core/src/registry_holder/entity_effect.rs b/azalea-core/src/registry_holder/entity_effect.rs index 442b0e1a..ef08b7f0 100644 --- a/azalea-core/src/registry_holder/entity_effect.rs +++ b/azalea-core/src/registry_holder/entity_effect.rs @@ -1,7 +1,12 @@ use std::{collections::HashMap, str::FromStr}; use azalea_registry::{ - EnchantmentEntityEffectKind as EntityEffectKind, GameEvent, Holder, ParticleKind, SoundEvent, + Holder, + builtin::{ + EnchantmentEntityEffectKind as EntityEffectKind, GameEvent, ParticleKind, SoundEvent, + }, + data::DamageKindKey, + identifier::Identifier, }; use simdnbt::{ Deserialize, DeserializeError, @@ -9,7 +14,6 @@ use simdnbt::{ }; use crate::{ - identifier::Identifier, position::{Vec3, Vec3i}, registry_holder::{ block_predicate::BlockPredicate, block_state_provider::BlockStateProvider, @@ -129,17 +133,15 @@ pub struct ChangeItemDamage { pub struct DamageEntity { pub min_damage: LevelBasedValue, pub max_damage: LevelBasedValue, - // TODO: convert to a DamageKind after azalea-registry refactor #[simdnbt(rename = "damage_type")] - pub damage_kind: Identifier, + pub damage_kind: DamageKindKey, } #[derive(Debug, Clone, simdnbt::Deserialize)] pub struct Explode { pub attribute_to_user: Option<bool>, - // TODO: convert to a DamageKind after azalea-registry refactor #[simdnbt(rename = "damage_type")] - pub damage_kind: Option<Identifier>, + pub damage_kind: Option<DamageKindKey>, pub knockback_multiplier: Option<LevelBasedValue>, pub immune_blocks: Option<HomogeneousList>, pub offset: Option<Vec3>, diff --git a/azalea-core/src/registry_holder/float_provider.rs b/azalea-core/src/registry_holder/float_provider.rs index 6ce6b26d..c7d56bf9 100644 --- a/azalea-core/src/registry_holder/float_provider.rs +++ b/azalea-core/src/registry_holder/float_provider.rs @@ -1,6 +1,6 @@ use std::ops::Range; -use azalea_registry::FloatProviderKind; +use azalea_registry::builtin::FloatProviderKind; use simdnbt::{ DeserializeError, FromNbtTag, borrow::{NbtCompound, NbtTag}, diff --git a/azalea-core/src/registry_holder/mod.rs b/azalea-core/src/registry_holder/mod.rs index 269cf454..886c75e1 100644 --- a/azalea-core/src/registry_holder/mod.rs +++ b/azalea-core/src/registry_holder/mod.rs @@ -16,13 +16,12 @@ pub mod value; use std::{collections::HashMap, io::Cursor}; +use azalea_registry::identifier::Identifier; use indexmap::IndexMap; use simdnbt::{DeserializeError, FromNbtTag, borrow, owned::NbtCompound}; use thiserror::Error; use tracing::error; -use crate::identifier::Identifier; - /// The base of the registry. /// /// This is the registry that is sent to the client upon login. @@ -39,7 +38,7 @@ pub struct RegistryHolder { #[rustfmt::skip] // allow empty line /// Attributes about the dimension. - pub dimension_type: RegistryType<dimension_type::DimensionTypeElement>, + pub dimension_type: RegistryType<dimension_type::DimensionKindElement>, pub enchantment: RegistryType<enchantment::EnchantmentData>, @@ -93,7 +92,6 @@ macro_rules! registry_holder { ) -> Option<&Identifier> { let index = protocol_id as usize; - if registry.namespace() == "minecraft" { match registry.path() { $( @@ -189,7 +187,7 @@ impl RegistryDeserializesTo for NbtCompound { .get_index(protocol_id as usize) } } -impl RegistryDeserializesTo for dimension_type::DimensionTypeElement { +impl RegistryDeserializesTo for dimension_type::DimensionKindElement { fn get_for_registry<'a>( registries: &'a RegistryHolder, registry_name: &'static str, diff --git a/azalea-core/src/registry_holder/value.rs b/azalea-core/src/registry_holder/value.rs index ccd7f9ea..964d1e5a 100644 --- a/azalea-core/src/registry_holder/value.rs +++ b/azalea-core/src/registry_holder/value.rs @@ -1,6 +1,9 @@ use azalea_registry::{ - Attribute, EnchantmentLevelBasedValueKind as LevelBasedValueKind, - EnchantmentValueEffectKind as ValueEffectKind, + builtin::{ + Attribute, EnchantmentLevelBasedValueKind as LevelBasedValueKind, + EnchantmentValueEffectKind as ValueEffectKind, + }, + identifier::Identifier, }; use simdnbt::{ DeserializeError, FromNbtTag, @@ -9,7 +12,6 @@ use simdnbt::{ use crate::{ attribute_modifier_operation::AttributeModifierOperation, - identifier::Identifier, registry_holder::{components::impl_from_effect_nbt_tag, get_in_compound}, }; |
