コード例 #1
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target instanceof Water) {
         $up = $target->getSide(Vector3::SIDE_UP);
         if ($up->getId() === Block::AIR) {
             $this->getLevel()->setBlock($up, $this, true, true);
             return true;
         }
     }
     return false;
 }
コード例 #2
0
 private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null)
 {
     ++$check;
     $index = $pos->x . "." . $pos->y . "." . $pos->z;
     if (isset($visited[$index])) {
         return false;
     }
     if ($pos->getId() === self::WOOD) {
         return true;
     } elseif ($pos->getId() === self::LEAVES and $distance < 3) {
         $visited[$index] = true;
         $down = $pos->getSide(0)->getId();
         if ($down === Item::WOOD) {
             return true;
         }
         if ($fromSide === null) {
             for ($side = 2; $side <= 5; ++$side) {
                 if ($this->findLog($pos->getSide($side), $visited, $distance + 1, $check, $side) === true) {
                     return true;
                 }
             }
         } else {
             //No more loops
             switch ($fromSide) {
                 case 2:
                     if ($this->findLog($pos->getSide(2), $visited, $distance + 1, $check, $fromSide) === true) {
                         return true;
                     } elseif ($this->findLog($pos->getSide(4), $visited, $distance + 1, $check, $fromSide) === true) {
                         return true;
                     } elseif ($this->findLog($pos->getSide(5), $visited, $distance + 1, $check, $fromSide) === true) {
                         return true;
                     }
                     break;
                 case 3:
                     if ($this->findLog($pos->getSide(3), $visited, $distance + 1, $check, $fromSide) === true) {
                         return true;
                     } elseif ($this->findLog($pos->getSide(4), $visited, $distance + 1, $check, $fromSide) === true) {
                         return true;
                     } elseif ($this->findLog($pos->getSide(5), $visited, $distance + 1, $check, $fromSide) === true) {
                         return true;
                     }
                     break;
                 case 4:
                     if ($this->findLog($pos->getSide(2), $visited, $distance + 1, $check, $fromSide) === true) {
                         return true;
                     } elseif ($this->findLog($pos->getSide(3), $visited, $distance + 1, $check, $fromSide) === true) {
                         return true;
                     } elseif ($this->findLog($pos->getSide(4), $visited, $distance + 1, $check, $fromSide) === true) {
                         return true;
                     }
                     break;
                 case 5:
                     if ($this->findLog($pos->getSide(2), $visited, $distance + 1, $check, $fromSide) === true) {
                         return true;
                     } elseif ($this->findLog($pos->getSide(3), $visited, $distance + 1, $check, $fromSide) === true) {
                         return true;
                     } elseif ($this->findLog($pos->getSide(5), $visited, $distance + 1, $check, $fromSide) === true) {
                         return true;
                     }
                     break;
             }
         }
     }
     return false;
 }