Made entity collision checks for block placement more logical and less wasteful

We don't care how many entities collide, only that a non-zero number collided.
This commit is contained in:
Dylan K. Taylor 2017-09-03 11:50:15 +01:00
parent 0b83c61494
commit 41780fd195

View File

@ -1743,26 +1743,22 @@ class Level implements ChunkManager, Metadatable{
if($hand->isSolid() === true and $hand->getBoundingBox() !== null){
$entities = $this->getCollidingEntities($hand->getBoundingBox());
$realCount = 0;
foreach($entities as $e){
if($e instanceof Arrow or $e instanceof DroppedItem){
continue;
}
++$realCount;
return false; //Entity in block
}
if($player !== null){
if(($diff = $player->getNextPosition()->subtract($player->getPosition())) and $diff->lengthSquared() > 0.00001){
$bb = $player->getBoundingBox()->getOffsetBoundingBox($diff->x, $diff->y, $diff->z);
if($hand->getBoundingBox()->intersectsWith($bb)){
++$realCount;
return false; //Inside player BB
}
}
}
if($realCount > 0){
return false; //Entity in block
}
}