aboutsummaryrefslogtreecommitdiff
path: root/azalea-chat/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-chat/src/lib.rs')
-rw-r--r--azalea-chat/src/lib.rs12
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)
+}