API reference / @jsprismarine/client / DataDrivenScreens
Class: DataDrivenScreens
Defined in: client/src/DataDrivenScreens.ts:110
The client's half of @minecraft/server-ui's data-driven screens: the CustomForm and MessageBox a behavior pack shows. The server sets the screen's property in the minecraft data store and then opens the screen; this keeps each property's values by path, answers a close the server asks for as a player's client does, and sends the player's clicks, writes and dismissals. It reads both layouts the server sends: a property of maps up to protocol 2225, and a variable per value from 2259.
Emits show with a ClientScreen when a screen opens, and close with the form id when one closes.
Extends
EventEmitter
Constructors
Constructor
new DataDrivenScreens(
session,protocolVersion):DataDrivenScreens
Defined in: client/src/DataDrivenScreens.ts:127
Registers the screen handlers on the session, for the life of the session.
Parameters
session
The session whose screens this follows and answers.
protocolVersion
number
The protocol the client speaks, which decides the data store layout.
Returns
DataDrivenScreens
Overrides
EventEmitter.constructor
Properties
PACKETS
readonlystaticPACKETS: readonly [typeofClientboundDataStorePacket, typeofClientboundDataDrivenUIShowScreenPacket, typeofClientboundDataDrivenUICloseScreenPacket]
Defined in: client/src/DataDrivenScreens.ts:112
The packets this reads, registered on the client's registry with the others.
Methods
click()
click(
formId,path):Promise<void>
Defined in: client/src/DataDrivenScreens.ts:193
Clicks a button or image by the path of its onClick, such as layout[4].onClick, layout[1].image_onClick or a message box's button1.onClick.
Parameters
formId
number
path
string
Returns
Promise<void>
close()
close(
formId,reason?):Promise<void>
Defined in: client/src/DataDrivenScreens.ts:199
Reports a screen closed, by default as the player dismissing it.
Parameters
formId
number
reason?
DataDrivenScreenClosedReason = DataDrivenScreenClosedReason.ClientCanceled
Returns
Promise<void>
screens()
screens(): readonly
ClientScreen[]
Defined in: client/src/DataDrivenScreens.ts:163
The screens open now, oldest first.
Returns
readonly ClientScreen[]
write()
write(
formId,path,value):Promise<void>
Defined in: client/src/DataDrivenScreens.ts:168
Writes a value to one path of an open screen's property, as an input control does.
Parameters
formId
number
path
string
value
Returns
Promise<void>