From 6bc5f600110cb68b5f1286d5017638b3a811060e Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 30 Aug 2014 23:52:06 +0200 Subject: [PATCH] Added Cobble Wall bounding box --- src/pocketmine/block/StoneWall.php | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/pocketmine/block/StoneWall.php b/src/pocketmine/block/StoneWall.php index 2e6bda3a2..23f758c97 100644 --- a/src/pocketmine/block/StoneWall.php +++ b/src/pocketmine/block/StoneWall.php @@ -22,6 +22,8 @@ namespace pocketmine\block; +use pocketmine\math\AxisAlignedBB; + class StoneWall extends Transparent{ public function __construct($meta = 0){ $meta &= 0x01; @@ -34,4 +36,40 @@ class StoneWall extends Transparent{ $this->hardness = 30; } + public function getBoundingBox(){ + $flag = $this->canConnect($this->getSide(2)); + $flag1 = $this->canConnect($this->getSide(3)); + $flag2 = $this->canConnect($this->getSide(4)); + $flag3 = $this->canConnect($this->getSide(5)); + + $f = $flag2 ? 0 : 0.25; + $f1 = $flag3 ? 1 : 0.75; + $f2 = $flag ? 0 : 0.25; + $f3 = $flag1 ? 1 : 0.75; + $f4 = 1; + + if($flag and $flag1 and !$flag2 and !$flag3){ + $f4 = 0.8125; + $f = 0.3125; + $f1 = 0.6875; + }elseif(!$flag and !$flag1 and $flag2 and $flag3){ + $f4 = 0.8125; + $f2 = 0.3125; + $f3 = 0.6875; + } + + return new AxisAlignedBB( + $this->x + $f, + $this->y, + $this->z + $f2, + $this->x + $f1, + $this->y + $f4, + $this->z + $f3 + ); + } + + public function canConnect(Block $block){ + return ($block->getID() !== self::COBBLE_WALL and $block->getID() !== self::FENCE_GATE) ? $block->isSolid : true; + } + } \ No newline at end of file