Skip to content

@minecraft/server


@minecraft/server / Structure

Class: Structure ​

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

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

Extends ​

Properties ​

id ​

readonly id: string

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

Remarks ​

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".


isValid ​

readonly isValid: boolean

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

Remarks ​

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


size ​

readonly size: Vector3

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

Remarks ​

The dimensions of the structure. For example, a single block structure will have a size of

Throws ​

This property can throw when used.

InvalidStructureError

Methods ​

getBlockPermutation() ​

getBlockPermutation(location): BlockPermutation | undefined

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

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.

Remarks ​

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

Throws ​

Throws if the location is outside the structure's bounds. Throws if the Structure has been deleted.

minecraftcommon.InvalidArgumentError

InvalidStructureError


getIsWaterlogged() ​

getIsWaterlogged(location): boolean

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

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.

Remarks ​

Returns whether the block at the given location is waterlogged.

Throws ​

Throws if the location is outside the structure's bounds. Throws if the Structure has been deleted.

minecraftcommon.InvalidArgumentError

InvalidStructureError


saveAs() ​

saveAs(identifier, saveMode?): Structure

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

Parameters ​

identifier ​

string

The name of the newly created Structure.

saveMode? ​

StructureSaveMode

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

Returns ​

Structure

Returns the newly created structure.

Remarks ​

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

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 has been deleted.

minecraftcommon.EngineError

minecraftcommon.InvalidArgumentError

InvalidStructureError


saveToWorld() ​

saveToWorld(): void

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

Returns ​

void

Remarks ​

Saves a modified Structure to the world file.

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

Throws ​

Throws if the Structure has been deleted.

InvalidStructureError


setBlockPermutation() ​

setBlockPermutation(location, blockPermutation?, waterlogged?): void

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

Parameters ​

location ​

Vector3

The block location relative to the Structure's origin.

blockPermutation? ​

BlockPermutation

The BlockPermutation to set. Defaults to: null

waterlogged? ​

boolean

Specifies whether the block should be waterlogged. Air and undefined blocks cannot be waterlogged. Defaults to: false

Returns ​

void

Remarks ​

Sets a BlockPermutation within a Structure.

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

Throws ​

Throws if the type of block is StructureVoid. Throws if the block is undefined and waterlogged is set to true. Throws if the block is air and waterlogged is set to true. Throws if the location is outside the structure's bounds. Throws if the Structure has been deleted.

minecraftcommon.InvalidArgumentError

InvalidStructureError