Skip to content

CommandBlock 5.47.0 ​

class · pocketmine\block\CommandBlock · source

Extends Opaque
Implements AnyFacing

Impulse, repeating and chain command blocks (https://minecraft.wiki/w/Command_Block). The command and the settings live in the block entity (TileCommandBlock); the block state holds the facing and the conditional flag.

  • Impulse: runs once, TickDelay ticks after a redstone signal turns on (or after "Always Active" is turned on).
  • Repeating: runs every TickDelay ticks (at least 1) while powered or always active; with ExecuteOnFirstTick it runs at once when it becomes active.
  • Chain: runs right after the command block pointing into it ran (after its own TickDelay if it has one), when it is powered or always active. The chain stops after maxcommandchainlength chain blocks.

A conditional command block only runs if the command block behind it (opposite to its facing) succeeded on its last run. Nothing runs when the commandblocksenabled game rule is off. Only operators in creative mode can place command blocks or open their screen; they never drop.

Constants ​

MAX_RUNS_PER_TICK ​

php
public const MAX_RUNS_PER_TICK = 4096

Most command block runs (impulse, repeating and chain) per world and tick: the others wait for the next tick, so that a contraption of repeating command blocks can't stall the server.

Properties ​

$conditional protected ​

php
protected bool $conditional

Methods ​

__construct() ​

php
public function __construct(\pocketmine\block\BlockIdentifier $idInfo, string $name, \pocketmine\block\BlockTypeInfo $typeInfo, \pocketmine\block\utils\CommandBlockType $commandBlockType)

describeBlockOnlyState() protected ​

php
protected function describeBlockOnlyState(\pocketmine\data\runtime\RuntimeDataDescriber $w) : void

getCommandBlockType() ​

php
public function getCommandBlockType() : \pocketmine\block\utils\CommandBlockType

getDropsForCompatibleTool() ​

php
public function getDropsForCompatibleTool(\pocketmine\item\Item $item) : array

isAffectedBySilkTouch() ​

php
public function isAffectedBySilkTouch() : bool

isConditional() ​

php
public function isConditional() : bool

Whether it only runs when the command block behind it succeeded (Bedrock "conditional_bit").

onInteract() ​

php
public function onInteract(\pocketmine\item\Item $item, int $face, \pocketmine\math\Vector3 $clickVector, ?\pocketmine\player\Player $player = null, array &$returnedItems = []) : bool

onNearbyBlockChange() ​

php
public function onNearbyBlockChange() : void

onScheduledUpdate() ​

php
public function onScheduledUpdate() : void

pausesScheduledUpdatesOutsideTickingChunks() ​

php
public function pausesScheduledUpdatesOutsideTickingChunks() : bool

place() ​

php
public function place(\pocketmine\world\BlockTransaction $tx, \pocketmine\item\Item $item, \pocketmine\block\Block $blockReplace, \pocketmine\block\Block $blockClicked, int $face, \pocketmine\math\Vector3 $clickVector, ?\pocketmine\player\Player $player = null) : bool

setConditional() ​

php
public function setConditional(bool $conditional) : self

writeStateToWorld() ​

php
public function writeStateToWorld() : void

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