Merge commit '71f2a34616961d6328f06fd911b6d4450a61643e'

This commit is contained in:
Dylan K. Taylor 2021-11-01 17:33:02 +00:00
commit a78248a19c
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -1436,14 +1436,11 @@ abstract class Entity{
}
public function spawnTo(Player $player) : void{
if($player->getWorld() !== $this->getWorld()){
throw new \InvalidArgumentException("Player is not in the same world");
}
$id = spl_object_id($player);
//TODO: this will cause some visible lag during chunk resends; if the player uses a spawn egg in a chunk, the
//created entity won't be visible until after the resend arrives. However, this is better than possibly crashing
//the player by sending them entities too early.
if(!isset($this->hasSpawned[$id]) and $player->hasReceivedChunk($this->location->getFloorX() >> Chunk::COORD_BIT_SIZE, $this->location->getFloorZ() >> Chunk::COORD_BIT_SIZE)){
if(!isset($this->hasSpawned[$id]) and $player->getWorld() === $this->getWorld() and $player->hasReceivedChunk($this->location->getFloorX() >> Chunk::COORD_BIT_SIZE, $this->location->getFloorZ() >> Chunk::COORD_BIT_SIZE)){
$this->hasSpawned[$id] = $player;
$this->sendSpawnPacket($player);