import { ActionFormData, MessageFormData, ModalFormData } from "@minecraft/server-ui";
import { world, system } from "@minecraft/server"


//initiate form
world.afterEvents.itemUse.subscribe(event => {
  if (event.itemStack.typeId === "redstone:storyline_structure_illager_forge_quest") {
    const player = event.source
    //form code
    let form = new ActionFormData();
    form.title("§1Rise of the Relicsmiths Quest #2");
    form.body("§1Locate an Illager Forge and kill the Tinkerer for the next quest scroll... §c[This is a miniboss fight quest found in a dungeon like forge structure, proper equipment may be needed!]");
    form.button("§4I'm ready!")

    //form button effects
    form.show(player).then(r => {
      if (r.canceled) return;

      let response = r.selection;
      switch (response) {
        case 0:
          player.sendMessage("§c[Find an Illager Forge in the §ameadows §cand kill the Tinkerer, he may have the Core...]")
          break;

        case 1:

          break;

        case 2:

          break;
        case 3:


        default:
      }
    }).catch(e => {
      console.error(e, e.stack);
    });
  };
});

