diff --git a/crates/horizon-client/src/game/books.rs b/crates/horizon-client/src/game/books.rs index 07d65c5a4..4c1a03129 100644 --- a/crates/horizon-client/src/game/books.rs +++ b/crates/horizon-client/src/game/books.rs @@ -76,9 +76,11 @@ fn view_pages(data: Option<&StackData>) -> Vec { .iter() .enumerate() .map(|(i, page)| match tagged.then(|| &w.page_tags[i]) { - Some(tag @ horizon_world::nbt::Tag::Compound(_)) => { - horizon_client::entity_nbt::name_text(tag) - } + // A component object, or a component list (`ComponentSerialization` + // takes both; servers behind ViaVersion send the list form). + Some( + tag @ (horizon_world::nbt::Tag::Compound(_) | horizon_world::nbt::Tag::List(_)), + ) => horizon_client::entity_nbt::name_text(tag), _ => Text::literal(page), }) .collect() @@ -137,6 +139,18 @@ impl Game<'_> { } } ClickEvent::OpenUrl(url) => self.click_url(url), + ClickEvent::RunCommand(command) => self.click_command(&command), + ClickEvent::SuggestCommand(command) => { + // defaultHandleClickEvent: the chat screen takes it over. + if self.player.is_some() { + self.close_book(); + self.open_chat(&command); + } + } + ClickEvent::CopyToClipboard(value) => { + use horizon_client::clipboard::Clipboard; + self.clipboard.set(&value); + } _ => {} } } diff --git a/crates/horizon-client/src/game/chat.rs b/crates/horizon-client/src/game/chat.rs index 49ad2be44..4ed7a0571 100644 --- a/crates/horizon-client/src/game/chat.rs +++ b/crates/horizon-client/src/game/chat.rs @@ -859,7 +859,7 @@ impl Game<'_> { /// first, as `ClientPacketListener.sendUnattendedCommand` lets client /// commands take it. (Vanilla asks first when the command fails to /// parse; here the server answers it.) - fn click_command(&mut self, command: &str) { + pub(super) fn click_command(&mut self, command: &str) { let command = command.strip_prefix('/').unwrap_or(command); if self.mod_command(command) { return;