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
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false) {
         $faces = [2 => 2, 3 => 3, 4 => 4, 5 => 5];
         if (isset($faces[$face])) {
             $this->meta = $faces[$face];
             $this->getLevel()->setBlock($block, $this, true, true);
             return true;
         }
     }
     return false;
 }
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if (($target->isTransparent() === false or $target->getId() === self::SLAB) and $face !== 0 and $face !== 1) {
         $faces = [2 => 0, 3 => 1, 4 => 2, 5 => 3];
         $this->meta = $faces[$face] & 0x3;
         if ($fy > 0.5) {
             $this->meta |= 0x8;
         }
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
示例#4
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $below = $this->getSide(0);
     if ($target->isTransparent() === false and $face !== 0) {
         $faces = [1 => 5, 2 => 4, 3 => 3, 4 => 2, 5 => 1];
         $this->meta = $faces[$face];
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     } elseif ($below->isTransparent() === false or $below->getId() === self::FENCE or $below->getId() === self::COBBLE_WALL) {
         $this->meta = 0;
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
 public function onUpdate($type)
 {
     if ($type === Level::BLOCK_UPDATE_NORMAL or $type === Level::BLOCK_UPDATE_TOUCH) {
         $this->getLevel()->setBlock($this, Block::get(Item::GLOWING_REDSTONE_ORE, $this->meta), false, true);
         return Level::BLOCK_UPDATE_WEAK;
     }
     return false;
 }
 public function onUpdate($type)
 {
     if ($type === Level::BLOCK_UPDATE_SCHEDULED or $type === Level::BLOCK_UPDATE_RANDOM) {
         $this->getLevel()->setBlock($this, Block::get(Item::REDSTONE_ORE, $this->meta), false, false, true);
         return Level::BLOCK_UPDATE_WEAK;
     }
     return false;
 }
示例#7
0
 public function onActivate(Item $item, Player $player = null)
 {
     if ($item->isHoe()) {
         $item->useOn($this);
         $this->getLevel()->setBlock($this, Block::get(Item::FARMLAND, 0), true);
         return true;
     }
     return false;
 }
示例#8
0
 public function onEnable()
 {
     error_reporting(0);
     @mkdir($this->getDataFolder());
     self::$instance = $this;
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $this->console = new ConsoleCommandSender();
     \nao20010128nao\block\Block::pollute();
     $this->ph1 = new PopupBroadcast("The game is running...\nPhase 1 - Collect Anything!");
     $this->ph2 = new PopupBroadcast("The game is running...\nPhase 2 - Live or Die!");
     $this->gameover = new PopupBroadcast("GAME OVER");
     $this->wfp = new PopupBroadcast("Waiting for players...");
     $this->shrinkBorder = new ShrinkBorder($this);
     $this->phase = 0;
     $this->onTimeup();
 }
示例#9
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($face !== 0) {
         $faces = [2 => 2, 3 => 3, 4 => 4, 5 => 5];
         if (!isset($faces[$face])) {
             $this->meta = floor(($player->yaw + 180) * 16 / 360 + 0.5) & 0xf;
             $this->getLevel()->setBlock($block, Block::get(Item::SIGN_POST, $this->meta), true);
             return true;
         } else {
             $this->meta = $faces[$face];
             $this->getLevel()->setBlock($block, Block::get(Item::WALL_SIGN, $this->meta), true);
             return true;
         }
     }
     return false;
 }
示例#10
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $this->meta &= 0x7;
     if ($face === 0) {
         if ($target->getId() === self::WOOD_SLAB and ($target->getDamage() & 0x8) === 0x8 and ($target->getDamage() & 0x7) === ($this->meta & 0x7)) {
             $this->getLevel()->setBlock($target, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true);
             return true;
         } elseif ($block->getId() === self::WOOD_SLAB and ($block->getDamage() & 0x7) === ($this->meta & 0x7)) {
             $this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true);
             return true;
         } else {
             $this->meta |= 0x8;
         }
     } elseif ($face === 1) {
         if ($target->getId() === self::WOOD_SLAB and ($target->getDamage() & 0x8) === 0 and ($target->getDamage() & 0x7) === ($this->meta & 0x7)) {
             $this->getLevel()->setBlock($target, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true);
             return true;
         } elseif ($block->getId() === self::WOOD_SLAB and ($block->getDamage() & 0x7) === ($this->meta & 0x7)) {
             $this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true);
             return true;
         }
     } else {
         //TODO: collision
         if ($block->getId() === self::WOOD_SLAB) {
             if (($block->getDamage() & 0x7) === ($this->meta & 0x7)) {
                 $this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true);
                 return true;
             }
             return false;
         } else {
             if ($fy > 0.5) {
                 $this->meta |= 0x8;
             }
         }
     }
     if ($block->getId() === self::WOOD_SLAB and ($target->getDamage() & 0x7) !== ($this->meta & 0x7)) {
         return false;
     }
     $this->getLevel()->setBlock($block, $this, true, true);
     return true;
 }
