import { world } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui"
const ui = new ActionFormData()
.title("Form")
.body("")
.button("button1")
.button("button2")
.button("button3");
const customUi = new ActionFormData()
.title("Custom Form")
.body("Select Something Here")
.button("Rewards", "textures/ui/promo_holiday_gift_small")
.button("Shop", "textures/ui/icon_deals")
.button("Ban Tool", "textures/ui/hammer_l")
.button("Skins", "textures/ui/icon_hangar")
.button("Skins", "textures/ui/icon_hangar")
.button("Skins", "textures/ui/icon_hangar")
.button("Skins", "textures/ui/icon_hangar")
.button("Skins", "textures/ui/icon_hangar")
.button("Skins", "textures/ui/icon_hangar");
world.afterEvents.itemUse.subscribe(async (event) => {
const { source, itemStack } = event
switch (itemStack.typeId) {
case "minecraft:compass": ui.show(source); break;
case "minecraft:clock": {
const res = await customUi.show(source);
res.selection //This Is Number Will Be Derived From The "collection_index" property of a button in JSON UI
world.sendMessage(`Button ${res.selection} Has Been Pressed!`)
break
};
}
})