Class: Dimension
dimensionBeta
A class that represents a particular dimension (e.g., The End) within a world.
Properties
heightRange
readonlyheightRange:NumberRange
Beta
Remarks
Height range of the dimension.
Throws
This property can throw when used.
id
readonlyid:string
Beta
Remarks
Identifier of the dimension.
localizationKey
readonlylocalizationKey:string
Beta
Remarks
Key for the localization of a dimension's name used by language files.
Methods
calculateClosestBiomeFromSeed()
calculateClosestBiomeFromSeed(
pos,biomeToFind,options?):Vector3|undefined
Beta
Parameters
pos
Starting location to look for a biome to find.
biomeToFind
string | BiomeType
Identifier of the biome to look for.
options?
Additional selection criteria for a biome search.
Returns
Vector3 | undefined
Returns a location of the biome, or undefined if a biome could not be found.
Preview
Remarks
Calculates the location of the closest biome of a particular type from the world seed. Note that calculateClosestBiomeFromSeed can be an expensive operation, so avoid using many of these calls within a particular tick. The result is derived purely from the world generation algorithm and the world seed, so the returned location may not reflect the actual current terrain if biomes have been modified after generation.
Throws
This function can throw errors.
Error
cloneBlocks()
cloneBlocks(
beginLocation,endLocation,destination,cloneMode,filter?):void
Beta World Mutation
Parameters
beginLocation
The lower northwest starting corner of the area to clone from.
endLocation
The upper southeast ending corner of the area to clone from.
destination
The lower northwest starting corner of the area to clone to.
cloneMode
Specifies how the cloned blocks should be placed at the destination.
filter?
An optional block filter used to include only matching blocks from the source area.
Returns
void
Remarks
Clones a region of blocks from one area of the dimension to another.
Throws
This function can throw errors.
Error
LocationOutOfWorldBoundariesError
containsBiomes()
containsBiomes(
volume,biomeFilter,isSuperset):boolean
Beta
Parameters
volume
Area to check biomes in.
biomeFilter
A list of biomes to include and exclude. A list of tags to include and exclude. Will return false if a biome is found in the area that is in the excluded list or contains any of the excluded tags.
isSuperset
boolean
Superset is used to determine the strictness of the filter. If superset is set to true then the area must contain one or more biomes in the included list or that contains all of the included tags. If superset is set to false then the area must contain only biomes in the included list and that contain all of the included tags
Returns
boolean
Returns true if the biomes in the area match the filter settings passed in. Otherwise, returns false.
Remarks
Checks if an area contains the specified biomes. If the area is partially inside world boundaries, only the area that is in bounds will be searched. This operation takes longer proportional to both the area of the volume and the number of biomes to check.
Throws
An error will be thrown if the area provided includes unloaded chunks. An error will be thrown if the area provided is completely outside the world boundaries. An error will be thrown if an unknown biome name is provided.
LocationOutOfWorldBoundariesError
containsBlock()
containsBlock(
volume,filter,allowUnloadedChunks?):boolean
Beta
Parameters
volume
Volume of blocks that will be checked.
filter
Block filter that will be checked against each block in the volume.
allowUnloadedChunks?
boolean
If set to true will suppress the UnloadedChunksError if some or all of the block volume is outside of the loaded chunks. Will only check the block locations that are within the loaded chunks in the volume. Defaults to: false
Returns
boolean
Returns true if at least one block in the volume satisfies the filter, false otherwise.
Remarks
Searches the block volume for a block that satisfies the block filter.
Throws
This function can throw errors.
Error
createExplosion()
createExplosion(
location,radius,explosionOptions?):boolean
World Mutation Beta
Parameters
location
The location of the explosion.
radius
number
Radius, in blocks, of the explosion to create. Bounds: [0, 1000]
explosionOptions?
Additional configurable options for the explosion.
Returns
boolean
Remarks
Creates an explosion at the specified location.
Throws
This function can throw errors.
LocationOutOfWorldBoundariesError
Examples
createExplosion.ts
createNoBlockExplosion.ts
createExplosions.ts
fillBlocks()
fillBlocks(
volume,block,options?):ListBlockVolume
World Mutation Beta
Parameters
volume
Volume of blocks to be filled.
block
string | BlockPermutation | BlockType
Type of block to fill the volume with.
options?
A set of additional options, such as a block filter which can be used to include / exclude specific blocks in the fill.
Returns
Returns a ListBlockVolume which contains all the blocks that were placed.
Remarks
Fills an area of blocks with a specific block type.
Throws
This function can throw errors.
Error
getBiome()
getBiome(
location):BiomeType
Beta
Parameters
location
Location at which to check the biome.
Returns
Remarks
Returns the biome type at the specified location.
Throws
An error will be thrown if the location is out of world bounds. An error will be thrown if the location is in an unloaded chunk.
LocationOutOfWorldBoundariesError
getBlock()
getBlock(
location):Block|undefined
Beta
Parameters
location
The location at which to return a block.
Returns
Block | undefined
Block at the specified location, or 'undefined' if asking for a block at an unloaded chunk.
Remarks
Returns a block instance at the given location.
Throws
PositionInUnloadedChunkError: Exception thrown when trying to interact with a Block object that isn't in a loaded and ticking chunk anymore
PositionOutOfWorldBoundariesError: Exception thrown when trying to interact with a position outside of dimension height range
LocationOutOfWorldBoundariesError
getBlockAbove()
getBlockAbove(
location,options?):Block|undefined
Beta
Parameters
location
Location to retrieve the block above from.
options?
The options to decide if a block is a valid result.
Returns
Block | undefined
Remarks
Gets the first block found above a given block location based on the given options (by default will find the first solid block above).
Throws
This function can throw errors.
getBlockBelow()
getBlockBelow(
location,options?):Block|undefined
Beta
Parameters
location
Location to retrieve the block below from.
options?
The options to decide if a block is a valid result.
Returns
Block | undefined
Remarks
Gets the first block found below a given block location based on the given options (by default will find the first solid block below).
Throws
This function can throw errors.
getBlockFromRay()
getBlockFromRay(
location,direction,options?):BlockRaycastHit|undefined
Beta
Parameters
location
Location from where to initiate the ray check.
direction
Vector direction to cast the ray.
options?
Additional options for processing this raycast query.
Returns
BlockRaycastHit | undefined
Remarks
Gets the first block that intersects with a vector emanating from a location.
Throws
This function can throw errors.
getBlocks()
getBlocks(
volume,options,allowUnloadedChunks?):ListBlockVolume
Beta
Parameters
volume
Volume of blocks that will be checked.
options
Block query options including filter criteria and optional closest/farthest distance sorting from a location.
allowUnloadedChunks?
boolean
If set to true will suppress the UnloadedChunksError if some or all of the block volume is outside of the loaded chunks. Will only check the block locations that are within the loaded chunks in the volume. Defaults to: false
Returns
Returns the ListBlockVolume that contains all the block locations that satisfied the block query options.
Preview
Remarks
Gets all the blocks in a volume that satisfy the block query options.
Throws
This function can throw errors.
Error
getEntities()
getEntities(
options?):Entity[]
Beta
Parameters
options?
Additional options that can be used to filter the set of entities returned.
Returns
Entity[]
An entity array.
Remarks
Returns a set of entities based on a set of conditions defined via the EntityQueryOptions set of filter criteria.
Throws
This function can throw errors.
Examples
bounceSkeletons.ts
tagsQuery.ts
testThatEntityIsFeatherItem.ts
getEntitiesAtBlockLocation()
getEntitiesAtBlockLocation(
location):Entity[]
Beta
Parameters
location
The location at which to return entities.
Returns
Entity[]
Zero or more entities at the specified location.
Remarks
Returns a set of entities at a particular location.
getEntitiesFromRay()
getEntitiesFromRay(
location,direction,options?):EntityRaycastHit[]
Beta
Parameters
location
direction
options?
Additional options for processing this raycast query.
Returns
Remarks
Gets entities that intersect with a specified vector emanating from a location.
Throws
This function can throw errors.
getGeneratedStructures()
getGeneratedStructures(
location):any[]
Beta
Parameters
location
Location at which to check for structures.
Returns
any[]
Remarks
Returns a vector of generated structures that contain the specified location (ex: Pillager Outpost, Mineshaft, etc.). The vector will be empty if no structures are found.
Throws
An error will be thrown if the location is out of world bounds. An error will be thrown if the location is in an unloaded chunk.
LocationOutOfWorldBoundariesError
getLightLevel()
getLightLevel(
location):number
Beta
Parameters
location
Location of the block we want to check the brightness of.
Returns
number
The brightness level on the block.
Remarks
Returns the total brightness level of light shining on a certain block position.
Throws
This function can throw errors.
getPlayers()
getPlayers(
options?):Player[]
Beta
Parameters
options?
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.
getSkyLightLevel()
getSkyLightLevel(
location):number
Beta
Parameters
location
Position of the block we want to check the brightness of.
Returns
number
The brightness level on the block.
Remarks
Returns the brightness level of light shining from the sky on a certain block position.
Throws
This function can throw errors.
getTopmostBlock()
getTopmostBlock(
locationXZ,minHeight?):Block|undefined
Beta
Parameters
locationXZ
Location to retrieve the topmost block for.
minHeight?
number
The Y height to begin the search from. Defaults to the maximum dimension height.
Returns
Block | undefined
Remarks
Returns the highest block at the given XZ location.
Throws
This function can throw errors.
getWeather()
getWeather():
WeatherType
Beta
Returns
Returns a WeatherType that explains the broad category of weather that is currently going on.
Remarks
Returns the current weather.
isChunkLoaded()
isChunkLoaded(
location):boolean
Beta
Parameters
location
Location to check if the chunk is loaded.
Returns
boolean
Remarks
Returns true if the chunk at the given location is loaded (and valid for use with scripting).
placeFeature()
placeFeature(
featureName,location,shouldThrow?):boolean
World Mutation Beta
Parameters
featureName
string
The string identifier for the feature.
location
Location to place the feature.
shouldThrow?
boolean
Specifies if the function call will throw an error if the feature could not be placed. Note: The function call will always throw an error if using an unknown feature name or trying to place in a unloaded chunk. Defaults to: false
Returns
boolean
Remarks
Places the given feature into the dimension at the specified location.
Throws
An error will be thrown if the feature name is invalid. An error will be thrown if the location is in an unloaded chunk.
Error
placeFeatureRule()
placeFeatureRule(
featureRuleName,location):boolean
World Mutation Beta
Parameters
featureRuleName
string
The string identifier for the feature rule.
location
Location to place the feature rule.
Returns
boolean
Remarks
Places the given feature rule into the dimension at the specified location.
Throws
An error will be thrown if the feature rule name is invalid. An error will be thrown if the location is in an unloaded chunk.
playSound()
playSound(
soundId,location,soundOptions?):SoundInstance
World Mutation Beta
Parameters
soundId
string
Identifier of the sound.
location
Location of the sound.
soundOptions?
Additional options for configuring additional effects for the sound.
Returns
Remarks
Plays a sound for all players.
Throws
An error will be thrown if volume is less than 0.0. An error will be thrown if fade is less than 0.0. An error will be thrown if pitch is less than 0.01. An error will be thrown if volume is less than 0.0.
runCommand()
runCommand(
commandString):CommandResult
World Mutation Beta
Parameters
commandString
string
Command to run. Note that command strings should not start with slash.
Returns
Returns a command result with a count of successful values from the command.
Remarks
Runs a command synchronously using the context of the broader dimenion.
Throws
Throws an exception if the command fails due to incorrect parameters or command syntax, or in erroneous cases for the command. Note that in many cases, if the command does not operate (e.g., a target selector found no matches), this method will not throw an exception.
setBlockPermutation()
setBlockPermutation(
location,permutation):void
World Mutation Beta
Parameters
location
The location within the dimension to set the block.
permutation
The block permutation to set.
Returns
void
Remarks
Sets a block in the world using a BlockPermutation. BlockPermutations are blocks with a particular state.
Throws
Throws if the location is within an unloaded chunk or outside of the world bounds.
LocationOutOfWorldBoundariesError
setBlockType()
setBlockType(
location,blockType):void
World Mutation Beta
Parameters
location
The location within the dimension to set the block.
blockType
string | BlockType
The type of block to set. This can be either a string identifier or a BlockType. The default block permutation is used.
Returns
void
Remarks
Sets a block at a given location within the dimension.
Throws
Throws if the location is within an unloaded chunk or outside of the world bounds.
Error
LocationOutOfWorldBoundariesError
setWeather()
setWeather(
weatherType,duration?):void
World Mutation Beta
Parameters
weatherType
Set the type of weather to apply.
duration?
number
Sets the duration of the weather (in ticks). If no duration is provided, the duration will be set to a random duration between 300 and 900 seconds. Bounds: [1, 1000000]
Returns
void
Remarks
Sets the current weather within the dimension
Throws
This function can throw errors.
spawnEntity()
spawnEntity<
T>(identifier,location,options?):Entity
World Mutation Beta
Type Parameters
T
T = never
Parameters
identifier
EntityIdentifierType<NoInfer<T>>
Identifier of the type of entity to spawn. If no namespace is specified, 'minecraft:' is assumed.
location
The location at which to create the entity.
options?
Returns
Newly created entity at the specified location.
Remarks
Creates a new entity (e.g., a mob) at the specified location.
Throws
This function can throw errors.
LocationOutOfWorldBoundariesError
Examples
spawnAdultHorse.ts
quickFoxLazyDog.ts
triggerEvent.ts
spawnItem()
spawnItem(
itemStack,location):Entity
World Mutation Beta
Parameters
itemStack
location
The location at which to create the item stack.
Returns
Newly created item stack entity at the specified location.
Remarks
Creates a new item stack as an entity at the specified location.
Throws
This function can throw errors.
LocationOutOfWorldBoundariesError
Examples
itemStacks.ts
spawnFeatherItem.ts
spawnParticle()
spawnParticle(
effectName,location,molangVariables?):void
World Mutation Beta
Parameters
effectName
string
Identifier of the particle to create.
location
The location at which to create the particle emitter.
molangVariables?
A set of optional, customizable variables that can be adjusted for this particle.
Returns
void
Remarks
Creates a new particle emitter at a specified location in the world.
Throws
This function can throw errors.
LocationOutOfWorldBoundariesError
Example
spawnParticle.ts
spawnXp()
spawnXp(
location,amount):void
Beta World Mutation
Parameters
location
The location at which to spawn the experience orb.
amount
number
The amount of experience to give the experience orb. Bounds: [1, 12000]
Returns
void
Remarks
Spawns an experience orb at a specified location in the dimension.
Throws
This function can throw errors.
LocationOutOfWorldBoundariesError
stopAllSounds()
stopAllSounds():
void
Beta World Mutation
Returns
void
Remarks
Stops all sounds from playing for all players.
stopSound()
stopSound(
soundId):void
Beta World Mutation
Parameters
soundId
string
Identifier of the sound.
Returns
void
Remarks
Stops a sound from playing for all players.
