Minecraft 1.21.6 Dialogs Integration
asmolfemboi opened this issue · 0 comments
Suggestion
I propose adding support for the Minecraft 1.21.6 Dialogs feature to Skript, enabling server administrators to create and manage interactive dialog windows using Skript’s intuitive syntax. The Dialogs feature, introduced in Minecraft 1.21.6, allows for modal windows that display information and collect player input through various controls like text, buttons, toggles, sliders, and dropdowns (see Minecraft Wiki for details:,). This suggestion includes new syntaxes for creating, configuring, and handling dialog interactions, leveraging Skript’s event-driven and expression-based structure.
Proposed Syntax
1. Dialog Creation and Configuration
A new command to create and configure a dialog, allowing specification of the title, body, inputs, buttons, and layout options.
create dialog [named] %string% for %players%:
title: %text%
[body] text: %text%
[add] button %string% [with text %text%] [and action %string%]
[add] text input %string% [with label %text%] [and default %string%] [and max length %number%]
[add] toggle input %string% [with label %text%] [and default %boolean%]
[add] slider input %string% [with label %text%] [from %number% to %number%] [with step %number%] [and default %number%]
[add] dropdown input %string% [with label %text%] options %strings% [and default %string%]
[set] columns: %number%
[set] close on esc: %boolean%
open
Explanation:
%string%is the dialog ID for referencing in events.%players%specifies the target player(s) for the dialog.titlesets the dialog’s title (aTextobject in Minecraft, supporting formatted text).body textadds a plain text body (usesPlainMessageDialogBody).buttonadds a button with a name and optional display text, linked to a custom action ID.- Input types (
text input,toggle input,slider input,dropdown input) map to Minecraft’s input controls (TextInputControl,BooleanInputControl,NumberRangeInputControl,SingleOptionInputControl). columnssets the dialog layout (default 1, as perDialogBuilder.java).close on escdetermines if the dialog closes on ESC key (default true).opendisplays the dialog to the specified players.
Example Usage:
create dialog "welcome" for player:
title: "Welcome to the Server!"
body text: "Choose your starter kit:"
add button "warrior" with text "Warrior Kit" and action "select_warrior"
add button "mage" with text "Mage Kit" and action "select_mage"
add text input "nickname" with label "Your Nickname" and default "Player" and max length 16
add toggle input "pvp" with label "Enable PvP?" and default true
open
2. Dialog Interaction Event
A new event to handle dialog submissions, capturing button clicks and input values.
on dialog submit %string%:
trigger:
# Event values:
# %event-string% - dialog ID
# %event-player% - player who submitted
# %event-button% - button action ID (if a button was clicked)
# %event-inputs% - map of input names to their values
Explanation:
- Triggered when a player submits a dialog (via button click or form submission).
event-stringis the dialog ID.event-playeris the submitting player.event-buttonis the action ID of the clicked button (null if no button was clicked).event-inputsis a key-value map (e.g.,{"nickname": "Steve", "pvp": true}).
Example Usage:
on dialog submit "welcome":
set {_button} to event-button
set {_inputs} to event-inputs
if {_button} is "select_warrior":
give player iron sword
send "You chose the Warrior Kit!" to event-player
else if {_button} is "select_mage":
give player stick named "Magic Wand"
send "You chose the Mage Kit!" to event-player
set {_nickname} to {_inputs}.nickname
set {_pvp} to {_inputs}.pvp
send "Nickname set to %{_nickname}% and PvP is %{_pvp}%!" to event-player
3. Dialog Management Commands
Commands to open or close dialogs programmatically.
open dialog %string% to %players%
close dialog %string% for %players%
Example Usage:
command /showwelcome:
trigger:
open dialog "welcome" to player
4. Javadoc Reference
While Skript itself doesn’t directly use Javadocs for its syntax, the proposed syntax aligns with the Minecraft 1.21.6 Dialogs API (package net.minecraft.dialog.*). Relevant classes include:
Dialog: Base class for dialogs (MultiActionDialogfor multiple buttons).DialogBody: For content likePlainMessageDialogBody,ItemDialogBody.DialogInput: For inputs likeTextInputControl,BooleanInputControl, etc.DialogAction: For button actions (DynamicCustomDialogActionfor custom callbacks).
For implementation, refer to the example code in DialogBuilder.java (), which provides a practical reference for dialog creation in Java.
Why?
The Minecraft 1.21.6 Dialogs feature enhances server interactivity by allowing server-side creation of modal windows without relying on inventory GUIs or client mods (,). Integrating this into Skript would:
- Simplify Customization: Skript’s strength is enabling server admins to add complex features without Java knowledge (,). A dialog syntax would make it easy to create interactive menus for quests, shops, or settings.
- Enhance Player Experience: Dialogs offer a polished, modern UI compared to chat-based or inventory-based interfaces, improving immersion (e.g., for NPC interactions or server menus).
- Leverage Native Features: The Dialogs feature is built into Minecraft 1.21.6, ensuring compatibility and performance without external dependencies (unlike some existing dialog libraries,,).
- Support Mapmakers and Server Owners: As shown in tutorials (), dialogs are valuable for datapacks and server plugins. Skript integration would make this accessible to non-programmers.
Other
nope.
Agreement
- I have read the guidelines above and affirm I am following them with this suggestion.