mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
Fixed #313 Entities are updated depending on near block updates [gh#313]
This commit is contained in:
parent
4b6e456c65
commit
d1f2f82c6d
4 changed files with 19 additions and 2 deletions
|
|
@ -43,7 +43,23 @@ class EntityAPI{
|
|||
}
|
||||
|
||||
public function init(){
|
||||
$this->server->schedule(25, array($this, "updateEntities"), array(), true);
|
||||
}
|
||||
|
||||
public function updateEntities(){
|
||||
$l = $this->server->query("SELECT EID FROM entities WHERE hasUpdate = 1;");
|
||||
if($l !== false and $l !== true){
|
||||
while(($e = $l->fetchArray(SQLITE3_ASSOC)) !== false){
|
||||
$e = $this->get($e["EID"]);
|
||||
if($e instanceof Entity){
|
||||
$e->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateRadius(Position $center, $radius = 15, $class = false){
|
||||
$this->server->query("UPDATE entities SET hasUpdate = 1 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;");
|
||||
}
|
||||
|
||||
public function getRadius(Position $center, $radius = 15, $class = false){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue