68 if(!$this->world->isInWorld($x, $y, $z) || !$this->canFlowInto($this->world->getBlockAt($x, $y, $z))){
89 $realCost = $this->calculateFlowCost($x, $y, $z, $accumulatedCost + 1, $maxCost, $originOpposite, Facing::opposite($j));
103 $flowCost = array_fill_keys(array_map(fn(
Facing $f) => $f->value,
Facing::HORIZONTAL), 1000);
104 $maxCost = intdiv(4, $this->flowDecayPerBlock);
105 foreach(Facing::HORIZONTAL as $j){
106 [$dx, $dy, $dz] = Facing::OFFSET[$j->value];
111 if(!$this->world->isInWorld($x, $y, $z) || !$this->canFlowInto($this->world->getBlockAt($x, $y, $z))){
112 $this->flowCostVisited[World::blockHash($x, $y, $z)] = self::BLOCKED;
113 }elseif($this->world->getBlockAt($x, $y - 1, $z)->canBeFlowedInto()){
114 $this->flowCostVisited[World::blockHash($x, $y, $z)] = self::CAN_FLOW_DOWN;
115 $flowCost[$j->value] = $maxCost = 0;
116 }elseif($maxCost > 0){
117 $this->flowCostVisited[World::blockHash($x, $y, $z)] = self::CAN_FLOW;
118 $opposite = Facing::opposite($j);
119 $flowCost[$j->value] = $this->calculateFlowCost($x, $y, $z, 1, $maxCost, $opposite, $opposite);
120 $maxCost = min($maxCost, $flowCost[$j->value]);
124 $this->flowCostVisited = [];
126 $minCost = min($flowCost);
128 $isOptimalFlowDirection = [];
130 foreach($flowCost as $facing => $cost){
131 if($cost === $minCost){
132 $isOptimalFlowDirection[] = $facing;
136 return $isOptimalFlowDirection;