From ea5bd0348ae20cf444a333ade222df4b3ea2c6b0 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 29 Aug 2017 14:22:12 +0100 Subject: [PATCH] Fixed liquid flow attempting to set negative block damage values This should only execute if the current liquid block is actually still existent. When decay is negative, it means the water block doesn't exist anymore. --- src/pocketmine/block/Liquid.php | 70 +++++++++++++++++---------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/src/pocketmine/block/Liquid.php b/src/pocketmine/block/Liquid.php index ba8e75798..ad639cdf6 100644 --- a/src/pocketmine/block/Liquid.php +++ b/src/pocketmine/block/Liquid.php @@ -254,48 +254,50 @@ abstract class Liquid extends Transparent{ //$this->updateFlow(); } - $bottomBlock = $this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y - 1, $this->z)); + if($decay >= 0){ + $bottomBlock = $this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y - 1, $this->z)); - if($this instanceof Lava and $bottomBlock instanceof Water){ - $this->getLevel()->setBlock($bottomBlock, BlockFactory::get(Block::STONE), true, true); + if($this instanceof Lava and $bottomBlock instanceof Water){ + $this->getLevel()->setBlock($bottomBlock, BlockFactory::get(Block::STONE), true, true); - }elseif($bottomBlock->canBeFlowedInto() or ($bottomBlock instanceof Liquid and ($bottomBlock->getDamage() & 0x07) !== 0)){ - $this->getLevel()->setBlock($bottomBlock, BlockFactory::get($this->id, $decay | 0x08), true, false); - $this->getLevel()->scheduleDelayedBlockUpdate($bottomBlock, $this->tickRate()); + }elseif($bottomBlock->canBeFlowedInto() or ($bottomBlock instanceof Liquid and ($bottomBlock->getDamage() & 0x07) !== 0)){ + $this->getLevel()->setBlock($bottomBlock, BlockFactory::get($this->id, $decay | 0x08), true, false); + $this->getLevel()->scheduleDelayedBlockUpdate($bottomBlock, $this->tickRate()); - }elseif($decay >= 0 and ($decay === 0 or !$bottomBlock->canBeFlowedInto())){ - $flags = $this->getOptimalFlowDirections(); + }elseif($decay === 0 or !$bottomBlock->canBeFlowedInto()){ + $flags = $this->getOptimalFlowDirections(); - $l = $decay + $multiplier; + $l = $decay + $multiplier; - if($decay >= 8){ - $l = 1; + if($decay >= 8){ + $l = 1; + } + + if($l >= 8){ + $this->checkForHarden(); + + return; + } + + if($flags[0]){ + $this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x - 1, $this->y, $this->z)), $l); + } + + if($flags[1]){ + $this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x + 1, $this->y, $this->z)), $l); + } + + if($flags[2]){ + $this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z - 1)), $l); + } + + if($flags[3]){ + $this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z + 1)), $l); + } } - if($l >= 8){ - $this->checkForHarden(); - return; - } - - if($flags[0]){ - $this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x - 1, $this->y, $this->z)), $l); - } - - if($flags[1]){ - $this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x + 1, $this->y, $this->z)), $l); - } - - if($flags[2]){ - $this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z - 1)), $l); - } - - if($flags[3]){ - $this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z + 1)), $l); - } + $this->checkForHarden(); } - - $this->checkForHarden(); - } }