diff options
Diffstat (limited to 'azalea-chat/src/base_component.rs')
| -rwxr-xr-x | azalea-chat/src/base_component.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/azalea-chat/src/base_component.rs b/azalea-chat/src/base_component.rs index dcc28ecc..8f70ecb7 100755 --- a/azalea-chat/src/base_component.rs +++ b/azalea-chat/src/base_component.rs @@ -19,6 +19,26 @@ impl BaseComponent { } } +#[cfg(feature = "simdnbt")] +impl simdnbt::Serialize for BaseComponent { + fn to_compound(self) -> simdnbt::owned::NbtCompound { + let mut compound = simdnbt::owned::NbtCompound::new(); + if !self.siblings.is_empty() { + compound.insert( + "extra", + simdnbt::owned::NbtList::from( + self.siblings + .into_iter() + .map(|component| component.to_compound()) + .collect::<Vec<_>>(), + ), + ); + } + compound.extend(self.style.to_compound()); + compound + } +} + impl Default for BaseComponent { fn default() -> Self { Self::new() |
