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){
|
||||
|
|
|
|||
|
|
@ -488,8 +488,8 @@ class Level{
|
|||
|
||||
$this->level->setBlock($x, $y, $z, $id, $meta);
|
||||
|
||||
if($tiles && ($t = $this->server->api->tile->getXYZ($this, $x, $y, $z)) != false){ //TODO rewrite
|
||||
$t->close();
|
||||
if($tiles){ //TODO rewrite
|
||||
$this->server->api->tile->invalidateAll($this, $x, $y, $z);
|
||||
}
|
||||
if($updateBlocksAround){
|
||||
self::updateNeighborsAt($x, $y, $z, $oldID);
|
||||
|
|
@ -723,9 +723,7 @@ class Level{
|
|||
}
|
||||
|
||||
if($tiles === true){
|
||||
if(($t = $this->server->api->tile->get($pos)) !== false){
|
||||
$t->close();
|
||||
}
|
||||
$this->server->api->tile->invalidateAll($this, $pos->x, $pos->y, $pos->z);
|
||||
}
|
||||
|
||||
if($update === true){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue