Spawn unleashed, movement fixed and some Player DataProperty cleanup

This commit is contained in:
Intyre
2016-06-22 00:08:52 +02:00
parent ef8227a074
commit df8e1e8702
6 changed files with 46 additions and 36 deletions

View File

@ -27,32 +27,33 @@ namespace pocketmine\network\protocol;
class MoveEntityPacket extends DataPacket{
const NETWORK_ID = Info::MOVE_ENTITY_PACKET;
// eid, x, y, z, yaw, pitch
/** @var array[] */
public $entities = [];
public function clean(){
$this->entities = [];
return parent::clean();
}
public $eid;
public $x;
public $y;
public $z;
public $yaw;
public $headYaw;
public $pitch;
public function decode(){
$this->eid = $this->getLong();
$this->x = $this->getFloat();
$this->y = $this->getFloat();
$this->z = $this->getFloat();
$this->pitch = $this->getByte()*(360.0/256);
$this->yaw = $this->getByte()*(360.0/256);
$this->headYaw = $this->getByte()*(360.0/256);
}
public function encode(){
$this->reset();
$this->putInt(count($this->entities));
foreach($this->entities as $d){
$this->putLong($d[0]); //eid
$this->putFloat($d[1]); //x
$this->putFloat($d[2]); //y
$this->putFloat($d[3]); //z
$this->putFloat($d[4]); //yaw
$this->putFloat($d[5]); //headYaw
$this->putFloat($d[6]); //pitch
}
$this->putLong($this->eid);
$this->putFloat($this->x);
$this->putFloat($this->y);
$this->putFloat($this->z);
$this->putByte($this->pitch/(360.0/256));
$this->putByte($this->yaw/(360.0/256));
$this->putByte($this->headYaw/(360.0/256));
}
}