Merge branch 'stable' into next-minor

This commit is contained in:
Dylan K. Taylor
2022-04-10 21:23:04 +01:00
11 changed files with 128 additions and 160 deletions

View File

@ -768,17 +768,29 @@ abstract class Entity{
}
protected function broadcastMovement(bool $teleport = false) : void{
$this->server->broadcastPackets($this->hasSpawned, [MoveActorAbsolutePacket::create(
$this->id,
$this->getOffsetPosition($this->location),
$this->location->pitch,
$this->location->yaw,
$this->location->yaw,
(
($teleport ? MoveActorAbsolutePacket::FLAG_TELEPORT : 0) |
($this->onGround ? MoveActorAbsolutePacket::FLAG_GROUND : 0)
)
)]);
if($teleport){
//TODO: HACK! workaround for https://github.com/pmmp/PocketMine-MP/issues/4394
//this happens because MoveActor*Packet doesn't clear interpolation targets on the client, so the entity
//snaps to the teleport position, but then lerps back to the original position if a normal movement for the
//entity was recently broadcasted. This can be seen with players throwing ender pearls.
//TODO: remove this if the bug ever gets fixed (lol)
foreach($this->hasSpawned as $player){
$this->despawnFrom($player);
$this->spawnTo($player);
}
}else{
$this->server->broadcastPackets($this->hasSpawned, [MoveActorAbsolutePacket::create(
$this->id,
$this->getOffsetPosition($this->location),
$this->location->pitch,
$this->location->yaw,
$this->location->yaw,
(
//TODO: if the above hack for #4394 gets removed, we should be setting FLAG_TELEPORT here
($this->onGround ? MoveActorAbsolutePacket::FLAG_GROUND : 0)
)
)]);
}
}
protected function broadcastMotion() : void{