Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'pmmp/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
haniokasai committed Dec 14, 2018
2 parents 8a0c5e7 + e0558d2 commit d9b9732
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/pocketmine/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public static function isValidUserName(?string $name) : bool{
/** @var int */
protected $spawnThreshold;
/** @var int */
protected $chunkLoadCount = 0;
protected $spawnChunkLoadCount = 0;
/** @var int */
protected $chunksPerTick;

Expand Down Expand Up @@ -904,7 +904,6 @@ public function sendChunk(int $x, int $z, CompressBatchPromise $promise){
}

$this->usedChunks[Level::chunkHash($x, $z)] = true;
$this->chunkLoadCount++;

$this->networkSession->queueCompressed($promise);

Expand All @@ -914,7 +913,8 @@ public function sendChunk(int $x, int $z, CompressBatchPromise $promise){
$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){
Expand Down
3 changes: 3 additions & 0 deletions src/pocketmine/entity/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ public function getScale() : float{
* @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;
Expand Down
26 changes: 14 additions & 12 deletions src/pocketmine/level/Level.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,14 @@ public function addSound(Sound $sound, array $players = null){
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);
}
}

Expand All @@ -470,13 +471,14 @@ public function addParticle(Particle $particle, array $players = null){
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);
}
}

Expand Down

0 comments on commit d9b9732

Please sign in to comment.