Topic category: Help with Minecraft modding (Bedrock Edition)
import * as server from "@minecraft/server"
import * as ui from "@minecraft/server-ui"
let homes = []
const form = new ui.ActionFormData
form.title("Home Menu")
form.body("Choose an option")
form.button("sethome")
let sethome = new ui.ModalFormData
sethome.title("Set Home")
sethome.textField("Select a Home Name", "base1, main-home, BigVillage")
let delhome = new ui.ModalFormData
delhome.title("delete home")
delhome.textField("Delete a home", "base1, main-home, BigVillage")
let tphome = new ui.ModalFormData
tphome.title("TP to home")
tphome.textField("Select A Home to tp to", "base1, main-home, BigVillage")
server.world.beforeEvents.chatSend.subscribe((e) => {
if (e.message === "home") {
server.system.run(() => show_main(e.sender))
}
})
function sethomeui(sender) {
sethome.show(sender).then((sel) => {
if (sel.canceled === true) { return }
let [textField] = sel.formValues
textField = textField.toString()
homes.push(textField)
})
}
function show_main(sender) {
form.show(sender).then((sel) => {
switch (sel.selection) {
case (1): sethomeui(sender)
}
})
}
using the "module_name": "@minecraft/server",
"version": "1.14.0-beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "1.3.0-beta"
This works with no errors but when i type home in chat the chat window doesnt close + when i close it there is no ui form that appears. does anyone know how to fix this