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

    Class DimensionTypes

    Used for accessing all available dimension types. Currently only works with Vanilla dimensions.

    export class DimensionTypes {
    private constructor();
    static get(dimensionTypeId: string): DimensionType | undefined;
    static getAll(): DimensionType[];
    }
    Index
    • Parameters

      • dimensionTypeId: string

      Returns DimensionType | undefined

      Retrieves a dimension type using a string-based identifier. Works with both vanilla dimensions and custom dimensions. Custom dimensions cannot be retrieved until after the system startup event has completed.

      early-execution-allowed - This function can be called in early-execution mode.

      import { DimensionTypes, Player, system } from "@minecraft/server";

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

      const dimensionType = DimensionTypes.get("minecraft:overworld");
      if (!dimensionType) return;

      sourceEntity.sendMessage(`Found dimension type: ${dimensionType.typeId}`);
      });
    • Returns DimensionType[]

      Retrieves an array of all dimension types. Includes both vanilla dimensions and custom dimensions. Custom dimensions are not included until after the system startup event has completed.

      early-execution-allowed - This function can be called in early-execution mode.

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

      const dimensions = DimensionTypes.getAll();
      for (const dimensionType of dimensions) {
      world.sendMessage(dimensionType.typeId);
      }

      // minecraft:overworld
      // minecraft:nether
      // minecraft:the_end