fix collision detection not detecting fence & fence-gate, fixed nether-brick fence gate AABB, close #1299

This commit is contained in:
Dylan K. Taylor
2017-09-29 15:27:14 +01:00
parent a33be643c4
commit 27798c69ee
3 changed files with 31 additions and 17 deletions

View File

@ -25,6 +25,8 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
class NetherBrickFence extends Transparent{
@ -46,8 +48,21 @@ class NetherBrickFence extends Transparent{
return "Nether Brick Fence";
}
protected function recalculateBoundingBox(){
$width = 0.375;
return new AxisAlignedBB(
$this->x + ($this->canConnect($this->getSide(Vector3::SIDE_WEST)) ? 0 : $width),
$this->y,
$this->z + ($this->canConnect($this->getSide(Vector3::SIDE_NORTH)) ? 0 : $width),
$this->x + 1 - ($this->canConnect($this->getSide(Vector3::SIDE_EAST)) ? 0 : $width),
$this->y + 1.5,
$this->z + 1 - ($this->canConnect($this->getSide(Vector3::SIDE_SOUTH)) ? 0 : $width)
);
}
public function canConnect(Block $block){
return ($block instanceof NetherBrickFence) or ($block->isSolid() and !$block->isTransparent());
return $block instanceof NetherBrickFence or $block instanceof FenceGate or ($block->isSolid() and !$block->isTransparent());
}
public function getDrops(Item $item) : array{
@ -57,6 +72,4 @@ class NetherBrickFence extends Transparent{
return [];
}
//TODO: fix bounding boxes
}