public function canUpdate() : bool
{
if ($this->getEntityId() === 0) {
return false;
}
$hasPlayer = false;
$count = 0;
foreach ($this->getLevel()->getEntities() as $e) {
if ($e instanceof Player) {
if ($e->distance($this->getBlock()) <= 15) {
$hasPlayer = true;
}
}
if ($e::NETWORK_ID == $this->getEntityId()) {
$count++;
}
}
if ($hasPlayer and $count < 15) {
// Spawn limit = 15
return true;
}
return false;
}