Skip to content

StructureBlock 5.47.0 ​

class · pocketmine\block\tile\StructureBlock · source

Extends Spawnable

Block entity of a structure block (Bedrock ID "StructureBlock", same fields and defaults as BDS 1.26.52). In save mode it saves the box at its offset and size as a structure template of the world (see StructureTemplateStorage); in load mode it loads the template of its name at its offset, with its rotation, mirror, integrity, seed and animation; in corner mode it marks a corner of the area found by StructureBlock::detectSize(); data mode only holds a text for the structures generated by the game. A redstone signal turning on saves (in memory or to disk, as its redstone save mode says) or loads.

"isPowered" is the redstone state in the saved data (like Java's "powered"), so that a block still powered when its chunk loads again doesn't see a new signal; clients always get false, like BDS sends.

Constants ​

CORNER_SCAN_RANGE ​

php
public const CORNER_SCAN_RANGE = 80

Horizontal distance searched for corner blocks (vanilla StructureBlockEntity.SCAN_CORNER_BLOCKS_RANGE)

MAX_ANIMATION_SECONDS ​

php
public const MAX_ANIMATION_SECONDS = 3600.0

MAX_NAME_LENGTH ​

php
public const MAX_NAME_LENGTH = 128

MAX_OFFSET_X ​

php
public const MAX_OFFSET_X = 64

MAX_OFFSET_Y ​

php
public const MAX_OFFSET_Y = 384

MAX_OFFSET_Z ​

php
public const MAX_OFFSET_Z = 64

MAX_SIZE_X ​

php
public const MAX_SIZE_X = 64

MAX_SIZE_Y ​

php
public const MAX_SIZE_Y = 384

MAX_SIZE_Z ​

php
public const MAX_SIZE_Z = 64

REDSTONE_SAVE_DISK ​

php
public const REDSTONE_SAVE_DISK = 1

REDSTONE_SAVE_MEMORY ​

php
public const REDSTONE_SAVE_MEMORY = 0

TAG_ANIMATION_MODE ​

php
public const TAG_ANIMATION_MODE = "animationMode"

TAG_ANIMATION_SECONDS ​

php
public const TAG_ANIMATION_SECONDS = "animationSeconds"

TAG_DATA_FIELD ​

php
public const TAG_DATA_FIELD = "dataField"

TAG_IGNORE_ENTITIES ​

php
public const TAG_IGNORE_ENTITIES = "ignoreEntities"

TAG_INCLUDE_PLAYERS ​

php
public const TAG_INCLUDE_PLAYERS = "includePlayers"

TAG_INTEGRITY ​

php
public const TAG_INTEGRITY = "integrity"

TAG_IS_POWERED ​

php
public const TAG_IS_POWERED = "isPowered"

TAG_LAST_TOUCHED_PLAYER_ID ​

php
public const TAG_LAST_TOUCHED_PLAYER_ID = "lastTouchedPlayerId"

TAG_MIRROR ​

php
public const TAG_MIRROR = "mirror"

TAG_MODE ​

php
public const TAG_MODE = "data"

TAG_OFFSET_X ​

php
public const TAG_OFFSET_X = "xStructureOffset"

TAG_OFFSET_Y ​

php
public const TAG_OFFSET_Y = "yStructureOffset"

TAG_OFFSET_Z ​

php
public const TAG_OFFSET_Z = "zStructureOffset"

TAG_REDSTONE_SAVE_MODE ​

php
public const TAG_REDSTONE_SAVE_MODE = "redstoneSaveMode"

TAG_REMOVE_BLOCKS ​

php
public const TAG_REMOVE_BLOCKS = "removeBlocks"

TAG_ROTATION ​

php
public const TAG_ROTATION = "rotation"

TAG_SEED ​

php
public const TAG_SEED = "seed"

TAG_SHOW_BOUNDING_BOX ​

php
public const TAG_SHOW_BOUNDING_BOX = "showBoundingBox"

TAG_SIZE_X ​

php
public const TAG_SIZE_X = "xStructureSize"

TAG_SIZE_Y ​

php
public const TAG_SIZE_Y = "yStructureSize"

TAG_SIZE_Z ​

php
public const TAG_SIZE_Z = "zStructureSize"

TAG_STRUCTURE_NAME ​

php
public const TAG_STRUCTURE_NAME = "structureName"

Methods ​

addAdditionalSpawnData() protected ​

php
protected function addAdditionalSpawnData(\pocketmine\nbt\tag\CompoundTag $nbt) : void

close() ​

php
public function close() : void

detectSize() ​

php
public function detectSize() : bool

Finds the corner blocks with the same structure name around the block (the screen's Detect button in save mode) and sets the offset and size to the area between them. Returns whether an area was found.

getAnimationMode() ​

php
public function getAnimationMode() : int

getAnimationSeconds() ​

php
public function getAnimationSeconds() : float

getDataField() ​

php
public function getDataField() : string

getIntegrity() ​

php
public function getIntegrity() : float

getLastTouchedPlayerId() ​

php
public function getLastTouchedPlayerId() : int

getMirror() ​

php
public function getMirror() : \pocketmine\world\structure\StructureMirror

getMode() ​

php
public function getMode() : \pocketmine\block\utils\StructureBlockType

getOffset() ​

php
public function getOffset() : \pocketmine\math\Vector3

getRedstoneSaveMode() ​

php
public function getRedstoneSaveMode() : int

getRotation() ​

php
public function getRotation() : \pocketmine\world\structure\StructureRotation

getSeed() ​

php
public function getSeed() : int

getSize() ​

php
public function getSize() : \pocketmine\math\Vector3

getStructureName() ​

php
public function getStructureName() : string

isIgnoreEntities() ​

php
public function isIgnoreEntities() : bool

isIncludePlayers() ​

php
public function isIncludePlayers() : bool

isLoadingStructure() ​

php
public function isLoadingStructure() : bool

Whether a structure is being loaded by this block (big or animated structures take several ticks).

isRemoveBlocks() ​

php
public function isRemoveBlocks() : bool

isShowBoundingBox() ​

php
public function isShowBoundingBox() : bool

isValidStructureName() ​

php
public static function isValidStructureName(string $name) : bool

Whether the name can be used as a structure template name: not empty, printable, at most MAX_NAME_LENGTH long.

loadStructure() ​

php
public function loadStructure() : ?\pocketmine\lang\Translatable

Loads the template of the block's name at its offset, with its settings. Big or animated structures are loaded over several ticks. Returns an error message, or null if it worked (or started).

onRedstoneSignal() ​

php
public function onRedstoneSignal(bool $powered) : void

Called when the redstone signal reaching the block changes: when it turns on, saves (as the redstone save mode says) or loads.

readSaveData() ​

php
public function readSaveData(\pocketmine\nbt\tag\CompoundTag $nbt) : void

saveStructure() ​

php
public function saveStructure(bool $toDisk) : ?\pocketmine\lang\Translatable

Saves the box at the block's offset and size as the template of its name. Returns an error message, or null if it worked.

setAnimationMode() ​

php
public function setAnimationMode(int $mode) : void

setAnimationSeconds() ​

php
public function setAnimationSeconds(float $seconds) : void

setDataField() ​

php
public function setDataField(string $dataField) : void

setIgnoreEntities() ​

php
public function setIgnoreEntities(bool $ignoreEntities) : void

setIncludePlayers() ​

php
public function setIncludePlayers(bool $includePlayers) : void

setIntegrity() ​

php
public function setIntegrity(float $integrity) : void

setLastTouchedPlayerId() ​

php
public function setLastTouchedPlayerId(int $id) : void

setMirror() ​

php
public function setMirror(\pocketmine\world\structure\StructureMirror $mirror) : void

setMode() ​

php
public function setMode(\pocketmine\block\utils\StructureBlockType $mode) : void

Sets the mode of the block entity only: use BlockStructureBlock::setMode() to change the block (which updates its block entity).

setOffset() ​

php
public function setOffset(int $x, int $y, int $z) : void

Sets the offset of the structure from the block, clamped to the vanilla limits.

setRedstoneSaveMode() ​

php
public function setRedstoneSaveMode(int $mode) : void

setRemoveBlocks() ​

php
public function setRemoveBlocks(bool $removeBlocks) : void

setRotation() ​

php
public function setRotation(\pocketmine\world\structure\StructureRotation $rotation) : void

setSeed() ​

php
public function setSeed(int $seed) : void

setShowBoundingBox() ​

php
public function setShowBoundingBox(bool $showBoundingBox) : void

setSize() ​

php
public function setSize(int $x, int $y, int $z) : void

Sets the size of the structure, clamped to the vanilla limits (0 to 64x384x64).

setStructureName() ​

php
public function setStructureName(string $name) : void

trigger() ​

php
public function trigger() : ?\pocketmine\lang\Translatable

Saves or loads, as the screen's Save and Load buttons do (saves always go to disk). Returns an error message, or null if it worked.

writeSaveData() protected ​

php
protected function writeSaveData(\pocketmine\nbt\tag\CompoundTag $nbt) : void

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