示例#11
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;
 }
 public function canConnect(Block $block)
 {
     //TODO: activate comments when the NetherBrickFenceGate class has been created.
     return $block instanceof NetherBrickFence ? true : $block->isSolid() and !$block->isTransparent();
 }
示例#13
0
 public function canConnect(Block $block)
 {
     return ($block->getId() !== self::COBBLE_WALL and $block->getId() !== self::FENCE_GATE) ? $block->isSolid() and !$block->isTransparent() : true;
 }
示例#14
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if (!$target->isTransparent() and $target->isSolid()) {
         $faces = [0 => 0, 1 => 0, 2 => 1, 3 => 4, 4 => 8, 5 => 2];
         if (isset($faces[$face])) {
             $this->meta = $faces[$face];
             $this->getLevel()->setBlock($block, $this, true, true);
             return true;
         }
     }
     return false;
 }
示例#15
0
 private function checkForHarden()
 {
     if ($this instanceof Lava) {
         $colliding = false;
         for ($side = 0; $side <= 5 and !$colliding; ++$side) {
             $colliding = $this->getSide($side) instanceof Water;
         }
         if ($colliding) {
             if ($this->getDamage() === 0) {
                 $this->getLevel()->setBlock($this, Block::get(Item::OBSIDIAN), true);
             } elseif ($this->getDamage() <= 4) {
                 $this->getLevel()->setBlock($this, Block::get(Item::COBBLESTONE), true);
             }
         }
     }
 }
示例#16
0
 public function onActivate(Item $item, Player $player = null)
 {
     if (($this->getDamage() & 0x8) === 0x8) {
         //Top
         $down = $this->getSide(0);
         if ($down->getId() === $this->getId()) {
             $meta = $down->getDamage() ^ 0x4;
             $this->getLevel()->setBlock($down, Block::get($this->getId(), $meta), true);
             $players = $this->getLevel()->getChunkPlayers($this->x >> 4, $this->z >> 4);
             if ($player instanceof Player) {
                 unset($players[$player->getLoaderId()]);
             }
             $this->level->addSound(new DoorSound($this));
             return true;
         }
         return false;
     } else {
         $this->meta ^= 0x4;
         $this->getLevel()->setBlock($this, $this, true);
         $players = $this->getLevel()->getChunkPlayers($this->x >> 4, $this->z >> 4);
         if ($player instanceof Player) {
             unset($players[$player->getLoaderId()]);
         }
         $this->level->addSound(new DoorSound($this));
     }
     return true;
 }
示例#17
0
 /**
  * Returns the Block on the side $side, works like Vector3::side()
  *
  * @param int $side
  * @param int $step
  *
  * @return Block
  */
 public function getSide($side, $step = 1)
 {
     if ($this->isValid()) {
         return $this->getLevel()->getBlock(Vector3::getSide($side, $step));
     }
     return Block::get(Item::AIR, 0, Position::fromObject(Vector3::getSide($side, $step)));
 }
示例#18
0
 public function canConnect(Block $block)
 {
     return $block->isSolid() or $block->getId() === $this->getId() or $block->getId() === self::GLASS_PANE or $block->getId() === self::GLASS;
 }
示例#19
0
 public function canConnect(Block $block)
 {
     return ($block instanceof Fence or $block instanceof FenceGate) ? true : $block->isSolid() and !$block->isTransparent();
 }
示例#20
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $down = $this->getSide(0);
     if ($down->isTransparent() === false) {
         $faces = [0 => 3, 1 => 4, 2 => 2, 3 => 5];
         $d = $player instanceof Player ? $player->getDirection() : 0;
         $next = $this->getSide($faces[($d + 3) % 4]);
         $downNext = $this->getSide(0);
         if ($next->canBeReplaced() === true and $downNext->isTransparent() === false) {
             $meta = ($d + 3) % 4 & 0x3;
             $this->getLevel()->setBlock($block, Block::get($this->id, $meta), true, true);
             $this->getLevel()->setBlock($next, Block::get($this->id, $meta | 0x8), true, true);
             return true;
         }
     }
     return false;
 }