pocketmine\math\Vector3::setComponents PHP Method

setComponents() public method

public setComponents ( $x, $y, $z ) : Vector3
$x
$y
$z
return Vector3
    public function setComponents($x, $y, $z)
    {
        $this->x = $x;
        $this->y = $y;
        $this->z = $z;
        return $this;
    }

Usage Example

Beispiel #1
2
 private function getOptimalFlowDirections()
 {
     if ($this->temporalVector === \null) {
         $this->temporalVector = new Vector3(0, 0, 0);
     }
     for ($j = 0; $j < 4; ++$j) {
         $this->flowCost[$j] = 1000;
         $x = $this->x;
         $y = $this->y;
         $z = $this->z;
         if ($j === 0) {
             --$x;
         } elseif ($j === 1) {
             ++$x;
         } elseif ($j === 2) {
             --$z;
         } elseif ($j === 3) {
             ++$z;
         }
         $block = $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $z));
         if (!$block->canBeFlowedInto() and !$block instanceof Liquid) {
             continue;
         } elseif ($block instanceof Liquid and $block->getDamage() === 0) {
             continue;
         } elseif ($this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y - 1, $z))->canBeFlowedInto()) {
             $this->flowCost[$j] = 0;
         } else {
             $this->flowCost[$j] = $this->calculateFlowCost($block, 1, $j);
         }
     }
     $minCost = $this->flowCost[0];
     for ($i = 1; $i < 4; ++$i) {
         if ($this->flowCost[$i] < $minCost) {
             $minCost = $this->flowCost[$i];
         }
     }
     for ($i = 0; $i < 4; ++$i) {
         $this->isOptimalFlowDirection[$i] = $this->flowCost[$i] === $minCost;
     }
     return $this->isOptimalFlowDirection;
 }
All Usage Examples Of pocketmine\math\Vector3::setComponents