Skip to content

StructureTemplate 5.47.0 ​

final class · pocketmine\world\structure\StructureTemplate · source

A Bedrock structure template: the format of .mcstructure files, also stored in the world database under the key "structuretemplate_<name>" (verified with BDS 1.26.52, which writes format_version 2).

Blocks are stored in two layers (the second one holds the water of waterlogged blocks) of palette indexes, ordered by x, then y, then z (see StructureTemplate::index()). An index outside the palette (-1, which reads back as 0xffffffff from an int array) is a structure void: the block in the world is left as it is. Block entity data is keyed by block index; block entities and entities keep the world coordinates they had when saved, relative to StructureTemplate::getWorldOrigin().

Constants ​

FORMAT_VERSION ​

php
public const FORMAT_VERSION = 2

MAX_VOLUME ​

php
public const MAX_VOLUME = 64 * 384 * 64 * 4

Largest number of blocks accepted from saved data (four times the biggest structure block area)

TAG_BLOCK_ENTITY_DATA ​

php
public const TAG_BLOCK_ENTITY_DATA = "block_entity_data"

TAG_BLOCK_INDICES ​

php
public const TAG_BLOCK_INDICES = "block_indices"

TAG_BLOCK_PALETTE ​

php
public const TAG_BLOCK_PALETTE = "block_palette"

TAG_BLOCK_POSITION_DATA ​

php
public const TAG_BLOCK_POSITION_DATA = "block_position_data"

TAG_DEFAULT_PALETTE ​

php
public const TAG_DEFAULT_PALETTE = "default"

TAG_ENTITIES ​

php
public const TAG_ENTITIES = "entities"

TAG_FORMAT_VERSION ​

php
public const TAG_FORMAT_VERSION = "format_version"

TAG_PALETTE ​

php
public const TAG_PALETTE = "palette"

TAG_SIZE ​

php
public const TAG_SIZE = "size"

TAG_STRUCTURE ​

php
public const TAG_STRUCTURE = "structure"

TAG_WORLD_ORIGIN ​

php
public const TAG_WORLD_ORIGIN = "structure_world_origin"

VOID ​

php
public const VOID = -1

Methods ​

__construct() ​

php
public function __construct(int $sizeX, int $sizeY, int $sizeZ, array $palette, array $blocks, ?array $liquids = null, array $blockEntities = [], array $entities = [], int $originX = 0, int $originY = 0, int $originZ = 0)

empty() ​

php
public static function empty(int $sizeX, int $sizeY, int $sizeZ) : self

Creates a template where every block is a structure void.

fromBinary() ​

php
public static function fromBinary(string $data) : self

fromNbt() ​

php
public static function fromNbt(\pocketmine\nbt\tag\CompoundTag $root) : self

getBlockEntities() ​

php
public function getBlockEntities() : array

getBlockEntity() ​

php
public function getBlockEntity(int $index) : ?\pocketmine\nbt\tag\CompoundTag

getBlocks() ​

php
public function getBlocks() : array

getEntities() ​

php
public function getEntities() : array

getLiquidPaletteIndex() ​

php
public function getLiquidPaletteIndex(int $index) : ?int

Palette index of the liquid (layer 1) at the given block index, or null if there is none.

getLiquids() ​

php
public function getLiquids() : ?array

getPalette() ​

php
public function getPalette() : array

getPaletteIndex() ​

php
public function getPaletteIndex(int $index) : ?int

Palette index of the block at the given block index, or null for a structure void.

getSizeX() ​

php
public function getSizeX() : int

getSizeY() ​

php
public function getSizeY() : int

getSizeZ() ​

php
public function getSizeZ() : int

getVolume() ​

php
public function getVolume() : int

getWorldOrigin() ​

php
public function getWorldOrigin() : array

index() ​

php
public static function index(int $x, int $y, int $z, int $sizeY, int $sizeZ) : int

Index of the block at x/y/z (relative to the template) in the block layers.

isEmpty() ​

php
public function isEmpty() : bool

Whether the template has neither blocks (all structure voids) nor entities: vanilla refuses to save or load such a structure.

toBinary() ​

php
public function toBinary() : string

toNbt() ​

php
public function toNbt() : \pocketmine\nbt\tag\CompoundTag

VanillaMine is a fork of PocketMine-MP. Not affiliated with the PMMP team or Mojang.