コード例 #1
0
ファイル: Painting.php プロジェクト: MunkySkunk/BukkitPE
 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($target->isTransparent() === false and $face !== 0 and $face !== 1 and $block->isSolid() === false) {
         $faces = [2 => 0, 3 => 2, 4 => 1, 5 => 3];
         $motives = [["Kebab", 1, 1], ["Aztec", 1, 1], ["Alban", 1, 1], ["Aztec2", 1, 1], ["Bomb", 1, 1], ["Plant", 1, 1], ["Wasteland", 1, 1], ["Wanderer", 1, 2], ["Graham", 1, 2], ["Pool", 2, 1], ["Courbet", 2, 1], ["Sunset", 2, 1], ["Sea", 2, 1], ["Creebet", 2, 1], ["Match", 2, 2], ["Bust", 2, 2], ["Stage", 2, 2], ["Void", 2, 2], ["SkullAndRoses", 2, 2], ["Fighters", 4, 2], ["Skeleton", 4, 3], ["DonkeyKong", 4, 3], ["Pointer", 4, 4], ["Pigscene", 4, 4], ["Flaming Skull", 4, 4]];
         $motive = $motives[mt_rand(0, count($motives) - 1)];
         $data = ["x" => $target->x, "y" => $target->y + 0.4, "z" => $target->z, "yaw" => $faces[$face] * 90, "Motive" => $motive[0]];
         $nbt = new Compound("", ["Motive" => new String("Motive", $data["Motive"]), "Pos" => new Enum("Pos", [new Double("", $data["x"]), new Double("", $data["y"]), new Double("", $data["z"])]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", $data["yaw"]), new Float("", 0)])]);
         $painting = new PaintingEntity($player->getLevel()->getChunk($block->getX() >> 4, $block->getZ() >> 4), $nbt);
         $painting->spawnToAll();
         /*if($player->isSurvival()){
         				$item = $player->getInventory()->getItemInHand();
         				$count = $item->getCount();
         				if(--$count <= 0){
         					$player->getInventory()->setItemInHand(Item::get(Item::AIR));
         					return;
         				}
         
         				$item->setCount($count);
         				$player->getInventory()->setItemInHand($item);
         			}*/
         return true;
     }
     return false;
 }
コード例 #2
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;
 }
コード例 #3
0
ファイル: TripwireHook.php プロジェクト: MunkySkunk/BukkitPE
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($face !== 0 && $face !== 1 && !$target->isTransparent()) {
         $ret = $this->setFacingDirection($face);
         $this->getLevel()->setBlock($block, $this, true);
         return $ret;
     }
     return false;
 }
コード例 #4
0
ファイル: WoodenButton.php プロジェクト: MunkySkunk/BukkitPE
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if (!$target->isTransparent() || ($face === 0 && ($this->getSide(0) instanceof Slab && ($this->getSide(0)->meta & 0x8) === 0x8) || $this->getSide(0) instanceof WoodSlab && ($this->getSide(0)->meta & 0x8) === 0x8 || $this->getSide(0) instanceof Stair && ($this->getSide(0)->meta & 0x4) === 0x4)) {
         $this->meta = $face;
         $this->getLevel()->setBlock($block, $this, true, false);
         return true;
     }
     return false;
 }
コード例 #5
0
ファイル: Ladder.php プロジェクト: MunkySkunk/BukkitPE
 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;
 }
コード例 #6
0
ファイル: IronTrapdoor.php プロジェクト: MunkySkunk/BukkitPE
 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;
 }
コード例 #7
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 ($this->getSide($faces[$side])->isTransparent() === true and !($side === 0 and ($below->getId() === self::FENCE or $below->getId() === self::COBBLE_WALL or $below->getId() === self::GLASS || $below instanceof Slab && ($below->meta & 0x8) === 0x8 || $below instanceof WoodSlab && ($below->meta & 0x8) === 0x8 || $below instanceof Stair && ($below->meta & 0x4) === 0x4))) {
         $this->meta = 0;
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
コード例 #8
0
ファイル: AnvilBlock.php プロジェクト: gitter-badger/BukkitPE
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false) {
         $faces = [0 => 0, 1 => 1, 2 => 2, 3 => 3];
         $damage = $this->getDamage();
         $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x4;
         if ($damage >= 0 && $damage <= 3) {
             $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
         } elseif ($damage >= 4 && $damage <= 7) {
             $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] | 0x4;
         } elseif ($damage >= 8 && $damage <= 11) {
             $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] | 0x8;
         }
         $this->getLevel()->setBlock($block, $this, true);
         return true;
     }
     return false;
 }
コード例 #9
0
ファイル: Lever.php プロジェクト: MunkySkunk/BukkitPE
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false) {
         $faces = [3 => 3, 2 => 4, 4 => 2, 5 => 1];
         if ($face === 0) {
             $to = $player instanceof Player ? $player->getDirection() : 0;
             $this->meta = $to ^ 0x1 === 0x1 ? 0 : 7;
         } elseif ($face === 1) {
             $to = $player instanceof Player ? $player->getDirection() : 0;
             $this->meta = $to ^ 0x1 === 0x1 ? 6 : 5;
         } else {
             $this->meta = $faces[$face];
         }
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
コード例 #10
0
 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();
 }
コード例 #11
0
ファイル: StoneWall.php プロジェクト: MunkySkunk/BukkitPE
 public function canConnect(Block $block)
 {
     return ($block->getId() !== self::COBBLE_WALL and $block->getId() !== self::FENCE_GATE) ? $block->isSolid() and !$block->isTransparent() : true;
 }
コード例 #12
0
ファイル: Fence.php プロジェクト: gitter-badger/BukkitPE
 public function canConnect(Block $block)
 {
     return ($block instanceof Fence or $block instanceof FenceGate) ? true : $block->isSolid() and !$block->isTransparent();
 }
コード例 #13
0
ファイル: Vine.php プロジェクト: MunkySkunk/BukkitPE
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ((!$target->isTransparent() and $target->isSolid()) || $target->getId() === Block::LEAVES || $target->getId() === Block::LEAVES2) {
         $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;
 }