private function getOptimalFlowDirections($xx, $yy, $zz) { $flowCost = [0, 0, 0, 0]; $isOptimalFlowDirection = [0, 0, 0, 0]; for ($j = 0; $j < 4; ++$j) { $flowCost[$j] = 1000; $x = $xx; $y = $yy; $z = $zz; if ($j === 0) { --$x; } elseif ($j === 1) { ++$x; } elseif ($j === 2) { --$z; } elseif ($j === 3) { ++$z; } if (!$this->canFlowInto($x, $y, $z)) { continue; } elseif ($this->canFlowInto($x, $y, $z) and $this->level->getBlockDataAt($x, $y, $z) === 0) { continue; } elseif ($this->canFlowInto($x, $y - 1, $z)) { $flowCost[$j] = 0; } else { $flowCost[$j] = $this->calculateFlowCost($x, $y, $z, 1, $j); } } $minCost = $flowCost[0]; for ($i = 1; $i < 4; ++$i) { if ($flowCost[$i] < $minCost) { $minCost = $flowCost[$i]; } } for ($i = 0; $i < 4; ++$i) { $isOptimalFlowDirection[$i] = $flowCost[$i] === $minCost; } return $isOptimalFlowDirection; }