mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-09 11:31:49 +00:00
Optimized block updates
This commit is contained in:
parent
2790f60491
commit
758070e478
@ -653,25 +653,6 @@ class BlockAPI{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
case 74:
|
|
||||||
if($type === BLOCK_UPDATE_SCHEDULED or $type === BLOCK_UPDATE_RANDOM){
|
|
||||||
$changed = true;
|
|
||||||
$this->server->api->level->setBlock($x, $y, $z, 73, $block[1], false);
|
|
||||||
$type = BLOCK_UPDATE_WEAK;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 73:
|
|
||||||
if($type === BLOCK_UPDATE_NORMAL){
|
|
||||||
$changed = true;
|
|
||||||
$this->server->api->level->setBlock($x, $y, $z, 74, $block[1], false);
|
|
||||||
$this->server->schedule(mt_rand(40, 100), array($this, "blockScheduler"), array(
|
|
||||||
"x" => $x,
|
|
||||||
"y" => $y,
|
|
||||||
"z" => $z,
|
|
||||||
));
|
|
||||||
$type = BLOCK_UPDATE_WEAK;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if($type === BLOCK_TYPE_SCHEDULED){
|
if($type === BLOCK_TYPE_SCHEDULED){
|
||||||
@ -698,7 +679,11 @@ class BlockAPI{
|
|||||||
}else{
|
}else{
|
||||||
$block = $pos;
|
$block = $pos;
|
||||||
}
|
}
|
||||||
return $block->onUpdate($this, $type);
|
$level = $block->onUpdate($this, $type);
|
||||||
|
if($level === BLOCK_UPDATE_NORMAL){
|
||||||
|
$this->blockUpdateAround($block, $level);
|
||||||
|
}
|
||||||
|
return $level;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scheduleBlockUpdate(Vector3 $pos, $delay, $type = BLOCK_UPDATE_SCHEDULED){
|
public function scheduleBlockUpdate(Vector3 $pos, $delay, $type = BLOCK_UPDATE_SCHEDULED){
|
||||||
@ -715,9 +700,10 @@ class BlockAPI{
|
|||||||
$type,
|
$type,
|
||||||
$delay,
|
$delay,
|
||||||
);
|
);
|
||||||
$this->server->query("INSERT INTO blockUpdates (x, y, z, type, delay) VALUES (".$pos->x.", ".$pos->y.", ".$pos->z.", ".$type.", ".$delay.");");
|
$this->server->query("INSERT INTO blockUpdates (x, y, z, delay) VALUES (".$pos->x.", ".$pos->y.", ".$pos->z.", ".$delay.");");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function blockUpdateRemote($data, $event){
|
public function blockUpdateRemote($data, $event){
|
||||||
|
@ -121,7 +121,7 @@ class PocketMinecraftServer{
|
|||||||
$this->query("CREATE TABLE tileentities (ID INTEGER PRIMARY KEY, class TEXT, x NUMERIC, y NUMERIC, z NUMERIC, spawnable NUMERIC);");
|
$this->query("CREATE TABLE tileentities (ID INTEGER PRIMARY KEY, class TEXT, x NUMERIC, y NUMERIC, z NUMERIC, spawnable NUMERIC);");
|
||||||
$this->query("CREATE TABLE actions (ID INTEGER PRIMARY KEY, interval NUMERIC, last NUMERIC, code TEXT, repeat NUMERIC);");
|
$this->query("CREATE TABLE actions (ID INTEGER PRIMARY KEY, interval NUMERIC, last NUMERIC, code TEXT, repeat NUMERIC);");
|
||||||
$this->query("CREATE TABLE handlers (ID INTEGER PRIMARY KEY, name TEXT, priority NUMERIC);");
|
$this->query("CREATE TABLE handlers (ID INTEGER PRIMARY KEY, name TEXT, priority NUMERIC);");
|
||||||
$this->query("CREATE TABLE blockUpdates (x INTEGER, y INTEGER, z INTEGER, type INTEGER, delay NUMERIC);");
|
$this->query("CREATE TABLE blockUpdates (x INTEGER, y INTEGER, z INTEGER, delay NUMERIC);");
|
||||||
//$this->query("PRAGMA synchronous = OFF;");
|
//$this->query("PRAGMA synchronous = OFF;");
|
||||||
$this->preparedSQL->selectHandlers = $this->database->prepare("SELECT DISTINCT ID FROM handlers WHERE name = :name ORDER BY priority DESC;");
|
$this->preparedSQL->selectHandlers = $this->database->prepare("SELECT DISTINCT ID FROM handlers WHERE name = :name ORDER BY priority DESC;");
|
||||||
$this->preparedSQL->selectActions = $this->database->prepare("SELECT ID,code,repeat FROM actions WHERE last <= (:time - interval);");
|
$this->preparedSQL->selectActions = $this->database->prepare("SELECT ID,code,repeat FROM actions WHERE last <= (:time - interval);");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user