LevelEventPacket: added create() to reduce boilerplate code

This commit is contained in:
Dylan K. Taylor
2019-03-26 16:38:35 +00:00
parent 7333e7118e
commit 1bf0802275
7 changed files with 16 additions and 35 deletions

View File

@ -119,6 +119,14 @@ class LevelEventPacket extends DataPacket implements ClientboundPacket{
/** @var int */
public $data;
public static function create(int $evid, int $data, ?Vector3 $pos) : self{
$pk = new self;
$pk->evid = $evid;
$pk->data = $data;
$pk->position = $pos !== null ? $pos->asVector3() : null;
return $pk;
}
protected function decodePayload() : void{
$this->evid = $this->getVarInt();
$this->position = $this->getVector3();