pocketmine\block\Liquid::calculateFlowCost PHP Méthode

calculateFlowCost() private méthode

private calculateFlowCost ( Block $block, $accumulatedCost, $previousDirection )
$block Block
    private function calculateFlowCost(Block $block, $accumulatedCost, $previousDirection)
    {
        $cost = 1000;
        for ($j = 0; $j < 4; ++$j) {
            if ($j === 0 and $previousDirection === 1 or $j === 1 and $previousDirection === 0 or $j === 2 and $previousDirection === 3 or $j === 3 and $previousDirection === 2) {
                $x = $block->x;
                $y = $block->y;
                $z = $block->z;
                if ($j === 0) {
                    --$x;
                } elseif ($j === 1) {
                    ++$x;
                } elseif ($j === 2) {
                    --$z;
                } elseif ($j === 3) {
                    ++$z;
                }
                $blockSide = $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $z));
                if (!$blockSide->canBeFlowedInto() and !$blockSide instanceof Liquid) {
                    continue;
                } elseif ($blockSide instanceof Liquid and $blockSide->getDamage() === 0) {
                    continue;
                } elseif ($this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y - 1, $z))->canBeFlowedInto()) {
                    return $accumulatedCost;
                }
                if ($accumulatedCost >= 4) {
                    continue;
                }
                $realCost = $this->calculateFlowCost($blockSide, $accumulatedCost + 1, $j);
                if ($realCost < $cost) {
                    $cost = $realCost;
                }
            }
        }
        return $cost;
    }