Script forms for Java players
A behavior pack's @minecraft/server-ui forms reach Bedrock players as ModalFormRequestPacket and come back as ModalFormResponsePacket. Java 26.3 has dialogs: Show Dialog, Clear Dialog and the serverbound Custom Click Action. This plan maps the three older form builders, ActionFormData, MessageFormData and ModalFormData, onto dialogs, so a pack written for Bedrock shows the same forms to Java players without a change. The data-driven CustomForm and MessageBox screens are left for #4203.
Where the mapping lives
The script host writes a form as the JSON BDS writes and reads an answer as BDS reads one (packages/script-host/src/host/forms.ts). It stays as it is. The session presenter is the seam that owns what each edition shows (ADR 0026), so it gains showForm and closeForms:
BedrockPresentersends the JSON unchanged, asprismarine:scriptsdid.JavaPresenterreads the JSON into a dialog (editions/java/javaFormDialogs.ts) and keeps the form it shows.
A Java answer arrives as Custom Click Action. Its handler asks the presenter what the click means and runs the same answerForm intent a Bedrock ModalFormResponsePacket decodes into, carrying the JSON and cancel reason a Bedrock client would have sent. The scripts cannot tell the editions apart.
The mapping
Every dialog's buttons send jsprismarine:form with a compound payload that names the form id, so a click on a dialog that was replaced or cleared is dropped.
| Form | Dialog | Answer |
|---|---|---|
| Action, buttons | minecraft:multi_action, one column, a button per button | the button's index among the buttons |
| Action, none | minecraft:notice whose one button closes it | closed |
| Message | minecraft:multi_action, button1 above button2 | true for button1, false for button2 |
| Modal | minecraft:multi_action with one submit button and inputs | one value per element, in order |
A modal form's elements become inputs: a text field minecraft:text, a toggle minecraft:boolean, a slider minecraft:number_range and a dropdown minecraft:single_option. The submit button is a minecraft:dynamic/custom action, so the client puts every input's value in its payload. A header or a label answers null, as a Bedrock client answers it.
Every dialog also has an exit button, which Escape presses too. It answers the form as closed (UserClosed). Without it Escape would close the dialog and send nothing, and show() would never settle.
Decisions
- Busy. A Bedrock client answers
UserBusywhen it cannot show a form. A Java client shows a dialog over any screen, so the presenter decides: a form sent while the player has a dialog or a container open is answeredUserBusyat once, through the same intent. Packs already retry onUserBusy. - A player who leaves. The script host already rejects the player's open forms with
PlayerQuitonce the player is gone. Nothing Java-specific is needed. closeAllForms. SendsClear Dialogand forgets the form, which settles nothing, as on Bedrock.- Layout. A dialog shows its body above its inputs and buttons. An action form's headers and labels, and a modal form's, join the body in order. Dividers are left out.
- Text field length. A Java text input holds 32 characters unless the dialog says more, and the client's payload is limited to 32 KiB of NBT. Each text field holds 256 characters.
- Slider values. Java sends a float; the answer is rounded to the slider's step, so a step of 0.1 answers 0.3 rather than 0.30000001.
What Java dialogs cannot show
- A button's image.
- A text field's placeholder.
- A tooltip, on any element.
- A divider, and a header or label between a modal form's inputs, which moves above them.
Tests
javaPackets.test.tsround-trips the three packets.javaFormDialogs.test.tsmaps each form kind and reads each answer, including malformed payloads and stale form ids.- A loopback scenario,
packages/client/src/scenarios/java-forms.test.ts, joins@jsprismarine/client's Java client to a server running a pack. It answers an action, a message and a modal form, closes one with Escape, getsUserBusyfor a form sent while a dialog is open, and seescloseAllFormsclear the dialog.