Skip to content

@minecraft/server


@minecraft/server / StructureManager

Class: StructureManager ​

Defined in: @minecraft/server/index.d.ts:20119

Manager for Structure related APIs. Includes APIs for creating, getting, placing and deleting Structures.

Methods ​

createEmpty() ​

createEmpty(identifier, size, saveMode?): Structure

Defined in: @minecraft/server/index.d.ts:20149

Parameters ​

identifier ​

string

The name of the structure. A valid identifier must include a namespace and must be unique.

size ​

Vector3

The size of the structure. For example, to create a single block structure the size should be {x:1, y:1, z:1}.

saveMode? ​

StructureSaveMode

How the Structure should be saved upon creation. Defaults to StructureSaveMode.Memory. Defaults to: 0

Returns ​

Structure

Returns the newly created Structure.

Remarks ​

Creates an empty Structure in memory. Use Structure.setBlockPermutation to populate the structure with blocks and save changes with Structure.saveAs.

This function can't be called in restricted-execution mode.

Throws ​

Throws if the identifier is invalid. A valid identifier must include a namespace and must be unique.

minecraftcommon.EngineError

minecraftcommon.InvalidArgumentError


createFromWorld() ​

createFromWorld(identifier, dimension, from, to, options?): Structure

Defined in: @minecraft/server/index.d.ts:20176

Parameters ​

identifier ​

string

The name of the structure. A valid identifier must include a namespace and must be unique.

dimension ​

Dimension

The dimension where the blocks should be read from.

from ​

Vector3

to ​

Vector3

options? ​

StructureCreateOptions

Additional options for creating a structure from the world.

Returns ​

Structure

Returns the newly created Structure.

Remarks ​

Creates a new Structure from blocks in the world. This is functionally equivalent to the /structure save command.

This function can't be called in restricted-execution mode.

Throws ​

Throws if the identifier is invalid. A valid identifier must include a namespace and must be unique. Throws if the structure bounds exceed the maximum size. Throws if the structure bounds contains blocks outside the world bounds.

minecraftcommon.InvalidArgumentError


delete() ​

delete(structure): boolean

Defined in: @minecraft/server/index.d.ts:20202

Parameters ​

structure ​

string | Structure

The structure identifier or Structure object that should be deleted. Note, a Structure object will become invalid after it is deleted.

Returns ​

boolean

Returns whether the structure was removed.

Remarks ​

Deletes a structure from memory and from the world if it exists.

This function can't be called in restricted-execution mode.

Throws ​

Throws if a structure cannot be removed. For example, a structure loaded from a Behavior Pack.

minecraftcommon.InvalidArgumentError


get() ​

get(identifier): Structure | undefined

Defined in: @minecraft/server/index.d.ts:20214

Parameters ​

identifier ​

string

The name of the structure to get.

Returns ​

Structure | undefined

Returns a Structure if it exists, otherwise undefined.

Remarks ​

Gets a Structure that is saved to memory or the world.

This function can't be called in restricted-execution mode.


getPackStructureIds() ​

getPackStructureIds(): string[]

Defined in: @minecraft/server/index.d.ts:20226

Returns ​

string[]

The list of structure identifiers.

Remarks ​

Returns a list of all structures contained in behavior packs. Does not include structures saved to the world or in memory.

This function can't be called in restricted-execution mode.


getWorldStructureIds() ​

getWorldStructureIds(): string[]

Defined in: @minecraft/server/index.d.ts:20238

Returns ​

string[]

The list of structure identifiers.

Remarks ​

Returns a list of all structures saved to the world and to memory. Does not include structures contained in behavior packs.

This function can't be called in restricted-execution mode.


place() ​

place(structure, dimension, location, options?): void

Defined in: @minecraft/server/index.d.ts:20267

Parameters ​

structure ​

string | Structure

The structure's identifier or a Structure object.

dimension ​

Dimension

The dimension where the Structure should be placed.

location ​

Vector3

The location within the dimension where the Structure should be placed.

options? ​

StructurePlaceOptions

Additional options for Structure placement.

Returns ​

void

Remarks ​

Places a structure in the world. Structures placed in unloaded chunks will be queued for loading.

This function can't be called in restricted-execution mode.

Throws ​

Throws if the integrity value is outside of the range [0,1] Throws if the integrity seed is invalid. Throws if the placement location contains blocks that are outside the world bounds.

minecraftcommon.ArgumentOutOfBoundsError

minecraftcommon.InvalidArgumentError

InvalidStructureError


placeJigsaw() ​

placeJigsaw(pool, targetJigsaw, maxDepth, dimension, location, options?): BlockBoundingBox

Defined in: @minecraft/server/index.d.ts:20309

Parameters ​

pool ​

string

The identifier of the template pool to start from.

targetJigsaw ​

string

The name of the jigsaw block to start from. This block must be included in at least one of the starting pool structure templates.

maxDepth ​

number

The maximum recursion depth for the jigsaw structure. Bounds: [1, 20]

dimension ​

Dimension

The dimension to place the jigsaw structure in.

location ​

Vector3

The location where the jigsaw structure will begin generating relative to the targetJigsaw block.

options? ​

JigsawPlaceOptions

Optional settings to use when generating the jigsaw structure.

Returns ​

BlockBoundingBox

Returns a BlockBoundingBox object which represents the maximum bounds of the jigsaw structure.

Remarks ​

Places a partial jigsaw structure in the world. This is useful for debugging connections between jigsaw blocks.

This function can't be called in restricted-execution mode.

Throws ​

Throws if maxDepth is outside of the range [1,20] Throws if generation fails due to invalid parameters or jigsaw configuration. Throws if the placement location contains blocks that are outside the world bounds.

PlaceJigsawError


placeJigsawStructure() ​

placeJigsawStructure(identifier, dimension, location, options?): BlockBoundingBox

Defined in: @minecraft/server/index.d.ts:20347

Parameters ​

identifier ​

string

The identifier of the jigsaw structure.

dimension ​

Dimension

The dimension to place the jigsaw structure in.

location ​

Vector3

The location where the jigsaw structure will begin generating. Note that the y value will be overridden by the structure's start height unless the ignoreStarJigsawStructurePlaceOptions ignoreStartHeight option is set.

options? ​

JigsawStructurePlaceOptions

Optional settings to use when generating the jigsaw structure.

Returns ​

BlockBoundingBox

Returns a BlockBoundingBox object which represents the maximum bounds of the jigsaw structure.

Remarks ​

Places a jigsaw structure in the world.

This function can't be called in restricted-execution mode.

Throws ​

Throws if generation fails due to invalid parameters or jigsaw configuration. Throws if the placement location contains blocks that are outside the world bounds.

PlaceJigsawError