Fixed block update recursion issues (#464)

* Schedule all neighbour block updates to execute at the end of the tick, fixed recursion crash, close #251

* doTickPending timings now include neighbour block update times, refactored some var names
This commit is contained in:
Dylan K. Taylor
2017-04-01 20:18:56 +01:00
committed by GitHub
parent afb2e0c51f
commit 630f0fab7f
4 changed files with 67 additions and 19 deletions

View File

@ -64,7 +64,7 @@ class Lava extends Liquid{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$ret = $this->getLevel()->setBlock($this, $this, true, false);
$this->getLevel()->scheduleUpdate($this, $this->tickRate());
$this->getLevel()->scheduleDelayedBlockUpdate($this, $this->tickRate());
return $ret;
}

View File

@ -189,7 +189,7 @@ abstract class Liquid extends Transparent{
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$this->checkForHarden();
$this->getLevel()->scheduleUpdate($this, $this->tickRate());
$this->getLevel()->scheduleDelayedBlockUpdate($this, $this->tickRate());
}elseif($type === Level::BLOCK_UPDATE_SCHEDULED){
if($this->temporalVector === null){
$this->temporalVector = new Vector3(0, 0, 0);
@ -242,7 +242,7 @@ abstract class Liquid extends Transparent{
$this->getLevel()->setBlock($this, new Air(), true);
}else{
$this->getLevel()->setBlock($this, Block::get($this->id, $decay), true);
$this->getLevel()->scheduleUpdate($this, $this->tickRate());
$this->getLevel()->scheduleDelayedBlockUpdate($this, $this->tickRate());
}
}elseif($flag){
//$this->getLevel()->scheduleUpdate($this, $this->tickRate());
@ -262,10 +262,10 @@ abstract class Liquid extends Transparent{
if($decay >= 8){
$this->getLevel()->setBlock($bottomBlock, Block::get($this->id, $decay), true);
$this->getLevel()->scheduleUpdate($bottomBlock, $this->tickRate());
$this->getLevel()->scheduleDelayedBlockUpdate($bottomBlock, $this->tickRate());
}else{
$this->getLevel()->setBlock($bottomBlock, Block::get($this->id, $decay + 8), true);
$this->getLevel()->scheduleUpdate($bottomBlock, $this->tickRate());
$this->getLevel()->scheduleDelayedBlockUpdate($bottomBlock, $this->tickRate());
}
}elseif($decay >= 0 and ($decay === 0 or !$bottomBlock->canBeFlowedInto())){
$flags = $this->getOptimalFlowDirections();
@ -310,7 +310,7 @@ abstract class Liquid extends Transparent{
}
$this->getLevel()->setBlock($block, Block::get($this->getId(), $newFlowDecay), true);
$this->getLevel()->scheduleUpdate($block, $this->tickRate());
$this->getLevel()->scheduleDelayedBlockUpdate($block, $this->tickRate());
}
}

View File

@ -48,7 +48,7 @@ class Water extends Liquid{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$ret = $this->getLevel()->setBlock($this, $this, true, false);
$this->getLevel()->scheduleUpdate($this, $this->tickRate());
$this->getLevel()->scheduleDelayedBlockUpdate($this, $this->tickRate());
return $ret;
}