StructureBlock 5.47.0
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
public const CORNER_SCAN_RANGE = 80Horizontal distance searched for corner blocks (vanilla StructureBlockEntity.SCAN_CORNER_BLOCKS_RANGE)
MAX_ANIMATION_SECONDS
public const MAX_ANIMATION_SECONDS = 3600.0MAX_NAME_LENGTH
public const MAX_NAME_LENGTH = 128MAX_OFFSET_X
public const MAX_OFFSET_X = 64MAX_OFFSET_Y
public const MAX_OFFSET_Y = 384MAX_OFFSET_Z
public const MAX_OFFSET_Z = 64MAX_SIZE_X
public const MAX_SIZE_X = 64MAX_SIZE_Y
public const MAX_SIZE_Y = 384MAX_SIZE_Z
public const MAX_SIZE_Z = 64REDSTONE_SAVE_DISK
public const REDSTONE_SAVE_DISK = 1REDSTONE_SAVE_MEMORY
public const REDSTONE_SAVE_MEMORY = 0TAG_ANIMATION_MODE
public const TAG_ANIMATION_MODE = "animationMode"TAG_ANIMATION_SECONDS
public const TAG_ANIMATION_SECONDS = "animationSeconds"TAG_DATA_FIELD
public const TAG_DATA_FIELD = "dataField"TAG_IGNORE_ENTITIES
public const TAG_IGNORE_ENTITIES = "ignoreEntities"TAG_INCLUDE_PLAYERS
public const TAG_INCLUDE_PLAYERS = "includePlayers"TAG_INTEGRITY
public const TAG_INTEGRITY = "integrity"TAG_IS_POWERED
public const TAG_IS_POWERED = "isPowered"TAG_LAST_TOUCHED_PLAYER_ID
public const TAG_LAST_TOUCHED_PLAYER_ID = "lastTouchedPlayerId"TAG_MIRROR
public const TAG_MIRROR = "mirror"TAG_MODE
public const TAG_MODE = "data"TAG_OFFSET_X
public const TAG_OFFSET_X = "xStructureOffset"TAG_OFFSET_Y
public const TAG_OFFSET_Y = "yStructureOffset"TAG_OFFSET_Z
public const TAG_OFFSET_Z = "zStructureOffset"TAG_REDSTONE_SAVE_MODE
public const TAG_REDSTONE_SAVE_MODE = "redstoneSaveMode"TAG_REMOVE_BLOCKS
public const TAG_REMOVE_BLOCKS = "removeBlocks"TAG_ROTATION
public const TAG_ROTATION = "rotation"TAG_SEED
public const TAG_SEED = "seed"TAG_SHOW_BOUNDING_BOX
public const TAG_SHOW_BOUNDING_BOX = "showBoundingBox"TAG_SIZE_X
public const TAG_SIZE_X = "xStructureSize"TAG_SIZE_Y
public const TAG_SIZE_Y = "yStructureSize"TAG_SIZE_Z
public const TAG_SIZE_Z = "zStructureSize"TAG_STRUCTURE_NAME
public const TAG_STRUCTURE_NAME = "structureName"Methods
addAdditionalSpawnData() protected
protected function addAdditionalSpawnData(\pocketmine\nbt\tag\CompoundTag $nbt) : voidclose()
public function close() : voiddetectSize()
public function detectSize() : boolFinds 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()
public function getAnimationMode() : intgetAnimationSeconds()
public function getAnimationSeconds() : floatgetDataField()
public function getDataField() : stringgetIntegrity()
public function getIntegrity() : floatgetLastTouchedPlayerId()
public function getLastTouchedPlayerId() : intgetMirror()
public function getMirror() : \pocketmine\world\structure\StructureMirrorgetMode()
public function getMode() : \pocketmine\block\utils\StructureBlockTypegetOffset()
public function getOffset() : \pocketmine\math\Vector3getRedstoneSaveMode()
public function getRedstoneSaveMode() : intgetRotation()
public function getRotation() : \pocketmine\world\structure\StructureRotationgetSeed()
public function getSeed() : intgetSize()
public function getSize() : \pocketmine\math\Vector3getStructureName()
public function getStructureName() : stringisIgnoreEntities()
public function isIgnoreEntities() : boolisIncludePlayers()
public function isIncludePlayers() : boolisLoadingStructure()
public function isLoadingStructure() : boolWhether a structure is being loaded by this block (big or animated structures take several ticks).
isRemoveBlocks()
public function isRemoveBlocks() : boolisShowBoundingBox()
public function isShowBoundingBox() : boolisValidStructureName()
public static function isValidStructureName(string $name) : boolWhether the name can be used as a structure template name: not empty, printable, at most MAX_NAME_LENGTH long.
loadStructure()
public function loadStructure() : ?\pocketmine\lang\TranslatableLoads 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()
public function onRedstoneSignal(bool $powered) : voidCalled when the redstone signal reaching the block changes: when it turns on, saves (as the redstone save mode says) or loads.
readSaveData()
public function readSaveData(\pocketmine\nbt\tag\CompoundTag $nbt) : voidsaveStructure()
public function saveStructure(bool $toDisk) : ?\pocketmine\lang\TranslatableSaves 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()
public function setAnimationMode(int $mode) : voidsetAnimationSeconds()
public function setAnimationSeconds(float $seconds) : voidsetDataField()
public function setDataField(string $dataField) : voidsetIgnoreEntities()
public function setIgnoreEntities(bool $ignoreEntities) : voidsetIncludePlayers()
public function setIncludePlayers(bool $includePlayers) : voidsetIntegrity()
public function setIntegrity(float $integrity) : voidsetLastTouchedPlayerId()
public function setLastTouchedPlayerId(int $id) : voidsetMirror()
public function setMirror(\pocketmine\world\structure\StructureMirror $mirror) : voidsetMode()
public function setMode(\pocketmine\block\utils\StructureBlockType $mode) : voidSets the mode of the block entity only: use BlockStructureBlock::setMode() to change the block (which updates its block entity).
setOffset()
public function setOffset(int $x, int $y, int $z) : voidSets the offset of the structure from the block, clamped to the vanilla limits.
setRedstoneSaveMode()
public function setRedstoneSaveMode(int $mode) : voidsetRemoveBlocks()
public function setRemoveBlocks(bool $removeBlocks) : voidsetRotation()
public function setRotation(\pocketmine\world\structure\StructureRotation $rotation) : voidsetSeed()
public function setSeed(int $seed) : voidsetShowBoundingBox()
public function setShowBoundingBox(bool $showBoundingBox) : voidsetSize()
public function setSize(int $x, int $y, int $z) : voidSets the size of the structure, clamped to the vanilla limits (0 to 64x384x64).
setStructureName()
public function setStructureName(string $name) : voidtrigger()
public function trigger() : ?\pocketmine\lang\TranslatableSaves 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
protected function writeSaveData(\pocketmine\nbt\tag\CompoundTag $nbt) : void