Skip to content

Commit

Permalink
remove entity not found exception from getEntities()
Browse files Browse the repository at this point in the history
  • Loading branch information
rico132 committed Jul 21, 2022
1 parent cdaafd1 commit c440b87
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Chunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ public function readEntitiesTag(): ?ListTag
* @param string $name
* @param McCoordinatesFloat $coordinates
* @return Entity[]
* @throws Exception
*/
public function getEntities(string $name, McCoordinatesFloat $coordinates): array
{
Expand All @@ -233,7 +232,6 @@ public function getEntities(string $name, McCoordinatesFloat $coordinates): arra
$entities = [];
$found = false;
$results = [];
$exception = new Exception("Entity not found.");

// Filters entities by name for the while loop
foreach ($this->entities as $entity) {
Expand All @@ -250,7 +248,7 @@ public function getEntities(string $name, McCoordinatesFloat $coordinates): arra
return $results;
}
if (count($entities) === 0) {
throw $exception;
return [];
}
// Increases delta up to 13 times
while ($counter < 13) {
Expand All @@ -267,7 +265,7 @@ public function getEntities(string $name, McCoordinatesFloat $coordinates): arra
$delta = $delta * 10;
$counter++;
}
throw $exception;
return [];
}

/**
Expand Down

0 comments on commit c440b87

Please sign in to comment.