Exemplo n.º 1
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $down = $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];
         $side = $faces[$face];
         $faces = [1 => 4, 2 => 5, 3 => 2, 4 => 3, 5 => 0, 6 => 0, 0 => 0];
         if ($this->getSide($faces[$side])->isCharged($this->getHash())) {
             $this->id = 75;
             $this->getLevel()->setBlock($block, $this);
             return;
         }
         $this->getLevel()->setBlock($block, $this);
         $this->BroadcastRedstoneUpdate(Level::REDSTONE_UPDATE_PLACE, Block::REDSTONESOURCEPOWER);
         return true;
     } elseif ($down->isTransparent() === false or $down->getId() === self::FENCE or $down->getId() === self::COBBLE_WALL or $down->getId() === self::GLASS || $down instanceof Slab && ($down->meta & 0x8) === 0x8 || $down instanceof WoodSlab && ($down->meta & 0x8) === 0x8 || $down instanceof Stair && ($down->meta & 0x4) === 0x4) {
         $this->meta = 0;
         if ($target->isCharged($this->getHash())) {
             $this->id = 75;
             $this->getLevel()->setBlock($block, $this);
             return;
         }
         $this->getLevel()->setBlock($block, $this);
         $this->BroadcastRedstoneUpdate(Level::REDSTONE_UPDATE_PLACE, Block::REDSTONESOURCEPOWER);
         return true;
     }
     return false;
 }
Exemplo n.º 2
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];
         if ($target->isCharged()) {
             $this->id = 75;
             $this->getLevel()->setBlock($block, $this);
             return;
         }
         $this->getLevel()->setBlock($block, $this);
         $this->BroadcastRedstoneUpdate(Level::REDSTONE_UPDATE_PLACE, $this->getPower());
         $this->getLevel()->scheduleUpdate($this->getSide(Vector3::SIDE_UP), 2);
         // 2 ticks = 1 redstone tick
         return true;
     } elseif ($below->isTransparent() === false or $below->getId() === self::FENCE or $below->getId() === self::COBBLE_WALL) {
         $this->meta = 0;
         if ($target->isCharged()) {
             $this->id = 75;
             $this->getLevel()->setBlock($block, $this);
             return;
         }
         $this->getLevel()->setBlock($block, $this);
         $this->BroadcastRedstoneUpdate(Level::REDSTONE_UPDATE_PLACE, $this->getPower());
         $this->getLevel()->scheduleUpdate($this->getSide(Vector3::SIDE_UP), 2);
         return true;
     }
     return false;
 }