aboutsummaryrefslogtreecommitdiff
path: root/azalea-chat/src/hover_event.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-chat/src/hover_event.rs')
-rw-r--r--azalea-chat/src/hover_event.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/azalea-chat/src/hover_event.rs b/azalea-chat/src/hover_event.rs
index a18a3047..825c253b 100644
--- a/azalea-chat/src/hover_event.rs
+++ b/azalea-chat/src/hover_event.rs
@@ -1,4 +1,6 @@
use serde::Serialize;
+#[cfg(feature = "simdnbt")]
+use simdnbt::owned::NbtCompound;
use crate::FormattedText;
@@ -18,3 +20,29 @@ pub enum HoverEvent {
name: Box<FormattedText>,
},
}
+
+#[cfg(feature = "simdnbt")]
+impl simdnbt::Serialize for HoverEvent {
+ fn to_compound(self) -> NbtCompound {
+ let mut compound = NbtCompound::new();
+ let mut action = |s: &str| {
+ compound.insert("action", s);
+ };
+ match self {
+ HoverEvent::ShowText { value } => {
+ action("show_text");
+ compound.insert("value", value.to_compound());
+ }
+ HoverEvent::ShowItem { .. } => {
+ action("show_item");
+ }
+ HoverEvent::ShowEntity { id, name } => {
+ action("show_entity");
+ compound.insert("id", id);
+ // compound.insert("uuid", uuid.to_string());
+ compound.insert("name", name.to_compound());
+ }
+ }
+ compound
+ }
+}