BlockEventPacket: added a ::create() method

This commit is contained in:
Dylan K. Taylor
2019-05-30 19:44:29 +01:00
parent 790c2cd4b7
commit 77ace57985
2 changed files with 13 additions and 7 deletions

View File

@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\handler\SessionHandler;
class BlockEventPacket extends DataPacket implements ClientboundPacket{
@ -42,6 +43,16 @@ class BlockEventPacket extends DataPacket implements ClientboundPacket{
/** @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->getBlockPosition($this->x, $this->y, $this->z);
$this->eventType = $this->getVarInt();