use pocketmine\math\Vector3; use pocketmine\network\mcpe\handler\PacketHandler; class BlockEventPacket extends DataPacket implements ClientboundPacket{ public const NETWORK_ID = ProtocolInfo::BLOCK_EVENT_PACKET; /** @var int */ public $x; /** @var int */ public $y; /** @var int */ public $z; /** @var int */ public $eventType; /** @var int */ public $eventData; public static function create(int $eventId, int $eventData, Vector3 $pos) : self{ $pk = new self; $pk->eventType = $eventId; $pk->eventData = $eventData; $pk->x = $pos->getFloorX(); $pk->y = $pos->getFloorY(); $pk->z = $pos->getFloorZ(); return $pk; } protected function decodePayload() : void{ $this->buf->getBlockPosition($this->x, $this->y, $this->z); $this->eventType = $this->buf->getVarInt(); $this->eventData = $this->buf->getVarInt(); } protected function encodePayload() : void{ $this->buf->putBlockPosition($this->x, $this->y, $this->z); $this->buf->putVarInt($this->eventType); $this->buf->putVarInt($this->eventData); } public function handle(PacketHandler $handler) : bool{ return $handler->handleBlockEvent($this); } }