PocketMine-MP  1.4 - API 1.10.0
 All Classes Namespaces Functions Variables Pages
Stair.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 abstract class Stair extends Transparent{
29 
30  public function getHardness(){
31  return 30;
32  }
33 
34  /*
35  public function collidesWithBB(AxisAlignedBB $bb, &$list = []){
36  $damage = $this->getDamage();
37  $j = $damage & 0x03;
38 
39  $f = 0;
40  $f1 = 0.5;
41  $f2 = 0.5;
42  $f3 = 1;
43 
44  if(($damage & 0x04) > 0){
45  $f = 0.5;
46  $f1 = 1;
47  $f2 = 0;
48  $f3 = 0.5;
49  }
50 
51  if($bb->intersectsWith($bb2 = AxisAlignedBB::getBoundingBoxFromPool(
52  $this->x,
53  $this->y + $f,
54  $this->z,
55  $this->x + 1,
56  $this->y + $f1,
57  $this->z + 1
58  ))){
59  $list[] = $bb2;
60  }
61 
62  if($j === 0){
63  if($bb->intersectsWith($bb2 = AxisAlignedBB::getBoundingBoxFromPool(
64  $this->x + 0.5,
65  $this->y + $f2,
66  $this->z,
67  $this->x + 1,
68  $this->y + $f3,
69  $this->z + 1
70  ))){
71  $list[] = $bb2;
72  }
73  }elseif($j === 1){
74  if($bb->intersectsWith($bb2 = AxisAlignedBB::getBoundingBoxFromPool(
75  $this->x,
76  $this->y + $f2,
77  $this->z,
78  $this->x + 0.5,
79  $this->y + $f3,
80  $this->z + 1
81  ))){
82  $list[] = $bb2;
83  }
84  }elseif($j === 2){
85  if($bb->intersectsWith($bb2 = AxisAlignedBB::getBoundingBoxFromPool(
86  $this->x,
87  $this->y + $f2,
88  $this->z + 0.5,
89  $this->x + 1,
90  $this->y + $f3,
91  $this->z + 1
92  ))){
93  $list[] = $bb2;
94  }
95  }elseif($j === 3){
96  if($bb->intersectsWith($bb2 = AxisAlignedBB::getBoundingBoxFromPool(
97  $this->x,
98  $this->y + $f2,
99  $this->z,
100  $this->x + 1,
101  $this->y + $f3,
102  $this->z + 0.5
103  ))){
104  $list[] = $bb2;
105  }
106  }
107  }
108  */
109 
110  protected function recalculateBoundingBox(){
111 
112  if(($this->getDamage() & 0x04) > 0){
113  return new AxisAlignedBB(
114  $this->x,
115  $this->y + 0.5,
116  $this->z,
117  $this->x + 1,
118  $this->y + 1,
119  $this->z + 1
120  );
121  }else{
122  return new AxisAlignedBB(
123  $this->x,
124  $this->y,
125  $this->z,
126  $this->x + 1,
127  $this->y + 0.5,
128  $this->z + 1
129  );
130  }
131  }
132 
133  public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
134  $faces = [
135  0 => 0,
136  1 => 2,
137  2 => 1,
138  3 => 3,
139  ];
140  $this->meta = $faces[$player->getDirection()] & 0x03;
141  if(($fy > 0.5 and $face !== 1) or $face === 0){
142  $this->meta |= 0x04; //Upside-down stairs
143  }
144  $this->getLevel()->setBlock($block, $this, true, true);
145 
146  return true;
147  }
148 
149  public function getDrops(Item $item){
150  if($item->isPickaxe() >= 1){
151  return [
152  [$this->id, 0, 1],
153  ];
154  }else{
155  return [];
156  }
157  }
158 }