CommandBlock 5.47.0
Extends Spawnable
Block entity of command blocks (Bedrock ID "CommandBlock"; same fields and defaults as BDS 1.26.52, Version 52). It holds the command and its settings, runs the command as a CommandBlockSender and remembers whether the last run succeeded. When it runs is decided by the block (\pocketmine\block\CommandBlock).
Constants
MAX_COMMAND_LENGTH
public const MAX_COMMAND_LENGTH = 32767MAX_OUTPUT_LENGTH
public const MAX_OUTPUT_LENGTH = 1024TAG_AUTO
public const TAG_AUTO = "auto"TAG_COMMAND
public const TAG_COMMAND = "Command"TAG_CONDITIONAL_MODE
public const TAG_CONDITIONAL_MODE = "conditionalMode"TAG_CONDITION_MET
public const TAG_CONDITION_MET = "conditionMet"TAG_CUSTOM_NAME
public const TAG_CUSTOM_NAME = "CustomName"TAG_EXECUTE_ON_FIRST_TICK
public const TAG_EXECUTE_ON_FIRST_TICK = "ExecuteOnFirstTick"TAG_LAST_EXECUTION
public const TAG_LAST_EXECUTION = "LastExecution"TAG_LAST_OUTPUT
public const TAG_LAST_OUTPUT = "LastOutput"TAG_LAST_OUTPUT_PARAMS
public const TAG_LAST_OUTPUT_PARAMS = "LastOutputParams"TAG_LP_COMMAND_MODE
public const TAG_LP_COMMAND_MODE = "LPCommandMode"TAG_LP_CONDITIONAL_MODE
public const TAG_LP_CONDITIONAL_MODE = "LPCondionalMode"TAG_LP_REDSTONE_MODE
public const TAG_LP_REDSTONE_MODE = "LPRedstoneMode"TAG_POWERED
public const TAG_POWERED = "powered"TAG_SUCCESS_COUNT
public const TAG_SUCCESS_COUNT = "SuccessCount"TAG_TICK_DELAY
public const TAG_TICK_DELAY = "TickDelay"TAG_TRACK_OUTPUT
public const TAG_TRACK_OUTPUT = "TrackOutput"TAG_VERSION
public const TAG_VERSION = "Version"VERSION
public const VERSION = 52Command block data version written by BDS 1.26.52
Methods
addAdditionalSpawnData() protected
protected function addAdditionalSpawnData(\pocketmine\nbt\tag\CompoundTag $nbt) : voidgetCommand()
public function getCommand() : stringgetCommandSender()
public function getCommandSender() : \pocketmine\block\tile\CommandBlockSenderReturns the sender the command runs as.
getCustomName()
public function getCustomName() : stringName of the command block, used as the name of its command sender ("" = "!").
getLastExecution()
public function getLastExecution() : intWorld tick of the last run.
getLastOutput()
public function getLastOutput() : stringgetSuccessCount()
public function getSuccessCount() : intReturns 1 if the last run succeeded, 0 otherwise (conditional command blocks check it on the block behind them).
getTickDelay()
public function getTickDelay() : intTicks to wait before running (impulse, chain) or between two runs (repeating).
isActive()
public function isActive() : boolWhether the block may run: always active or powered.
isAuto()
public function isAuto() : boolWhether the block is "Always Active" (otherwise it needs redstone). New chain command blocks are.
isConditionMet()
public function isConditionMet() : boolWhether the condition of a conditional command block was met the last time it was checked.
isExecuteOnFirstTick()
public function isExecuteOnFirstTick() : boolWhether a repeating command block runs as soon as it becomes active, instead of waiting for its delay first. New repeating command blocks do.
isPowered()
public function isPowered() : boolWhether the block received redstone power at the last neighbour update.
isTrackingOutput()
public function isTrackingOutput() : boolreadSaveData()
public function readSaveData(\pocketmine\nbt\tag\CompoundTag $nbt) : voidrunCommand()
public function runCommand() : boolRuns the command now, unless command blocks are disabled by the commandblocksenabled game rule. Returns whether it ran successfully.
setAuto()
public function setAuto(bool $auto) : voidsetCommand()
public function setCommand(string $command) : voidSets the command (with or without the leading slash). Longer commands are cut to self::MAX_COMMAND_LENGTH.
setConditionMet()
public function setConditionMet(bool $conditionMet) : voidsetCustomName()
public function setCustomName(string $name) : voidsetExecuteOnFirstTick()
public function setExecuteOnFirstTick(bool $executeOnFirstTick) : voidsetLastOutput()
public function setLastOutput(string $output) : voidsetPowered()
public function setPowered(bool $powered) : voidsetSuccessCount()
public function setSuccessCount(int $successCount) : voidsetTickDelay()
public function setTickDelay(int $tickDelay) : voidsetTrackOutput()
public function setTrackOutput(bool $trackOutput) : voidwriteSaveData() protected
protected function writeSaveData(\pocketmine\nbt\tag\CompoundTag $nbt) : void