From c501c740a11c0b3f19c9caec0222efb9e88799c2 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 23 Sep 2018 17:05:03 +0100 Subject: [PATCH] Get rid of Block->canPassThrough() This is only implemented in 1 place where the collision box should just be zero anyway, so there's no point this existing. There's a lot of other blocks which should have bounding boxes without collision boxes as well, but that's outside the scope of this commit. --- src/pocketmine/block/Block.php | 4 ---- src/pocketmine/block/Vine.php | 8 ++++---- src/pocketmine/level/Level.php | 12 +++++------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 95973a8c2..35e868efc 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -413,10 +413,6 @@ class Block extends Position implements BlockIds, Metadatable{ return false; } - public function canPassThrough() : bool{ - return false; - } - /** * Returns whether entities can climb up this block. * @return bool diff --git a/src/pocketmine/block/Vine.php b/src/pocketmine/block/Vine.php index 1f0061157..fdfd7cb0c 100644 --- a/src/pocketmine/block/Vine.php +++ b/src/pocketmine/block/Vine.php @@ -78,10 +78,6 @@ class Vine extends Flowable{ return 0.2; } - public function canPassThrough() : bool{ - return true; - } - public function hasEntityCollision() : bool{ return true; } @@ -150,6 +146,10 @@ class Vine extends Flowable{ return new AxisAlignedBB($minX, $minY, $minZ, $maxX, 1, $maxZ); } + protected function recalculateCollisionBoxes() : array{ + return []; + } + public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ if(!$blockClicked->isSolid() or Facing::axis($face) === Facing::AXIS_Y){ return false; diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 571f14cef..8d4699965 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -1131,7 +1131,7 @@ class Level implements ChunkManager, Metadatable{ for($x = $minX; $x <= $maxX; ++$x){ for($y = $minY; $y <= $maxY; ++$y){ $block = $this->getBlockAt($x, $y, $z); - if(!$block->canPassThrough() and $block->collidesWithBB($bb)){ + if($block->collidesWithBB($bb)){ return [$block]; } } @@ -1142,7 +1142,7 @@ class Level implements ChunkManager, Metadatable{ for($x = $minX; $x <= $maxX; ++$x){ for($y = $minY; $y <= $maxY; ++$y){ $block = $this->getBlockAt($x, $y, $z); - if(!$block->canPassThrough() and $block->collidesWithBB($bb)){ + if($block->collidesWithBB($bb)){ $collides[] = $block; } } @@ -1193,11 +1193,9 @@ class Level implements ChunkManager, Metadatable{ for($x = $minX; $x <= $maxX; ++$x){ for($y = $minY; $y <= $maxY; ++$y){ $block = $this->getBlockAt($x, $y, $z); - if(!$block->canPassThrough()){ - foreach($block->getCollisionBoxes() as $blockBB){ - if($blockBB->intersectsWith($bb)){ - $collides[] = $blockBB; - } + foreach($block->getCollisionBoxes() as $blockBB){ + if($blockBB->intersectsWith($bb)){ + $collides[] = $blockBB; } } }