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.
This commit is contained in:
Dylan K. Taylor 2018-09-23 17:05:03 +01:00
parent 3eca64e893
commit c501c740a1
3 changed files with 9 additions and 15 deletions

View File

@ -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

View File

@ -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;

View File

@ -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,7 +1193,6 @@ 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;
@ -1202,7 +1201,6 @@ class Level implements ChunkManager, Metadatable{
}
}
}
}
if($entities){
foreach($this->getCollidingEntities($bb->expandedCopy(0.25, 0.25, 0.25), $entity) as $ent){