Minecraft:Dialog
More actions
|
For the {{{Description}}} of the same name, see [[{{{Destination}}}]]. |
Template:Exclusive Dialogs are simple Template:Ws that can display information and receive Minecraft:player input.
Usage
Dialogs can be displayed to Minecraft:players using the Template:Cmd command by server Minecraft:operators while in gameplay. Additionally, they can be displayed through a Template:Cd action in a Minecraft:text component or another dialog (see Template:Slink). They can also be configured for the Minecraft:pause menu and when pressing the Template:Control hotkey (see Template:Slink).
Dialogs enable various forms of interaction with the game, including:
- Sending messages or information using Minecraft:text components, including rich text formatting and clickable links (excluding type nbt, score and selector<ref name="no-component-resolution">Template:Bug</ref>);
- Receiving player input through input control fields such as textbox, toggle, slider, and option selection;
- Executing Minecraft:commands via action buttons (privileged commands can only be executed by server operators); and
- Navigating between multiple dialogs using nested structures.
Dialogs mostly comprise of these three elements, however their exact contents are dependent of the type:
- Header, which contains the title and warning button;
- Body elements, which may be labels, inputs, buttons, and submit actions (scrollable if needed); and
- Optional footer, which may contain confirmation buttons and submit actions.
When a dialog window opens, player Minecraft:controls are disabled temporarily until the user exits the window through an exit action button, the Template:W (Template:Key), or the warning button next to the dialog's title (which returns the user back to the Minecraft:title screen). In Minecraft:singleplayer, a dialog can be configured to pause the game, in which case the game also Minecraft:autosaves.
Definition
Dialog can be defined in Minecraft:data packs, as part of the directory structure below.
Dialog formatTemplate:Anchor
Dialogs have different structure depending on their type, which is specified by Template:Nbt tag. The structure below applies to every dialog types:
- *: If parent field is written, this field is required.
- Template:Nbt The root tag.
- Template:Nbt*: One of dialog types from the
minecraft:dialog_typeregistry:minecraft:noticeminecraft:confirmationminecraft:multi_actionminecraft:server_linksminecraft:dialog_list<section begin="json format common" />
- Template:NbtTemplate:NbtTemplate:Nbt*: Screen title, text component. Should be always visible on screen, no matter the specific type.
- Template:NbtTemplate:NbtTemplate:Nbt: Name to be used for a button leading to this dialog (for example, on the Minecraft:pause menu), optional text component. If not present, title will be used instead.
- Template:NbtTemplate:Nbt: Optional list of body elements or a single body element. See Template:Slink.
- Template:Nbt: Optional list of input controls. See Template:Slink.
- Template:Nbt: Can dialog be dismissed with Escape key. Defaults to
true. - Template:Nbt: If the dialog screen should pause the game in single-player mode. Defaults to
true. - Template:Nbt: An additional operation performed on the dialog after click or submit actions. Defaults to
close. Can be one of the following:close: Closes the dialog and returns to the previous non-dialog screen (if any).none: Does nothing, i.e. keeps the current dialog screen open (only available if Template:Nbt isfalseto avoid locking the game in single-player mode).wait_for_response: Replace the current dialog with a "Waiting for Response" screen.<section end="json format common" />
- Other fields depending on Template:Nbt, see below.
- Template:Nbt*: One of dialog types from the
notice
A dialog screen with a single action button in footer, specified by Template:Nbt. By default, the exit action (which returns the player back to gameplay) is the same Template:Nbt button.
- Template:Nbt The root tag.
- Template:Nbt*:
minecraft:notice. - Template:Nbt inherit/dialog
- Template:Nbt: Click action. Defaults to button with
gui.oklabel and no action or tooltip.- Template:NbtTemplate:NbtTemplate:Nbt*: Text component.
- Template:NbtTemplate:NbtTemplate:Nbt: Optional text component to display when button is highlighted or hovered over.
- Template:Nbt: Value between 1 and 1024 — Width of the button. Defaults to 150.
- Template:Nbt: An action to perform when button is clicked. See Template:Slink
- Template:Nbt*:
confirmation
A dialog screen with two action buttons in footer, specified by Template:Nbt and Template:Nbt. By default, the exit action is Template:Nbt button.
- Template:Nbt The root tag.
- Template:Nbt*:
minecraft:confirmation. - Template:Nbt inherit/dialog
- Template:Nbt*: Click action for positive outcome.
- Template:NbtTemplate:NbtTemplate:Nbt*: Text component.
- Template:NbtTemplate:NbtTemplate:Nbt: Optional text component to display when button is highlighted or hovered over.
- Template:Nbt: Value between 1 and 1024 — Width of the button. Defaults to 150.
- Template:Nbt: An action to perform when button is clicked. See Template:Slink
- Template:Nbt*: Click action for negative outcome.
- Template:NbtTemplate:NbtTemplate:Nbt*: Text component.
- Template:NbtTemplate:NbtTemplate:Nbt: Optional text component to display when button is highlighted or hovered over.
- Template:Nbt: Value between 1 and 1024 — Width of the button. Defaults to 150.
- Template:Nbt: An action to perform when button is clicked. See Template:Slink
- Template:Nbt*:
multi_action
A dialog screen with a scrollable list of action buttons arranged in columns. If Template:Nbt is present, a button for it will appear in the footer, otherwise the footer is not present. Template:Nbt is also used for the Escape action.
- Template:Nbt The root tag.
- Template:Nbt*:
minecraft:multi_action. - Template:Nbt inherit/dialog
- Template:Nbt*: Non-empty list of click actions.
- Template:NbtTemplate:NbtTemplate:Nbt*: Text component.
- Template:NbtTemplate:NbtTemplate:Nbt: Optional text component to display when button is highlighted or hovered over.
- Template:Nbt: Value between 1 and 1024 — Width of the button. Defaults to 150.
- Template:Nbt: An action to perform when button is clicked. See Template:Slink
- Template:Nbt: Positive integer describing number of columns. Defaults to 2.
- Template:Nbt: Action for leaving the dialog.
- Template:NbtTemplate:NbtTemplate:Nbt*: Text component.
- Template:NbtTemplate:NbtTemplate:Nbt: Optional text component to display when button is highlighted or hovered over.
- Template:Nbt: Value between 1 and 1024 — Width of the button. Defaults to 150.
- Template:Nbt: An action to perform when button is clicked. See Template:Slink
- Template:Nbt*:
server_links
A dialog screen with scrollable list of Minecraft:server links, arranged in columns. If Template:Nbt is present, a button for it will appear in the footer, otherwise the footer is not present. Template:Nbt is also used for the Escape action.
- Template:Nbt The root tag.
- Template:Nbt*:
minecraft:server_links. - Template:Nbt inherit/dialog
- Template:Nbt: Action for leaving the dialog.
- Template:NbtTemplate:NbtTemplate:Nbt*: Text component.
- Template:NbtTemplate:NbtTemplate:Nbt: Optional text component to display when button is highlighted or hovered over.
- Template:Nbt: Value between 1 and 1024 — Width of the button. Defaults to 150.
- Template:Nbt: An action to perform when button is clicked. See Template:Slink
- Template:Nbt: Positive integer describing number of columns. Defaults to 2.
- Template:Nbt: Value between 1 and 1024 — Width of the button. Defaults to 150.
- Template:Nbt*:
dialog_list
A dialog screen with scrollable list of buttons leading directly to other dialogs, arranged in columns. Titles of those buttons will be taken from Template:Nbt fields of targeted dialogs. If Template:Nbt is present, a button for it will appear in the footer, otherwise the footer is not present. Template:Nbt is also used for the Escape action.
- Template:Nbt The root tag.
- Template:Nbt*:
minecraft:dialog_list. - Template:Nbt inherit/dialog
- Template:NbtTemplate:NbtTemplate:Nbt*: Template:Json ref to show in the list.
- Template:Nbt: Action for leaving the dialog.
- Template:NbtTemplate:NbtTemplate:Nbt*: Text component.
- Template:NbtTemplate:NbtTemplate:Nbt: Optional text component to display when button is highlighted or hovered over.
- Template:Nbt: Value between 1 and 1024 — Width of the button. Defaults to 150.
- Template:Nbt: An action to perform when button is clicked. See Template:Slink
- Template:Nbt: Positive integer describing number of columns. Defaults to 2.
- Template:Nbt: Value between 1 and 1024 — Width of the button. Defaults to 150.
- Template:Nbt*:
Body formatTemplate:Anchor
All dialogs have a list of body elements describing contents between title and actions or inputs.
plain_message
A multiline label.
- Template:Nbt: The body element
- Template:Nbt*:
minecraft:plain_message - Template:NbtTemplate:NbtTemplate:Nbt*: Text component. Does not support nbt, score and selector components.<ref name="no-component-resolution"/>
- Template:Nbt: Value between 1 and 1024 — Maximum width of message. Defaults to 200.
- Template:Nbt*:
item
An item with optional description. It appears like it is in the Minecraft:inventory slot when the mouse hovers over the item. The size does not scale even if width and height are set to other values than the default. If the description is present, then it appears next to the right side of the item.
- Template:Nbt: The body element
- Template:Nbt*:
minecraft:item - Template:Nbt*: Item stack with count.
- Template:Nbt*: Item identifier.
- Template:Nbt: Item count.
- Template:Nbt: Optional. Additional information about the item. See item components.
- Template:NbtTemplate:NbtTemplate:Nbt: A compound or a text component (does not support nbt, score and selector components.<ref name="no-component-resolution"/>)
- Template:NbtTemplate:NbtTemplate:Nbt: Text component (does not support nbt, score and selector components.<ref name="no-component-resolution"/>)
- Template:Nbt: Value between 1 and 1024 — Maximum width of message. Defaults to 200.
- Template:Nbt: If true, count and damage bar will be rendered over the item. Defaults to
true. - Template:Nbt: If true, item tooltip will show up when item is hovered. Defaults to
true. - Template:Nbt: Value between 1 and 256 — Horizontal size of element. Defaults to 16.
- Template:Nbt: Value between 1 and 256 — Vertical size of element. Defaults to 16.
- Template:Nbt*:
Input control formatTemplate:Anchor
Input controls are used to receive certain information from the players. These information can be used with the associated Template:Nbt tag, for example, when an action button is clicked, the Template:Nbt can be used to reference information stored on that input control, either when running a command with Minecraft:macro substitution, or a custom NBT tag sent to the Minecraft:server (see Template:Slink).
All input control types have a label field.
- Template:Nbt: The input control
- Template:Nbt*: One of dialog types from the
minecraft:input_control_typeregistry:minecraft:textminecraft:booleanminecraft:single_optionminecraft:number_range
- Template:Nbt*: One of dialog types from the
<section begin="input control common" />**Template:Nbt*: String identifier of value used when submitting data, must be a valid template argument (letters, digits and _).
- Template:NbtTemplate:NbtTemplate:Nbt*: A Minecraft:text component to be displayed to the left of the input.<section end="input control common" />
- Additional fields based on Template:Nbt, see below.
text
A basic, single line, text input.
Output values:
- As template substitution: contents with special characters escaped using escape sequences to fit into an Minecraft:SNBT string.
- As tag: a string tag with contents without modification.
- Template:Nbt: The input control
- Template:Nbt*:
minecraft:text - Template:Nbt inherit/dialog/input control
- Template:Nbt: Value between 1 and 1024 — The width of the input. Defaults to 200.
- Template:Nbt: Controls if the label is visible. Defaults to
true. - Template:Nbt: The initial value of the text input.
- Template:Nbt: Maximum length of input. Defaults to 32.
- Template:Nbt: If present, allows users to input multiple lines, optional object with fields:
- Template:Nbt: Optional positive integer. If present, limits maximum lines.
- Template:Nbt: Value between 1 and 512 — Height of input.
- Template:Nbt*:
boolean
A checkbox.
Output values:
- As template substitution: Template:Nbt when checked, Template:Nbt when unchecked.
- As tag:
1bwhen checked,0bwhen unchecked.
- Template:Nbt: The input control
- Template:Nbt*:
minecraft:boolean - Template:Nbt inherit/dialog/input control
- Template:Nbt: The initial value of the checkbox. Defaults to
false(unchecked). - Template:Nbt: The string value to send when true. Defaults to 'true'.
- Template:Nbt: The string value to send when false. Defaults to 'false'.
- Template:Nbt*:
single_option
A preset option selection.
- Template:Nbt: The input control
- Template:Nbt*:
minecraft:single_option - Template:Nbt inherit/dialog/input control
- Template:Nbt: Controls if the label is visible. Defaults to
true. - Template:Nbt: Value between 1 and 1024 — The width of the input. Defaults to 200.
- Template:Nbt*: A non-empty list of options to be selected from:
- Template:Nbt: An option compound.
- Template:Nbt*: The value to be sent on submit.
- Template:NbtTemplate:NbtTemplate:Nbt: A text component for what the option is displayed as.
- Template:Nbt: Only one option can have this set to
true. Iftrue, the option chosen will be the initial one. Defaults to the first option beingtrue, and all othersfalse.
- Template:Nbt: An option compound.
- Template:Nbt*:
number_range
A number slider.
Output values:
- As template substitution: text representation of current value.
- Whole numbers will be sent without decimal point.
- As tag: a float tag with current value.
- Template:Nbt: The input control
- Template:Nbt*:
minecraft:number_range - Template:Nbt inherit/dialog/input control
- Template:Nbt: A translation key to be used for building label (first argument is contents of label field, second argument is current value). Defaults to
options.generic_value. - Template:Nbt: Value between 1 and 1024 — The width of the input. Defaults to 200.
- Template:Nbt*: The minimum number of the slider.
- Template:Nbt*: The maximum number of the slider.
- Template:Nbt: Step size (If present, only values of <math>initial + <any integer> * step</math> will be allowed. If absent, any value from the range is allowed).
- Template:Nbt: The initial increment value of the slider. Defaults to the middle of the range.
- Template:Nbt*:
Action formatTemplate:Anchor
Static action types
Static actions are actions that don't depend on the value of an input field. They are identical to text component events (except for open_file). They use the same format but with the action tag replaced with type.
For example, when using show_dialog, entry for action button will look like:
<syntaxhighlight lang="json">
{
"label": "Show dialog label",
"action": {
"type": "show_dialog",
"dialog": "custom:my_dialog"
}
} </syntaxhighlight> {{#lst:Text component format|click_events}}
Dynamic action types
Can be used in conjunction with input controls.
dynamic/run_command
This action will build a run_command event using a provided macro template (example: /say $(message) if you have a text input with an ID message)
- Template:Nbt
- Template:Nbt:
dynamic/run_command - Template:Nbt: A string with a macro template to be interpreted as a command.
- Template:Nbt:
dynamic/custom
This method will build a minecraft:custom event using all input values.
All input contents will be sent together inside a Template:Nbt compound tag, with tag value of each input put under id from key field of that input.
Additional static fields can be added to payload.
- Template:Nbt
- Template:Nbt:
dynamic/custom - Template:Nbt: Fields to be added to payload.
- Template:Nbt: Namespaced ID.
- Template:Nbt:
Dialog tag
Template:Main
A Minecraft:data pack can apply one or more dialogs to the Minecraft:pause screen and the Template:Control hotkey using the Template:Tag link and Template:Tag link tags. If multiple dialogs are applied to the same method, the built-in minecraft:custom_options or minecraft:quick_actions dialog is shown instead which by default feature a list of all dialogs in the respective tags, using the Template:Nbt tag in the dialogs.
History
References
Template:Navbox Java Edition technical
Minecraft:de:Dialogdefinition Minecraft:ja:ダイアログ Minecraft:pt:Diálogo Minecraft:ru:Диалог Minecraft:zh:对话框定义格式