Added PhpDoc for packet field types and changed float x,y,z to Vector3

This commit is contained in:
Dylan K. Taylor
2017-08-13 20:02:07 +01:00
parent 6480f7a989
commit 9be1b929a5
99 changed files with 424 additions and 207 deletions

View File

@ -54,8 +54,10 @@ use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\network\mcpe\protocol\MoveEntityPacket;
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
use pocketmine\network\mcpe\protocol\SetEntityDataPacket;
use pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
use pocketmine\Player;
use pocketmine\plugin\Plugin;
use pocketmine\Server;
@ -1146,7 +1148,7 @@ abstract class Entity extends Location implements Metadatable{
$this->lastYaw = $this->yaw;
$this->lastPitch = $this->pitch;
$this->level->addEntityMovement($this->chunk->getX(), $this->chunk->getZ(), $this->id, $this->x, $this->y + $this->baseOffset, $this->z, $this->yaw, $this->pitch, $this->yaw);
$this->broadcastMovement();
}
if($diffMotion > 0.0025 or ($diffMotion > 0.0001 and $this->getMotion()->lengthSquared() <= 0.0001)){ //0.05 ** 2
@ -1154,10 +1156,33 @@ abstract class Entity extends Location implements Metadatable{
$this->lastMotionY = $this->motionY;
$this->lastMotionZ = $this->motionZ;
$this->level->addEntityMotion($this->chunk->getX(), $this->chunk->getZ(), $this->id, $this->motionX, $this->motionY, $this->motionZ);
$this->broadcastMotion();
}
}
public function getOffsetPosition() : Vector3{
return new Vector3($this->x, $this->y + $this->baseOffset, $this->z);
}
protected function broadcastMovement(){
$pk = new MoveEntityPacket();
$pk->entityRuntimeId = $this->id;
$pk->position = $this->getOffsetPosition();
$pk->yaw = $this->yaw;
$pk->pitch = $this->pitch;
$pk->headYaw = $this->yaw; //TODO
$this->level->addChunkPacket($this->chunk->getX(), $this->chunk->getZ(), $pk);
}
protected function broadcastMotion(){
$pk = new SetEntityMotionPacket();
$pk->entityRuntimeId = $this->id;
$pk->motion = $this->getMotion();
$this->level->addChunkPacket($this->chunk->getX(), $this->chunk->getZ(), $pk);
}
/**
* @return Vector3
*/