mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
New method EntityAPI::getRadius()
This commit is contained in:
parent
a890cdc023
commit
75bb2a6399
2 changed files with 27 additions and 20 deletions
|
|
@ -46,6 +46,20 @@ class EntityAPI{
|
|||
|
||||
}
|
||||
|
||||
public function getRadius(Position $center, $radius = 15, $class = false){
|
||||
$entities = array();
|
||||
$l = $this->server->query("SELECT EID FROM entities WHERE level = '".$center->level->getName()."' ".($class !== false ? "AND class = $class ":"")."AND abs(x - {$center->x}) <= $radius AND abs(y - {$center->y}) <= $radius AND abs(z - {$center->z}) <= $radius;");
|
||||
if($l !== false and $l !== true){
|
||||
while(($e = $l->fetchArray(SQLITE3_ASSOC)) !== false){
|
||||
$e = $this->get($e["EID"]);
|
||||
if($e instanceof Entity){
|
||||
$entities[$e->eid] = $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $entities;
|
||||
}
|
||||
|
||||
public function getAll($level = null){
|
||||
if($level instanceof Level){
|
||||
$entities = array();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue