PocketMine-MP  1.4 - API 1.10.0
 All Classes Namespaces Functions Variables Pages
SignPost.php
1 <?php
2 
3 /*
4  *
5  * ____ _ _ __ __ _ __ __ ____
6  * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7  * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8  * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9  * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * @author PocketMine Team
17  * @link http://www.pocketmine.net/
18  *
19  *
20 */
21 
22 namespace pocketmine\block;
23 
27 
28 class SignPost extends Transparent{
29 
30  protected $id = self::SIGN_POST;
31 
32  public function __construct($meta = 0){
33  $this->meta = $meta;
34  }
35 
36  public function getHardness(){
37  return 5;
38  }
39 
40  public function isSolid(){
41  return false;
42  }
43 
44  public function getName(){
45  return "Sign Post";
46  }
47 
48  public function getBoundingBox(){
49  return null;
50  }
51 
52 
53  public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
54  if($face !== 0){
55  $faces = [
56  2 => 2,
57  3 => 3,
58  4 => 4,
59  5 => 5,
60  ];
61  if(!isset($faces[$face])){
62  $this->meta = floor((($player->yaw + 180) * 16 / 360) + 0.5) & 0x0F;
63  $this->getLevel()->setBlock($block, Block::get(Item::SIGN_POST, $this->meta), true);
64 
65  return true;
66  }else{
67  $this->meta = $faces[$face];
68  $this->getLevel()->setBlock($block, Block::get(Item::WALL_SIGN, $this->meta), true);
69 
70  return true;
71  }
72  }
73 
74  return false;
75  }
76 
77  public function onUpdate($type){
78  if($type === Level::BLOCK_UPDATE_NORMAL){
79  if($this->getSide(0)->getId() === self::AIR){
80  $this->getLevel()->useBreakOn($this);
81 
82  return Level::BLOCK_UPDATE_NORMAL;
83  }
84  }
85 
86  return false;
87  }
88 
89  public function onBreak(Item $item){
90  $this->getLevel()->setBlock($this, new Air(), true, true, true);
91 
92  return true;
93  }
94 
95  public function getDrops(Item $item){
96  return [
97  [Item::SIGN, 0, 1],
98  ];
99  }
100 }
getSide($side, $step=1)
Definition: Block.php:1028
static get($id, $meta=0, Position $pos=null)
Definition: Block.php:782
Definition: SignPost.php:28