Script API - v26.70.26
    Preparing search index...

    Class ActionFormData

    Builds a simple player form with buttons that let the player take action.

    import { world, DimensionLocation } from '@minecraft/server';
    import { ActionFormData, ActionFormResponse } from '@minecraft/server-ui';

    function showActionForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
    const playerList = world.getPlayers();

    if (playerList.length >= 1) {
    const form = new ActionFormData()
    .title('Test Title')
    .body('Body text here!')
    .button('btn 1')
    .button('btn 2')
    .button('btn 3')
    .button('btn 4')
    .button('btn 5');

    form.show(playerList[0]).then((result: ActionFormResponse) => {
    if (result.canceled) {
    log('Player exited out of the dialog. Note that if the chat window is up, dialogs are automatically canceled.');
    return -1;
    } else {
    log('Your result was: ' + result.selection);
    }
    });
    }
    }
    import { world, DimensionLocation } from '@minecraft/server';
    import { ActionFormData, ActionFormResponse } from '@minecraft/server-ui';

    function showFavoriteMonth(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
    const players = world.getPlayers();

    if (players.length >= 1) {
    const form = new ActionFormData()
    .title('Months')
    .body('Choose your favorite month!')
    .button('January')
    .button('February')
    .button('March')
    .button('April')
    .button('May');

    form.show(players[0]).then((response: ActionFormResponse) => {
    if (response.selection === 3) {
    log('I like April too!');
    return -1;
    }
    });
    }
    }
    import { Player, system } from "@minecraft/server";
    import { ActionFormData } from "@minecraft/server-ui";

    // Run `/scriptevent example:minigames` in chat to open the minigames menu.
    system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
    if (id !== "example:minigames" || !(sourceEntity instanceof Player)) return;
    const player = sourceEntity;

    const games = ["Spleef", "Murder Mystery", "Bedwars"];
    const form = new ActionFormData()
    .title("Minigames")
    .body("Choose a game")
    .button("Spleef", "textures/items/diamond_shovel")
    .button("Murder Mystery", "textures/items/iron_sword")
    .button("Bedwars", "textures/blocks/bed_red");

    form.show(player).then((response) => {
    if (response.canceled || response.selection === undefined) {
    player.sendMessage(`Canceled: ${response.cancelationReason}`);
    return;
    }

    player.sendMessage(`You selected ${games[response.selection]}.`);
    });
    });

    image

    export class ActionFormData {
    body(bodyText: minecraftserver.RawMessage | string): ActionFormData;
    button(text: minecraftserver.RawMessage | string, iconPath?: string): ActionFormData;
    divider(): ActionFormData;
    header(text: minecraftserver.RawMessage | string): ActionFormData;
    label(text: minecraftserver.RawMessage | string): ActionFormData;
    show(player: minecraftserver.Player): Promise<ActionFormResponse>;
    title(titleText: minecraftserver.RawMessage | string): ActionFormData;
    }
    Index
    • Parameters

      Returns ActionFormData

      Method that sets the body text for the modal form.

      This function can't be called in early-execution mode.

      import { Player, system } from "@minecraft/server";
      import { ActionFormData } from "@minecraft/server-ui";

      // Run `/scriptevent example:serverrules` in chat to open the form.
      system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
      if (id !== "example:serverrules" || !(sourceEntity instanceof Player)) return;

      const form = new ActionFormData();
      form.title("Server Rules");
      form.body("Be respectful, do not grief buildings, and have fun playing.");
      form.button("I Agree");

      form.show(sourceEntity).then((response) => {
      if (response.canceled) {
      sourceEntity.sendMessage("You closed the rules dialog.");
      return;
      }
      sourceEntity.sendMessage("You agreed to the rules.");
      });
      });
    • Parameters

      • text: string | RawMessage
      • OptionaliconPath: string

      Returns ActionFormData

      Adds a button to this form with an icon from a resource pack.

      This function can't be called in early-execution mode.

      import { Player, system } from "@minecraft/server";
      import { ActionFormData } from "@minecraft/server-ui";

      // Run `/scriptevent example:warpmenu` in chat to open the form.
      system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
      if (id !== "example:warpmenu" || !(sourceEntity instanceof Player)) return;

      const destinations = ["Spawn", "Market"];

      const form = new ActionFormData();
      form.title("Warp Menu");
      form.body("Choose a destination to visit:");
      form.button(destinations[0], "textures/items/compass");
      form.button(destinations[1], "textures/items/emerald");

      form.show(sourceEntity).then((response) => {
      if (response.canceled || response.selection === undefined) return;
      const destination = destinations[response.selection];
      sourceEntity.sendMessage(`Warping to ${destination}.`);
      });
      });
    • Returns ActionFormData

      Adds a section divider to the form.

      This function can't be called in early-execution mode.

      import { Player, system } from "@minecraft/server";
      import { ActionFormData } from "@minecraft/server-ui";

      // Run `/scriptevent example:gameoptionsmenu` in chat to open the form.
      system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
      if (id !== "example:gameoptionsmenu" || !(sourceEntity instanceof Player)) return;

      const form = new ActionFormData();
      form.title("Game Options");
      form.button("Resume Game");
      form.divider();
      form.button("Leave Server");

      form.show(sourceEntity).then((response) => {
      if (response.canceled || response.selection === undefined) return;
      if (response.selection === 0) {
      sourceEntity.sendMessage("Resuming the game.");
      } else {
      sourceEntity.sendMessage("Leaving the server.");
      }
      });
      });
    • Parameters

      Returns ActionFormData

      Adds a header to the form.

      This function can't be called in early-execution mode.

      import { Player, system } from "@minecraft/server";
      import { ActionFormData } from "@minecraft/server-ui";

      // Run `/scriptevent example:minigamedirectory` in chat to open the form.
      system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
      if (id !== "example:minigamedirectory" || !(sourceEntity instanceof Player)) return;

      const minigames = ["Parkour Challenge", "PVP Arena"];

      const form = new ActionFormData();
      form.title("Server Directory");
      form.header("Minigames");
      form.button(minigames[0]);
      form.button(minigames[1]);

      form.show(sourceEntity).then((response) => {
      if (response.canceled || response.selection === undefined) return;
      const minigame = minigames[response.selection];
      sourceEntity.sendMessage(`You selected ${minigame}.`);
      });
      });
    • Parameters

      Returns ActionFormData

      Adds a label to the form.

      This function can't be called in early-execution mode.

      import { Player, system } from "@minecraft/server";
      import { ActionFormData } from "@minecraft/server-ui";

      // Run `/scriptevent example:servernotice` in chat to open the form.
      system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
      if (id !== "example:servernotice" || !(sourceEntity instanceof Player)) return;

      const form = new ActionFormData();
      form.title("Server Notice");
      form.label("Daily server maintenance occurs every midnight UTC.");
      form.button("Understood");

      form.show(sourceEntity).then((response) => {
      if (response.canceled) return;
      sourceEntity.sendMessage("You acknowledged the server notice.");
      });
      });
    • Parameters

      • player: Player

        Player to show this dialog to.

      Returns Promise<ActionFormResponse>

      Creates and shows this modal popup form. Returns asynchronously when the player confirms or cancels the dialog.

      This function can't be called in restricted-execution mode.

      This function can't be called in early-execution mode.

      import { Player, system } from "@minecraft/server";
      import { ActionFormData } from "@minecraft/server-ui";

      // Run `/scriptevent example:weathervote` in chat to open the form.
      system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
      if (id !== "example:weathervote" || !(sourceEntity instanceof Player)) return;

      const weatherChoices = ["Clear Skies", "Rain Storm"];

      const form = new ActionFormData();
      form.title("Weather Vote");
      form.button(weatherChoices[0]);
      form.button(weatherChoices[1]);

      form.show(sourceEntity).then((response) => {
      if (response.canceled || response.selection === undefined) {
      sourceEntity.sendMessage("Vote canceled.");
      return;
      }
      const choice = weatherChoices[response.selection];
      sourceEntity.sendMessage(`You voted for ${choice}.`);
      });
      });
    • Parameters

      Returns ActionFormData

      This builder method sets the title for the modal dialog.

      This function can't be called in early-execution mode.

      import { Player, system } from "@minecraft/server";
      import { ActionFormData } from "@minecraft/server-ui";

      // Run `/scriptevent example:dailyrewards` in chat to open the form.
      system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
      if (id !== "example:dailyrewards" || !(sourceEntity instanceof Player)) return;

      const form = new ActionFormData();
      form.title("Daily Rewards");
      form.button("Claim Reward");

      form.show(sourceEntity).then((response) => {
      if (response.canceled) return;
      sourceEntity.sendMessage("Claimed daily reward.");
      });
      });