mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
invalidated all tile entities on block change
This commit is contained in:
parent
c5bdb933ed
commit
bbf506c887
2 changed files with 26 additions and 6 deletions
|
|
@ -11,12 +11,34 @@ class TileAPI{
|
|||
$this->server = ServerAPI::request();
|
||||
}
|
||||
public function getXYZ(Level $level, $x, $y, $z){
|
||||
$tile = $this->server->query("SELECT * FROM tiles WHERE level = '{$level->getName()}' AND x = $z AND y = $y AND z = $z;", true);
|
||||
$tile = $this->server->query("SELECT * FROM tiles WHERE level = '{$level->getName()}' AND x = $x AND y = $y AND z = $z;", true);
|
||||
if($tile !== false and $tile !== true and ($tile = $this->getByID($tile["ID"])) !== false){
|
||||
return $tile;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function invalidateAll(Level $level, $x, $y, $z){
|
||||
$x = (int) $x;
|
||||
$y = (int) $y;
|
||||
$z = (int) $z;
|
||||
$tile = $this->server->query("SELECT id FROM tiles WHERE level = '{$level->getName()}' AND x = $x AND y = $y AND z = $z;", false);
|
||||
$invcnt = 0;
|
||||
if($tile instanceof SQLite3Result){
|
||||
while(($t = $tile->fetchArray(SQLITE3_ASSOC)) !== false){
|
||||
$tl = $this->getByID($t["ID"]);
|
||||
if($tl instanceof Tile){
|
||||
++$invcnt;
|
||||
$tl->close();
|
||||
}
|
||||
|
||||
if($invcnt > 1){
|
||||
ConsoleAPI::warn("{$level->getName()}: ($x $y $z) has more than 1 tile entity! Invalidated ID {$t["ID"]} (Total invaliated: $invcnt)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get(Position $pos){
|
||||
$tile = $this->server->query("SELECT * FROM tiles WHERE level = '" . $pos->level->getName() . "' AND x = {$pos->x} AND y = {$pos->y} AND z = {$pos->z};", true);
|
||||
if($tile !== false and $tile !== true and ($tile = $this->getByID($tile["ID"])) !== false){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue