aboutsummaryrefslogtreecommitdiff
path: root/azalea-chat/src/text_component.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-chat/src/text_component.rs')
-rwxr-xr-xazalea-chat/src/text_component.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/azalea-chat/src/text_component.rs b/azalea-chat/src/text_component.rs
index fefd2cb8..6f95840d 100755
--- a/azalea-chat/src/text_component.rs
+++ b/azalea-chat/src/text_component.rs
@@ -24,6 +24,28 @@ impl Serialize for TextComponent {
}
}
+#[cfg(feature = "simdnbt")]
+impl simdnbt::Serialize for TextComponent {
+ fn to_compound(self) -> simdnbt::owned::NbtCompound {
+ let mut compound = simdnbt::owned::NbtCompound::new();
+ compound.insert("text", self.text);
+ compound.extend(self.base.style.to_compound());
+ if !self.base.siblings.is_empty() {
+ compound.insert(
+ "extra",
+ simdnbt::owned::NbtList::from(
+ self.base
+ .siblings
+ .into_iter()
+ .map(|component| component.to_compound())
+ .collect::<Vec<_>>(),
+ ),
+ );
+ }
+ compound
+ }
+}
+
const LEGACY_FORMATTING_CODE_SYMBOL: char = 'ยง';
/// Convert a legacy color code string into a FormattedText