diff options
| author | mat <git@matdoes.dev> | 2026-01-19 16:48:49 -1100 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-01-19 16:48:49 -1100 |
| commit | b7ad0e60f7b0a5f5a1f6a2c80abc865fdb250ee5 (patch) | |
| tree | 683c9ea01e0be320f76cd817fbf9da4f9c5d76d8 /azalea-chat/src/lib.rs | |
| parent | 7c1be0aa47cfee6ffcb114860ccb715dbad109a5 (diff) | |
| download | azalea-drasl-b7ad0e60f7b0a5f5a1f6a2c80abc865fdb250ee5.tar.xz | |
deserialize ClickEvent from nbt
Diffstat (limited to 'azalea-chat/src/lib.rs')
| -rw-r--r-- | azalea-chat/src/lib.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/azalea-chat/src/lib.rs b/azalea-chat/src/lib.rs index 4e0c38bf..fef2697e 100644 --- a/azalea-chat/src/lib.rs +++ b/azalea-chat/src/lib.rs @@ -11,3 +11,15 @@ pub mod text_component; pub mod translatable_component; pub use component::{DEFAULT_STYLE, FormattedText}; +#[cfg(feature = "simdnbt")] +use simdnbt::{DeserializeError, FromNbtTag}; + +// TODO: remove this after simdnbt refactor +#[cfg(feature = "simdnbt")] +pub(crate) fn get_in_compound<T: FromNbtTag>( + compound: &simdnbt::borrow::NbtCompound, + key: &str, +) -> Result<T, DeserializeError> { + let value = compound.get(key).ok_or(DeserializeError::MissingField)?; + T::from_nbt_tag(value).ok_or(DeserializeError::MissingField) +} |
