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_coregen_quest") {
    const player = event.source
    //form code
    let form = new ActionFormData();
    form.title("§1Rise of the Relicsmiths: Quest #3, FINAL");
    form.body("§1You look though the Tinkerer's personal log, and find that he has dispatched illagers to use the core to draw power from the souls within, there is only one place that can do this... An ancient core generator §4[This quest requires you to find a structure, it is not skippable, and beat a potential boss]");
    form.button("§4Got it!")

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

      let response = r.selection;
      switch (response) {
        case 0:
          player.sendMessage("§c[Locate an Ancient Core Generator in a taiga, desert or tundra, before the illagers commit the same mistake the old smiths did... To use the core for unlimited power]")
          break;

        case 1:

          break;

        default:
      }

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