From 1d90d72a64418071f943e404166fa39b09f50981 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 25 Oct 2026 02:14:59 +0100 Subject: [PATCH 1/2] Server dialogs: the packets and the dialog model show_dialog and clear_dialog in configuration and play, and custom_click_action, the answer, in both. Dialog.DIRECT_CODEC as horizon_client::dialog: the five dialog types, their bodies, inputs and actions with vanilla's defaults, the values inputs hold, and Action.createAction (a command template's $(key) substitution with escapeWithoutQuotes, a custom action's payload of every input's tag). Nothing uses them yet: the screen comes next. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/dialog.rs | 794 ++++++++++++++++++ crates/horizon-client/src/lib.rs | 1 + .../src/packets/configuration.rs | 52 ++ crates/horizon-protocol/src/packets/play.rs | 60 +- 4 files changed, 905 insertions(+), 2 deletions(-) create mode 100644 crates/horizon-client/src/dialog.rs diff --git a/crates/horizon-client/src/dialog.rs b/crates/horizon-client/src/dialog.rs new file mode 100644 index 000000000..7acd3e86a --- /dev/null +++ b/crates/horizon-client/src/dialog.rs @@ -0,0 +1,794 @@ +//! Server dialogs (`net.minecraft.server.dialog`): what `Dialog.DIRECT_CODEC` +//! decodes from a `show_dialog` packet, the values its inputs hold, and the +//! click event an action makes of them (`Action.createAction`). +use crate::text::Text; +use horizon_world::nbt::Tag; +use serde_json::{Value, json}; + +/// `CommonDialogData` and the type's own fields. +#[derive(Clone, Debug)] +pub struct Dialog { + pub kind: Kind, + pub title: Text, + pub external_title: Option, + pub can_close_with_escape: bool, + pub pause: bool, + pub after_action: AfterAction, + pub body: Vec, + pub inputs: Vec, +} + +/// The dialog types (`DialogTypes`). +#[derive(Clone, Debug)] +pub enum Kind { + /// `NoticeDialog`: one button, "OK" when the server names none. + Notice(Button), + Confirmation { + yes: Button, + no: Button, + }, + MultiAction { + actions: Vec