mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Replace empty() usages with count()
This commit is contained in:
@ -503,7 +503,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
if(!is_array($pk)){
|
||||
$pk = [$pk];
|
||||
}
|
||||
if(!empty($pk)){
|
||||
if(count($pk) > 0){
|
||||
if($players === null){
|
||||
foreach($pk as $e){
|
||||
$this->broadcastPacketToViewers($sound, $e);
|
||||
@ -519,7 +519,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
if(!is_array($pk)){
|
||||
$pk = [$pk];
|
||||
}
|
||||
if(!empty($pk)){
|
||||
if(count($pk) > 0){
|
||||
if($players === null){
|
||||
foreach($pk as $e){
|
||||
$this->broadcastPacketToViewers($particle, $e);
|
||||
@ -881,7 +881,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
if(count($this->changedBlocks) > 0){
|
||||
if(count($this->players) > 0){
|
||||
foreach($this->changedBlocks as $index => $blocks){
|
||||
if(empty($blocks)){ //blocks can be set normally and then later re-set with direct send
|
||||
if(count($blocks) === 0){ //blocks can be set normally and then later re-set with direct send
|
||||
continue;
|
||||
}
|
||||
unset($this->chunkCache[$index]);
|
||||
@ -909,8 +909,8 @@ class Level implements ChunkManager, Metadatable{
|
||||
$this->checkSleep();
|
||||
}
|
||||
|
||||
if(!empty($this->globalPackets)){
|
||||
if(!empty($this->players)){
|
||||
if(count($this->globalPackets) > 0){
|
||||
if(count($this->players) > 0){
|
||||
$this->server->batchPackets($this->players, $this->globalPackets);
|
||||
}
|
||||
$this->globalPackets = [];
|
||||
@ -1845,7 +1845,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
$item->onDestroyBlock($target);
|
||||
|
||||
if(!empty($drops)){
|
||||
if(count($drops) > 0){
|
||||
$dropPos = $target->add(0.5, 0.5, 0.5);
|
||||
foreach($drops as $drop){
|
||||
if(!$drop->isNull()){
|
||||
@ -1949,7 +1949,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
if($hand->isSolid()){
|
||||
foreach($hand->getCollisionBoxes() as $collisionBox){
|
||||
if(!empty($this->getCollidingEntities($collisionBox))){
|
||||
if(count($this->getCollidingEntities($collisionBox)) > 0){
|
||||
return false; //Entity in block
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
use function array_values;
|
||||
use function chr;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function explode;
|
||||
use function extension_loaded;
|
||||
@ -519,7 +520,7 @@ class LevelDB extends BaseLevelProvider{
|
||||
* @param string $index
|
||||
*/
|
||||
private function writeTags(array $targets, string $index){
|
||||
if(!empty($targets)){
|
||||
if(count($targets) > 0){
|
||||
$nbt = new LittleEndianNBTStream();
|
||||
$this->db->put($index, $nbt->write($targets));
|
||||
}else{
|
||||
|
Reference in New Issue
Block a user