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:riseofrelic_book") {
    const player = event.source
    //form code
    let form = new ActionFormData();
    form.title("§lThe End of Relic");
    form.body("The fall of the smiths, \nthe great and old, \ntheir death be told, \ntheir tales be sold, \nto adventurers like thee, \nto seek thy power, \nto save thy people \n {...} \nTo look back, \nand see our sorrows, \nto find the root of our troubles, \nour pride too strong, \nour will too weak, \nfor what we seek, \novertook our greed");
    form.button("§l§gEnter the Ruins of Relic... §c[Start Storyline]");
    form.button("§l§cClose Book")
    //form button effects
    form.show(player).then(r => {
      if (r.canceled) return;

      let response = r.selection;
      switch (response) {
        case 0:
          player.sendMessage('§c[search for more information on this from a §gLore Lower §ain a forest, plains or beach§c]');
          break;

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

