aboutsummaryrefslogtreecommitdiff
path: root/azalea-registry/src
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-registry/src')
-rw-r--r--azalea-registry/src/lib.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/azalea-registry/src/lib.rs b/azalea-registry/src/lib.rs
index 42950167..fd3fc3b5 100644
--- a/azalea-registry/src/lib.rs
+++ b/azalea-registry/src/lib.rs
@@ -20,6 +20,7 @@ pub use data::*;
pub use extra::*;
#[cfg(feature = "serde")]
use serde::Serialize;
+use simdnbt::{FromNbtTag, borrow::NbtTag};
pub trait Registry: AzaleaRead + AzaleaWrite
where
@@ -257,6 +258,19 @@ impl<R: Registry + Serialize, Direct: AzaleaRead + AzaleaWrite + Serialize> Seri
}
}
+impl<
+ R: Registry + Serialize + FromNbtTag,
+ Direct: AzaleaRead + AzaleaWrite + Serialize + FromNbtTag,
+> FromNbtTag for Holder<R, Direct>
+{
+ fn from_nbt_tag(tag: NbtTag) -> Option<Self> {
+ if let Some(reference) = R::from_nbt_tag(tag) {
+ return Some(Self::Reference(reference));
+ };
+ Direct::from_nbt_tag(tag).map(Self::Direct)
+ }
+}
+
registry! {
/// The AI code that's currently being executed for the entity.
enum Activity {