Skip to main content

Class: StructureManager

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

Constructors

new StructureManager()

private new StructureManager(): StructureManager

Returns

StructureManager

Methods

createEmpty()

createEmpty(identifier, size, saveMode?): Structure

Parameters

ParameterTypeDescription
identifierstringThe name of the structure. A valid identifier must include a
namespace and must be unique.
sizeVector3The size of the structure. For example, to create a single
block structure the size should be {x:1, y:1, z:1}.
saveMode?StructureSaveModeHow the Structure should be saved upon creation. Defaults to
StructureSaveMode.Memory.

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 @minecraft/server.Structure.save.

This function can't be called in read-only mode.

Throws

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

minecraftcommon.EngineError

minecraftcommon.InvalidArgumentError


createFromWorld()

Beta

createFromWorld(identifier, dimension, blockVolume, options?): Structure

Parameters

ParameterTypeDescription
identifierstringThe name of the structure. A valid identifier must include a
namespace and must be unique.
dimensionDimensionThe dimension where the blocks should be read from.
blockVolumeBlockVolumeThe location and bounds of the blocks that should be read.
options?StructureCreateOptionsAdditional 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 read-only 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

Parameters

ParameterTypeDescription
structurestring | StructureThe 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 read-only mode.

Throws

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

minecraftcommon.InvalidArgumentError


get()

get(identifier): Structure

Parameters

ParameterTypeDescription
identifierstringThe name of the structure to get.

Returns

Structure

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 read-only mode.


getIds()

Beta

getIds(): string[]

Returns

string[]

Remarks

This function can't be called in read-only mode.


place()

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

Parameters

ParameterTypeDescription
structurestring | StructureThe structure's identifier or a Structure object.
dimensionDimensionThe dimension where the Structure should be placed.
locationVector3The location within the dimension where the Structure should
be placed.
options?StructurePlaceOptionsAdditional 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 read-only 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