Script API - v1.21.90.25
    Preparing search index...

    Contains information about user interface elements that are showing up on the screen.

    import { world, DimensionLocation } from "@minecraft/server";

    function setTitle(targetLocation: DimensionLocation) {
    const players = world.getPlayers();

    if (players.length > 0) {
    players[0].onScreenDisplay.setTitle("§o§6Fancy Title§r");
    }
    }
    import { world, DimensionLocation } from "@minecraft/server";

    function setTitleAndSubtitle(
    targetLocation: DimensionLocation
    ) {
    const players = world.getPlayers();

    players[0].onScreenDisplay.setTitle("Chapter 1", {
    stayDuration: 100,
    fadeInDuration: 2,
    fadeOutDuration: 4,
    subtitle: "Trouble in Block Town",
    });
    }
    import { world, system, DimensionLocation } from "@minecraft/server";

    function countdown(targetLocation: DimensionLocation) {
    const players = world.getPlayers();

    players[0].onScreenDisplay.setTitle("Get ready!", {
    stayDuration: 220,
    fadeInDuration: 2,
    fadeOutDuration: 4,
    subtitle: "10",
    });

    let countdown = 10;

    const intervalId = system.runInterval(() => {
    countdown--;
    players[0].onScreenDisplay.updateSubtitle(countdown.toString());

    if (countdown == 0) {
    system.clearRun(intervalId);
    }
    }, 20);
    }
    Index

    Constructors

    Properties

    isValid: boolean

    Returns true if the current reference to this screen display manager object is valid and functional.

    Methods

    • Parameters

      Returns void

      This function can't be called in read-only mode.

      This function can throw errors.

      InvalidEntityError

    • Parameters

      Returns boolean

      This function can't be called in read-only mode.

      This function can throw errors.

      InvalidEntityError

    • Rc

      Returns void

      This function can't be called in read-only mode.

      This function can throw errors.

      InvalidEntityError

    • Parameters

      Returns void

      Set the action bar text - a piece of text that displays beneath the title and above the hot-bar.

      This function can't be called in read-only mode.

      This function can throw errors.

      InvalidEntityError

      RawMessageError

      // Script by WavePlayz

      import { world } from "@minecraft/server";

      // Subscribe to the event that triggers when a player places a block
      world.afterEvents.playerPlaceBlock.subscribe((eventData) => {
      // Extract the player and block objects from the event data
      const { player, block } = eventData;

      // Display a message on the player's action bar indicating the type of block they placed
      player.onScreenDisplay.setActionBar(`You placed ${block.typeId}`);
      });
    • Parameters

      • visible: HudVisibility

        Whether to set the HUD element to invisible, or to reset it back to its default.

      • OptionalhudElements: HudElement[]

        Optional list of HUD elements to configure visibility for.

      Returns void

      Sets visibility of a particular element of the heads up display (HUD).

      This function can't be called in read-only mode.

      This function can throw errors.

      InvalidEntityError

    • Parameters

      Returns void

      Will cause a title to show up on the player's on screen display. Will clear the title if set to empty string. You can optionally specify an additional subtitle as well as fade in, stay and fade out times.

      This function can't be called in read-only mode.

      import { world, DimensionLocation } from "@minecraft/server";

      function setTitle(targetLocation: DimensionLocation) {
      const players = world.getPlayers();

      if (players.length > 0) {
      players[0].onScreenDisplay.setTitle("§o§6Fancy Title§r");
      }
      }
      import { world, DimensionLocation } from "@minecraft/server";

      function setTitleAndSubtitle(
      targetLocation: DimensionLocation
      ) {
      const players = world.getPlayers();

      players[0].onScreenDisplay.setTitle("Chapter 1", {
      stayDuration: 100,
      fadeInDuration: 2,
      fadeOutDuration: 4,
      subtitle: "Trouble in Block Town",
      });
      }
      import { world, system, DimensionLocation } from "@minecraft/server";

      function countdown(targetLocation: DimensionLocation) {
      const players = world.getPlayers();

      players[0].onScreenDisplay.setTitle("Get ready!", {
      stayDuration: 220,
      fadeInDuration: 2,
      fadeOutDuration: 4,
      subtitle: "10",
      });

      let countdown = 10;

      const intervalId = system.runInterval(() => {
      countdown--;
      players[0].onScreenDisplay.updateSubtitle(countdown.toString());

      if (countdown == 0) {
      system.clearRun(intervalId);
      }
      }, 20);
      }
      // Script by WavePlayz

      import { world } from "@minecraft/server";

      // Function to convert seconds to ticks (1 second = 20 ticks in Minecraft)
      let secsToTicks = (/** @type {number} */ secs) => secs * 20;

      // Subscribe to the event that triggers when a player places a block
      world.afterEvents.playerPlaceBlock.subscribe((eventData) => {
      // Extract the player and block objects from the event data
      const { player, block } = eventData;

      // Define display options for the title message
      let displayOptions = {
      fadeInDuration: secsToTicks(0.5), // Duration for the title to fade in
      fadeOutDuration: secsToTicks(1), // Duration for the title to fade out
      stayDuration: secsToTicks(1.5), // Duration for the title to stay on screen
      subtitle: player.name, // Subtitle showing the player's name
      };

      // Set the title message to display when a block is placed
      player.onScreenDisplay.setTitle(
      `You placed \n ${block.typeId}`,
      displayOptions,
      );
      });
    • Parameters

      Returns void

      Updates the subtitle if the subtitle was previously displayed via the setTitle method.

      This function can't be called in read-only mode.

      This function can throw errors.

      InvalidEntityError

      RawMessageError

      import { world, system, DimensionLocation } from "@minecraft/server";

      function countdown(targetLocation: DimensionLocation) {
      const players = world.getPlayers();

      players[0].onScreenDisplay.setTitle("Get ready!", {
      stayDuration: 220,
      fadeInDuration: 2,
      fadeOutDuration: 4,
      subtitle: "10",
      });

      let countdown = 10;

      const intervalId = system.runInterval(() => {
      countdown--;
      players[0].onScreenDisplay.updateSubtitle(countdown.toString());

      if (countdown == 0) {
      system.clearRun(intervalId);
      }
      }, 20);
      }