Structure Class

Represents a loaded structure template (.mcstructure file). Structures can be placed in a world using the /structure command or the @minecraft/server.StructureManager APIs.

Properties

id

read-only id: string;

The name of the structure. The identifier must include a namespace. For structures created via the /structure command or structure blocks, this namespace defaults to "mystructure".

Type: string

size

read-only size: Vector3;

The dimensions of the structure. For example, a single block structure will have a size of {x:1, y:1, z:1}

Type: Vector3

Warning

This property can throw errors when used.

Throws InvalidStructureError

Methods

getBlockPermutation

getBlockPermutation(location: Vector3): BlockPermutation | undefined

Returns a BlockPermutation representing the block contained within the Structure at the given location.

Parameters

  • location: Vector3

    The block location relative to the Structure's origin.

Returns BlockPermutation | undefined - Returns a BlockPermutation. Returns undefined if a block does not exist at the given location.

Warning

This function can throw errors.

Throws @minecraft/common.InvalidArgumentError, InvalidStructureError

getIsWaterlogged

getIsWaterlogged(location: Vector3): boolean

Returns whether the block at the given location is waterlogged.

Parameters

  • location: Vector3

    The block location relative to the Structure's origin.

Returns boolean - Returns whether the block at the given location is waterlogged. Returns false if a block does not exist at the given location.

Warning

This function can throw errors.

Throws @minecraft/common.InvalidArgumentError, InvalidStructureError

isValid

isValid(): boolean

Returns whether the Structure is valid. The Structure may become invalid if it is deleted.

Returns boolean - Returns whether the Structure is valid.

saveAs

saveAs(identifier: string, saveMode?: StructureSaveMode): Structure

Creates a copy of a Structure and saves it with a new name.

Parameters

  • identifier: string

    The name of the newly created Structure.

  • saveMode?: StructureSaveMode = 1

    Determines how the Structure should be saved. Defaults to saving to the world.

Returns Structure - Returns the newly created structure.

Caution

This function is still in pre-release. Its signature may change or it may be removed in future releases.

Important

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

saveToWorld

saveToWorld(): void

Saves a modified Structure to the world file.

Caution

This function is still in pre-release. Its signature may change or it may be removed in future releases.

Important

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

Warning

This function can throw errors.

Throws InvalidStructureError

setBlockPermutation

setBlockPermutation(location: Vector3, blockPermutation?: BlockPermutation): void

Sets a BlockPermutation within a Structure.

Parameters

  • location: Vector3

    The block location relative to the Structure's origin.

  • blockPermutation?: BlockPermutation = null

    The BlockPermutation to set.

Caution

This function is still in pre-release. Its signature may change or it may be removed in future releases.

Important

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

Warning

This function can throw errors.

Throws @minecraft/common.InvalidArgumentError, InvalidStructureError