main.js
1import { world } from "@minecraft/server"
2import { ActionFormData } from "@minecraft/server-ui"
3
4const ui = new ActionFormData()
5 .title("Form")
6 .body("")
7 .button("button1")
8 .button("button2")
9 .button("button3");
10
11const customUi = new ActionFormData()
12 .title("Custom Form")
13 .body("")
14 .button("button1")
15 .button("button2")
16 .button("button3");
17
18world.afterEvents.itemUse.subscribe((event) => {
19 const { source, itemStack } = event
20 switch (itemStack.typeId) {
21 case "minecraft:compass": ui.show(source); break;
22 case "minecraft:clock": customUi.show(source); break;
23 }
24})