diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 93845b9b1..56b8d4972 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -230,7 +230,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** @var int */ protected $spawnThreshold; /** @var int */ - protected $chunkLoadCount = 0; + protected $spawnChunkLoadCount = 0; /** @var int */ protected $chunksPerTick; @@ -904,7 +904,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } $this->usedChunks[Level::chunkHash($x, $z)] = true; - $this->chunkLoadCount++; $this->networkSession->queueCompressed($promise); @@ -914,7 +913,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $entity->spawnTo($this); } } - }elseif($this->chunkLoadCount >= $this->spawnThreshold){ + }elseif(++$this->spawnChunkLoadCount >= $this->spawnThreshold){ + $this->spawnChunkLoadCount = -1; $this->spawned = true; foreach($this->usedChunks as $index => $c){ diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index f5239bf36..db87ad6c9 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -629,6 +629,9 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * @param float $value */ public function setScale(float $value) : void{ + if($value <= 0){ + throw new \InvalidArgumentException("Scale must be greater than 0"); + } $multiplier = $value / $this->getScale(); $this->width *= $multiplier; diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 5d42f9c8b..0d6f05f45 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -455,13 +455,14 @@ class Level implements ChunkManager, Metadatable{ if(!is_array($pk)){ $pk = [$pk]; } - - if($players === null){ - foreach($pk as $e){ - $this->broadcastPacketToViewers($sound, $e); + if(!empty($pk)){ + if($players === null){ + foreach($pk as $e){ + $this->broadcastPacketToViewers($sound, $e); + } + }else{ + $this->server->broadcastPackets($players, $pk); } - }else{ - $this->server->broadcastPackets($players, $pk); } } @@ -470,13 +471,14 @@ class Level implements ChunkManager, Metadatable{ if(!is_array($pk)){ $pk = [$pk]; } - - if($players === null){ - foreach($pk as $e){ - $this->broadcastPacketToViewers($particle, $e); + if(!empty($pk)){ + if($players === null){ + foreach($pk as $e){ + $this->broadcastPacketToViewers($particle, $e); + } + }else{ + $this->server->broadcastPackets($players, $pk); } - }else{ - $this->server->broadcastPackets($players, $pk); } }