From 41780fd19529c1e955f0182e3aaf3242cc6bb13d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 3 Sep 2017 11:50:15 +0100 Subject: [PATCH] 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. --- src/pocketmine/level/Level.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index f8607c6cc..2019662f7 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -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 - } }