Class in @minecraft/server
The world’s one dimension: Basalt has only the overworld.
import { Dimension } from '@minecraft/server';Example
Section titled “Example”import { world, type Vector3 } from '@minecraft/server';
const overworld = world.getDimension('overworld');const spot: Vector3 = { x: 0, y: 80, z: 0 };
// Place a block, read it back, then spawn a mob on top of it.overworld.setBlockType(spot, 'minecraft:gold_block');console.log(overworld.getBlock(spot)?.typeId);overworld.spawnEntity('minecraft:cow', { x: 0, y: 81, z: 0 });import { world } from '@minecraft/server';
const overworld = world.getDimension('overworld');const spot = { x: 0, y: 80, z: 0 };
// Place a block, read it back, then spawn a mob on top of it.overworld.setBlockType(spot, 'minecraft:gold_block');console.log(overworld.getBlock(spot)?.typeId);overworld.spawnEntity('minecraft:cow', { x: 0, y: 81, z: 0 });Properties
Section titled “Properties”read-only
readonly id: string;minecraft:overworld.
heightRange
Section titled “heightRange”read-only
readonly heightRange: { readonly min: number; readonly max: number };The lowest and highest block heights: -64 and 319 in the overworld.
localizationKey
Section titled “localizationKey”read-only
readonly localizationKey: string;The block’s name key in the language files.
Methods
Section titled “Methods”getBlock
Section titled “getBlock”getBlock(location: Vector3): Block | undefined;The block at a place, or undefined if its chunk isn’t loaded.
locationVector3
Block | undefinedsetBlockType
Section titled “setBlockType”setBlockType(location: Vector3, blockType: string | { id: string }): void;Puts a block there in its default state, as minecraft:stone.
locationVector3blockTypestring | { id: string }
setBlockPermutation
Section titled “setBlockPermutation”setBlockPermutation(location: Vector3, permutation: BlockPermutation): void;Puts a block there in exactly this state.
locationVector3permutationBlockPermutation
fillBlocks
Section titled “fillBlocks”fillBlocks(volume: BlockVolume, block: BlockPermutation | string, options?: unknown): number;Fills a box with a block (capped server-side like /fill); returns how many were set.
volumeBlockVolumeblockBlockPermutation | stringoptionsoptionalunknown
numbergetEntities
Section titled “getEntities”getEntities(options?: EntityFilterOptions): Entity[];Entities in loaded chunks, players among them, optionally filtered.
optionsoptionalEntityFilterOptions
Entity[]getPlayers
Section titled “getPlayers”getPlayers(options?: EntityQueryOptions & EntityFilterOptions): Player[];The players in it, narrowed by the options as getEntities is.
optionsoptionalEntityQueryOptions & EntityFilterOptions
Player[]spawnEntity
Section titled “spawnEntity”spawnEntity(identifier: string, location: Vector3): Entity;Brings a mob, or minecraft:xp_orb, into the world.
identifierstringlocationVector3
Entity- If there’s no such entity.
spawnItem
Section titled “spawnItem”spawnItem(itemStack: ItemStack, location: Vector3): ItemEntity;Sets an item down at a place.
itemStackItemStacklocationVector3
ItemEntitycreateExplosion
Section titled “createExplosion”createExplosion(location: Vector3, radius: number, explosionOptions?: ExplosionOptions): boolean;Sets off an explosion of this power.
locationVector3radiusnumberexplosionOptionsoptionalExplosionOptions
booleanplaySound
Section titled “playSound”playSound(soundId: string, location: Vector3, soundOptions?: { volume?: number; pitch?: number }): void;Plays a sound to every player.
soundIdstringlocationVector3soundOptionsoptional{ volume?: number; pitch?: number }
spawnParticle
Section titled “spawnParticle”spawnParticle(effectName: string, location: Vector3, molangVariables?: MolangVariableMap): void;Shows every player a particle effect.
effectNamestringlocationVector3molangVariablesoptionalMolangVariableMap
stopSound
Section titled “stopSound”stopSound(soundId: string): void;Stops a sound for every player.
soundIdstring
stopAllSounds
Section titled “stopAllSounds”stopAllSounds(): void;Stops every sound for every player.
getBlockAbove
Section titled “getBlockAbove”getBlockAbove(location: Vector3, options?: BlockRaycastOptions): Block | undefined;The first block above a place that isn’t air, or undefined if there’s none or its chunk isn’t loaded.
locationVector3optionsoptionalBlockRaycastOptions
Block | undefinedgetBlockBelow
Section titled “getBlockBelow”getBlockBelow(location: Vector3, options?: BlockRaycastOptions): Block | undefined;The first block below a place that isn’t air.
locationVector3optionsoptionalBlockRaycastOptions
Block | undefinedgetEntitiesAtBlockLocation
Section titled “getEntitiesAtBlockLocation”getEntitiesAtBlockLocation(location: Vector3): Entity[];The entities and players inside a block.
locationVector3
Entity[]getWeather
Section titled “getWeather”getWeather(): WeatherType;Whether it’s clear, raining or thundering.
WeatherTypesetWeather
Section titled “setWeather”setWeather(weatherType: WeatherType, duration?: number): void;For duration ticks, or vanilla’s random length.
weatherTypeWeatherTypedurationoptionalnumber
isChunkLoaded
Section titled “isChunkLoaded”isChunkLoaded(location: Vector3): boolean;Whether the chunk holding a block location is loaded.
locationVector3
booleangetChunk
Section titled “getChunk”getChunk(location: Vector3): ChunkInfo;getChunk(x: number, y: number, z: number): ChunkInfo;getChunk(chunkX: number, chunkZ: number): ChunkInfo;A chunk, named by the location of a block in it ({ x, y, z }, or
x, y, z), or by chunk coordinates (chunkX, chunkZ).
loadChunk
Section titled “loadChunk”loadChunk(location: Vector3): void;loadChunk(x: number, y: number, z: number): void;loadChunk(chunkX: number, chunkZ: number): void;Loads a chunk, generating it if new, and keeps it until
Dimension.unloadChunk. Named as in Dimension.getChunk.
unloadChunk
Section titled “unloadChunk”unloadChunk(location: Vector3): void;unloadChunk(x: number, y: number, z: number): void;unloadChunk(chunkX: number, chunkZ: number): void;Lets a chunk go, at once if no player is near. Named as in Dimension.getChunk.
runCommand
Section titled “runCommand”runCommand(commandString: string): CommandResult;Runs a command with the server’s permission, ~ counting from the world spawn.
commandStringstring
CommandResult- If the command fails or the server hasn’t started.
getBlockFromRay
Section titled “getBlockFromRay”getBlockFromRay(location: Vector3, direction: Vector3, options?: BlockRaycastOptions): BlockRaycastHit | undefined;The first block a ray from a point hits.
locationVector3directionVector3optionsoptionalBlockRaycastOptions
BlockRaycastHit | undefinedgetEntitiesFromRay
Section titled “getEntitiesFromRay”getEntitiesFromRay(location: Vector3, direction: Vector3, options?: EntityRaycastOptions): EntityRaycastHit[];The entities a ray from a point crosses, nearest first.
locationVector3directionVector3optionsoptionalEntityRaycastOptions
EntityRaycastHit[]getTopmostBlock
Section titled “getTopmostBlock”getTopmostBlock(locationXZ: VectorXZ, minHeight?: number): Block | undefined;The highest non-air block over an x/z, or undefined.
locationXZVectorXZminHeightoptionalnumber
Block | undefinedgetLightLevel
Section titled “getLightLevel”getLightLevel(location: Vector3): number;The light reaching a place.
locationVector3
numbergetSkyLightLevel
Section titled “getSkyLightLevel”getSkyLightLevel(location: Vector3): number;The skylight reaching a place.
locationVector3
numbercontainsBlock
Section titled “containsBlock”containsBlock(volume: BlockVolumeBase, filter: BlockFilter, allowUnloadedChunks?: boolean): boolean;Whether a box holds a block matching the filter.
volumeBlockVolumeBasefilterBlockFilterallowUnloadedChunksoptionalboolean
booleangetBlocks
Section titled “getBlocks”getBlocks(volume: BlockVolumeBase, options: BlockQueryOptions, allowUnloadedChunks?: boolean): ListBlockVolume;The blocks in a box matching the query.
volumeBlockVolumeBaseoptionsBlockQueryOptionsallowUnloadedChunksoptionalboolean
ListBlockVolumecloneBlocks
Section titled “cloneBlocks”cloneBlocks(beginLocation: Vector3, endLocation: Vector3, destination: Vector3, cloneMode: CloneMode, filter?: BlockFilter): void;Copies a box of blocks to another place.
beginLocationVector3endLocationVector3destinationVector3cloneModeCloneModefilteroptionalBlockFilter
spawnXp
Section titled “spawnXp”spawnXp(location: Vector3, amount: number): void;Drops experience orbs worth amount.
locationVector3amountnumber
getBiome
Section titled “getBiome”getBiome(location: Vector3): BiomeType;The biome at a place.
locationVector3
BiomeTypecontainsBiomes
Section titled “containsBiomes”containsBiomes(volume: BlockVolumeBase, biomeFilter: BiomeFilter, isSuperset: boolean): boolean;Whether a box holds the biomes the filter wants.
volumeBlockVolumeBasebiomeFilterBiomeFilterisSupersetboolean
booleancalculateClosestBiomeFromSeed
Section titled “calculateClosestBiomeFromSeed”calculateClosestBiomeFromSeed(pos: Vector3, biomeToFind: BiomeType | string, options?: BiomeSearchOptions): Vector3 | undefined;The nearest matching biome from the seed, searched from a point.
posVector3biomeToFindBiomeType | stringoptionsoptionalBiomeSearchOptions
Vector3 | undefinedplaceFeature
Section titled “placeFeature”placeFeature(featureName: string, location: Vector3, shouldThrow?: boolean): boolean;Places a named world-generation feature.
featureNamestringlocationVector3shouldThrowoptionalboolean
booleanplaceFeatureRule
Section titled “placeFeatureRule”placeFeatureRule(featureRuleName: string, location: Vector3): boolean;Places a named feature rule.
featureRuleNamestringlocationVector3
booleanUsed by
Section titled “Used by”DimensionLocation.dimension, TeleportOptions.dimension, Block.dimension, Entity.dimension, StructureManager.place, StructureManager.createFromWorld, BlockExplodeAfterEvent.dimension, ExplosionBeforeEvent.dimension, ExplosionAfterEvent.dimension, ProjectileHitBlockAfterEvent.dimension, ButtonPushAfterEvent.dimension, LeverActionAfterEvent.dimension, PistonActivateAfterEvent.dimension, PressurePlatePushAfterEvent.dimension, PressurePlatePopAfterEvent.dimension, TargetBlockHitAfterEvent.dimension, TripWireTripAfterEvent.dimension, ProjectileHitEntityAfterEvent.dimension, World.getDimension, BlockEvent.dimension, PlayerDimensionChangeAfterEvent.fromDimension, PlayerDimensionChangeAfterEvent.toDimension, PrimitiveShape.dimension, PrimitiveShapesManager.addText and 2 more