diff options
| author | mat <git@matdoes.dev> | 2025-09-26 06:16:33 +0800 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-09-25 19:20:09 -0300 |
| commit | 730297cf561d42fd9132eb201d1aec0d3d7c7e00 (patch) | |
| tree | d26f63b8a4553cc1b07c41a5b1a06aba773e60c4 /azalea-chat/src/hover_event.rs | |
| parent | 8927a0fe65f5f89b4459956f19989f27f1e0981c (diff) | |
| download | azalea-drasl-730297cf561d42fd9132eb201d1aec0d3d7c7e00.tar.xz | |
fix compile error with new serde version, and update deps
Diffstat (limited to 'azalea-chat/src/hover_event.rs')
| -rw-r--r-- | azalea-chat/src/hover_event.rs | 28 |
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 + } +} |
