Skip to content

CommandBlock 5.47.0 ​

class · pocketmine\block\tile\CommandBlock · source

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 ​

php
public const MAX_COMMAND_LENGTH = 32767

MAX_OUTPUT_LENGTH ​

php
public const MAX_OUTPUT_LENGTH = 1024

TAG_AUTO ​

php
public const TAG_AUTO = "auto"

TAG_COMMAND ​

php
public const TAG_COMMAND = "Command"

TAG_CONDITIONAL_MODE ​

php
public const TAG_CONDITIONAL_MODE = "conditionalMode"

TAG_CONDITION_MET ​

php
public const TAG_CONDITION_MET = "conditionMet"

TAG_CUSTOM_NAME ​

php
public const TAG_CUSTOM_NAME = "CustomName"

TAG_EXECUTE_ON_FIRST_TICK ​

php
public const TAG_EXECUTE_ON_FIRST_TICK = "ExecuteOnFirstTick"

TAG_LAST_EXECUTION ​

php
public const TAG_LAST_EXECUTION = "LastExecution"

TAG_LAST_OUTPUT ​

php
public const TAG_LAST_OUTPUT = "LastOutput"

TAG_LAST_OUTPUT_PARAMS ​

php
public const TAG_LAST_OUTPUT_PARAMS = "LastOutputParams"

TAG_LP_COMMAND_MODE ​

php
public const TAG_LP_COMMAND_MODE = "LPCommandMode"

TAG_LP_CONDITIONAL_MODE ​

php
public const TAG_LP_CONDITIONAL_MODE = "LPCondionalMode"

TAG_LP_REDSTONE_MODE ​

php
public const TAG_LP_REDSTONE_MODE = "LPRedstoneMode"

TAG_POWERED ​

php
public const TAG_POWERED = "powered"

TAG_SUCCESS_COUNT ​

php
public const TAG_SUCCESS_COUNT = "SuccessCount"

TAG_TICK_DELAY ​

php
public const TAG_TICK_DELAY = "TickDelay"

TAG_TRACK_OUTPUT ​

php
public const TAG_TRACK_OUTPUT = "TrackOutput"

TAG_VERSION ​

php
public const TAG_VERSION = "Version"

VERSION ​

php
public const VERSION = 52

Command block data version written by BDS 1.26.52

Methods ​

addAdditionalSpawnData() protected ​

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

getCommand() ​

php
public function getCommand() : string

getCommandSender() ​

php
public function getCommandSender() : \pocketmine\block\tile\CommandBlockSender

Returns the sender the command runs as.

getCustomName() ​

php
public function getCustomName() : string

Name of the command block, used as the name of its command sender ("" = "!").

getLastExecution() ​

php
public function getLastExecution() : int

World tick of the last run.

getLastOutput() ​

php
public function getLastOutput() : string

getSuccessCount() ​

php
public function getSuccessCount() : int

Returns 1 if the last run succeeded, 0 otherwise (conditional command blocks check it on the block behind them).

getTickDelay() ​

php
public function getTickDelay() : int

Ticks to wait before running (impulse, chain) or between two runs (repeating).

isActive() ​

php
public function isActive() : bool

Whether the block may run: always active or powered.

isAuto() ​

php
public function isAuto() : bool

Whether the block is "Always Active" (otherwise it needs redstone). New chain command blocks are.

isConditionMet() ​

php
public function isConditionMet() : bool

Whether the condition of a conditional command block was met the last time it was checked.

isExecuteOnFirstTick() ​

php
public function isExecuteOnFirstTick() : bool

Whether a repeating command block runs as soon as it becomes active, instead of waiting for its delay first. New repeating command blocks do.

isPowered() ​

php
public function isPowered() : bool

Whether the block received redstone power at the last neighbour update.

isTrackingOutput() ​

php
public function isTrackingOutput() : bool

readSaveData() ​

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

runCommand() ​

php
public function runCommand() : bool

Runs the command now, unless command blocks are disabled by the commandblocksenabled game rule. Returns whether it ran successfully.

setAuto() ​

php
public function setAuto(bool $auto) : void

setCommand() ​

php
public function setCommand(string $command) : void

Sets the command (with or without the leading slash). Longer commands are cut to self::MAX_COMMAND_LENGTH.

setConditionMet() ​

php
public function setConditionMet(bool $conditionMet) : void

setCustomName() ​

php
public function setCustomName(string $name) : void

setExecuteOnFirstTick() ​

php
public function setExecuteOnFirstTick(bool $executeOnFirstTick) : void

setLastOutput() ​

php
public function setLastOutput(string $output) : void

setPowered() ​

php
public function setPowered(bool $powered) : void

setSuccessCount() ​

php
public function setSuccessCount(int $successCount) : void

setTickDelay() ​

php
public function setTickDelay(int $tickDelay) : void

setTrackOutput() ​

php
public function setTrackOutput(bool $trackOutput) : void

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.