PocketMine-MP  1.4 - API 1.10.0
 All Classes Namespaces Functions Variables Pages
Carpet.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 
28 
29 class Carpet extends Flowable{
30 
31  protected $id = self::CARPET;
32 
33  public function __construct($meta = 0){
34  $this->meta = $meta;
35  }
36 
37  public function isSolid(){
38  return true;
39  }
40 
41  public function getName(){
42  static $names = [
43  0 => "White Carpet",
44  1 => "Orange Carpet",
45  2 => "Magenta Carpet",
46  3 => "Light Blue Carpet",
47  4 => "Yellow Carpet",
48  5 => "Lime Carpet",
49  6 => "Pink Carpet",
50  7 => "Gray Carpet",
51  8 => "Light Gray Carpet",
52  9 => "Cyan Carpet",
53  10 => "Purple Carpet",
54  11 => "Blue Carpet",
55  12 => "Brown Carpet",
56  13 => "Green Carpet",
57  14 => "Red Carpet",
58  15 => "Black Carpet",
59  ];
60  return $names[$this->meta & 0x0f];
61  }
62 
63  protected function recalculateBoundingBox(){
64 
65  return new AxisAlignedBB(
66  $this->x,
67  $this->y,
68  $this->z,
69  $this->x + 1,
70  $this->y + 0.0625,
71  $this->z + 1
72  );
73  }
74 
75  public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
76  $down = $this->getSide(0);
77  if($down->getId() !== self::AIR){
78  $this->getLevel()->setBlock($block, $this, true, true);
79 
80  return true;
81  }
82 
83  return false;
84  }
85 
86  public function onUpdate($type){
87  if($type === Level::BLOCK_UPDATE_NORMAL){
88  if($this->getSide(0)->getId() === self::AIR){
89  $this->getLevel()->useBreakOn($this);
90 
91  return Level::BLOCK_UPDATE_NORMAL;
92  }
93  }
94 
95  return false;
96  }
97 
98 }
getSide($side, $step=1)
Definition: Block.php:1028