use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; class CommandBlockUpdatePacket extends DataPacket implements ServerboundPacket{ public const NETWORK_ID = ProtocolInfo::COMMAND_BLOCK_UPDATE_PACKET; /** @var bool */ public $isBlock; /** @var int */ public $x; /** @var int */ public $y; /** @var int */ public $z; /** @var int */ public $commandBlockMode; /** @var bool */ public $isRedstoneMode; /** @var bool */ public $isConditional; /** @var int */ public $minecartEid; /** @var string */ public $command; /** @var string */ public $lastOutput; /** @var string */ public $name; /** @var bool */ public $shouldTrackOutput; /** @var int */ public $tickDelay; /** @var bool */ public $executeOnFirstTick; protected function decodePayload(PacketSerializer $in) : void{ $this->isBlock = $in->getBool(); if($this->isBlock){ $in->getBlockPosition($this->x, $this->y, $this->z); $this->commandBlockMode = $in->getUnsignedVarInt(); $this->isRedstoneMode = $in->getBool(); $this->isConditional = $in->getBool(); }else{ //Minecart with command block $this->minecartEid = $in->getEntityRuntimeId(); } $this->command = $in->getString(); $this->lastOutput = $in->getString(); $this->name = $in->getString(); $this->shouldTrackOutput = $in->getBool(); $this->tickDelay = $in->getLInt(); $this->executeOnFirstTick = $in->getBool(); } protected function encodePayload(PacketSerializer $out) : void{ $out->putBool($this->isBlock); if($this->isBlock){ $out->putBlockPosition($this->x, $this->y, $this->z); $out->putUnsignedVarInt($this->commandBlockMode); $out->putBool($this->isRedstoneMode); $out->putBool($this->isConditional); }else{ $out->putEntityRuntimeId($this->minecartEid); } $out->putString($this->command); $out->putString($this->lastOutput); $out->putString($this->name); $out->putBool($this->shouldTrackOutput); $out->putLInt($this->tickDelay); $out->putBool($this->executeOnFirstTick); } public function handle(PacketHandlerInterface $handler) : bool{ return $handler->handleCommandBlockUpdate($this); } }