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

Hierarchy

  • World

Constructors

  • Returns World

Methods

  • Returns Player[]

    Remarks

    Returns an array of all active players within the world.

    Throws

    This function can throw errors.

  • Parameters

    • dimensionId: string

    Returns Dimension

    The requested dimension

    Remarks

    Returns a dimension object.

    Throws

    Throws if the given dimension name is invalid

  • Beta

    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);