PocketMine-MP  1.4 - API 1.10.0
 All Classes Namespaces Functions Variables Pages
Thin.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 
24 
26 
27 abstract class Thin extends Transparent{
28 
29  public function isSolid(){
30  return false;
31  }
32 
33  protected function recalculateBoundingBox(){
34 
35  $f = 0.4375;
36  $f1 = 0.5625;
37  $f2 = 0.4375;
38  $f3 = 0.5625;
39 
40  $flag = $this->canConnect($this->getSide(2));
41  $flag1 = $this->canConnect($this->getSide(3));
42  $flag2 = $this->canConnect($this->getSide(4));
43  $flag3 = $this->canConnect($this->getSide(5));
44 
45  if((!$flag2 or !$flag3) and ($flag2 or $flag3 or $flag or $flag1)){
46  if($flag2 and !$flag3){
47  $f = 0;
48  }elseif(!$flag2 and $flag3){
49  $f1 = 1;
50  }
51  }else{
52  $f = 0;
53  $f1 = 1;
54  }
55 
56  if((!$flag or !$flag1) and ($flag2 or $flag3 or $flag or $flag1)){
57  if($flag and !$flag1){
58  $f2 = 0;
59  }elseif(!$flag and $flag1){
60  $f3 = 1;
61  }
62  }else{
63  $f2 = 0;
64  $f3 = 1;
65  }
66 
67  return new AxisAlignedBB(
68  $this->x + $f,
69  $this->y,
70  $this->z + $f2,
71  $this->x + $f1,
72  $this->y + 1,
73  $this->z + $f3
74  );
75  }
76 
77 
78  public function canConnect(Block $block){
79  return $block->isSolid() or $block->getId() === $this->getId() or $block->getId() === self::GLASS_PANE or $block->getId() === self::GLASS;
80  }
81 
82 }
getSide($side, $step=1)
Definition: Block.php:1028