separated neighbor updates and scheduled updates

This commit is contained in:
GameHerobrine 2024-05-22 06:15:34 +03:00
parent ee989ef556
commit 2ebc482e3d
36 changed files with 197 additions and 262 deletions

View file

@ -457,7 +457,8 @@ class BlockAPI{
return $this->cancelAction($block, $player);
}
}
$this->blockUpdate($target, BLOCK_UPDATE_TOUCH);
StaticBlock::getBlock($target->getID())::interact($target->level, $target->x, $target->y, $target->z, $player);
if($target->isActivable === true){
if($this->server->api->dhandle("player.block.activate", ["player" => $player, "block" => $block, "target" => $target, "item" => $item]) !== false and $target->onActivate($item, $player) === true){
@ -532,13 +533,21 @@ class BlockAPI{
return false;
}
$level = $block::onUpdate($pos->level, $pos->x, $pos->y, $pos->z, $type);
if($level === BLOCK_UPDATE_NORMAL){
$this->blockUpdateAround($block, $level);
}
return $level;
}
public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){
if($type == BLOCK_UPDATE_NORMAL){
try{
throw new Exception("Deprecated: tried updating $pos using BLOCK_UPDATE_NORMAL.");
}catch(Exception $e){
ConsoleAPI::error($e->getMessage());
ConsoleAPI::error($e->getTraceAsString());
}
return;
}
if($delay !== false){
$this->scheduleBlockUpdate($pos->getSide(0), $delay, $type);
$this->scheduleBlockUpdate($pos->getSide(1), $delay, $type);