Entity: make use of MoveActorAbsolutePacket::create()

This commit is contained in:
Dylan K. Taylor 2020-10-06 18:35:02 +01:00
parent d8ee657d20
commit cbc6ebebad

View File

@ -735,25 +735,21 @@ abstract class Entity{
} }
protected function broadcastMovement(bool $teleport = false) : void{ protected function broadcastMovement(bool $teleport = false) : void{
$pk = new MoveActorAbsolutePacket(); $this->server->broadcastPackets($this->hasSpawned, [MoveActorAbsolutePacket::create(
$pk->entityRuntimeId = $this->id; $this->id,
$pk->position = $this->getOffsetPosition($this->location); $this->getOffsetPosition($this->location),
//this looks very odd but is correct as of 1.5.0.7 //this looks very odd but is correct as of 1.5.0.7
//for arrows this is actually x/y/z rotation //for arrows this is actually x/y/z rotation
//for mobs x and z are used for pitch and yaw, and y is used for headyaw //for mobs x and z are used for pitch and yaw, and y is used for headyaw
$pk->xRot = $this->location->pitch; $this->location->pitch,
$pk->yRot = $this->location->yaw; //TODO: head yaw $this->location->yaw,
$pk->zRot = $this->location->yaw; $this->location->yaw,
(
if($teleport){ ($teleport ? MoveActorAbsolutePacket::FLAG_TELEPORT : 0) |
$pk->flags |= MoveActorAbsolutePacket::FLAG_TELEPORT; ($this->onGround ? MoveActorAbsolutePacket::FLAG_GROUND : 0)
} )
if($this->onGround){ )]);
$pk->flags |= MoveActorAbsolutePacket::FLAG_GROUND;
}
$this->server->broadcastPackets($this->hasSpawned, [$pk]);
} }
protected function broadcastMotion() : void{ protected function broadcastMotion() : void{