	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_ancient_stronghold_quest") {
    const player = event.source
    //form code
    let form = new ActionFormData();
    form.title("§1Rise of the Relicsmiths: Quest #1");
    form.body("§1Find an Ancient Stronghold, and find the Relic Core §4[This quest requires you to find a structure, it is skippable, however you may find gaps in the lore]");
    form.button(" Mark as complete")

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

      let response = r.selection;
      switch (response) {
        case 0:
          player.runCommandAsync("give @s redstone:storyline_structure_illager_forge_quest")
          player.runCommandAsync("say §cYou find the place quite deserted, with no sign of the Core... §hHowever, you see a barrel with an illager banner in the abandoned lab room, telling you where to go next...")
          break;

        case 1:

          break;

        default:
      }

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