A class that wraps the state of a world - a set of dimensions and the environment of Minecraft.

Hierarchy

  • World

Constructors

  • Returns World

Properties

afterEvents: AfterEvents

Remarks

Contains a set of events that are applicable to the entirety of the world. Event callbacks are called in a deferred manner. Event callbacks are executed in read-write mode.

beforeEvents: BeforeEvents

Remarks

Contains a set of events that are applicable to the entirety of the world. Event callbacks are called immediately. Event callbacks are executed in read-only mode.

scoreboard: Scoreboard

Remarks

Returns the general global scoreboard that applies to the world.

Methods

  • Beta

    Parameters

    • id: string
    • value: string

    Returns void

    Remarks

    A method that is internal-only, used for broadcasting specific messages between client and server.

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

  • Beta

    Returns number

    Remarks

    Returns the absolute time since the start of the world.

  • Returns Player[]

    Remarks

    Returns an array of all active players within the world.

    Throws

    This function can throw errors.

  • Beta

    Returns Vector3

    Returns the default spawn position.

    Remarks

    Returns the default spawn position within the world where players are spawned if they don't have a specific spawn position set.

  • Parameters

    • dimensionId: string

    Returns Dimension

    The requested dimension

    Remarks

    Returns a dimension object.

    Throws

    Throws if the given dimension name is invalid

  • Beta

    Parameters

    • identifier: string

    Returns undefined | string | number | boolean

    Returns the value for the property, or undefined if the property has not been set.

    Remarks

    Returns a property value.

    Throws

    This function can throw errors.

  • Beta

    Parameters

    • id: string

      The id of the entity.

    Returns undefined | Entity

    The requested entity object.

    Remarks

    Returns an entity based on the provided id.

    Throws

    Throws if the given entity id is invalid.

  • Parameters

    • Optional options: EntityQueryOptions

      Additional options that can be used to filter the set of players returned.

    Returns Player[]

    A player array.

    Remarks

    Returns a set of players based on a set of conditions defined via the EntityQueryOptions set of filter criteria.

    Throws

    This function can throw errors.

  • Beta

    Returns number

    Remarks

    Sets the current game time of the day.

  • Parameters

    Returns void

    Remarks

    Plays a particular music track for all players.

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

    Throws

    This function can throw errors.

  • Parameters

    Returns void

    Remarks

    Plays a sound for all players.

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

    Throws

    This function can throw errors.

  • Parameters

    Returns void

    Remarks

    Queues an additional music track for players. If a track is not playing, a music track will play.

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

    Throws

    This function can throw errors.

  • Beta

    Parameters

    • identifier: string

    Returns boolean

    Remarks

    Removes a specified property.

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

    Throws

    This function can throw errors.

  • Parameters

    Returns void

    Remarks

    Sends a message to all players.

    Throws

    This method can throw if the provided RawMessage is in an invalid format. For example, if an empty name string is provided to score.

    Example

    nestedTranslation.ts

    // Displays "Apple or Coal"
    let rawMessage = {
    translate: "accessibility.list.or.two",
    with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] },
    };
    world.sendMessage(rawMessage);

    Example

    scoreWildcard.ts

    // Displays the player's score for objective "obj". Each player will see their own score.
    const rawMessage = { score: { name: "*", objective: "obj" } };
    world.sendMessage(rawMessage);

    Example

    simpleString.ts

    // Displays "Hello, world!"
    world.sendMessage("Hello, world!");

    Example

    translation.ts

    // Displays "First or Second"
    const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] };
    world.sendMessage(rawMessage);
  • Beta

    Parameters

    • spawnPosition: Vector3

      Location within the overworld where a player will spawn.

    Returns void

    Remarks

    Sets the default spawn location for players within the world. Note that players can override this with their own spawn position. Note also that the default spawn position must be in the overworld dimension.

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

    Throws

    This function can throw errors.

  • Beta

    Parameters

    • identifier: string
    • value: string | number | boolean

      Data value of the property to set.

    Returns void

    Remarks

    Sets a specified property to a value.

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

    Throws

    This function can throw errors.

  • Beta

    Parameters

    • timeOfDay: number

    Returns void

    Remarks

    Returns the current game time of the day.

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

  • Returns void

    Remarks

    Stops any music tracks from playing.

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