mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 15:05:33 +00:00
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:
parent
0b83c61494
commit
41780fd195
@ -1743,26 +1743,22 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
if($hand->isSolid() === true and $hand->getBoundingBox() !== null){
|
if($hand->isSolid() === true and $hand->getBoundingBox() !== null){
|
||||||
$entities = $this->getCollidingEntities($hand->getBoundingBox());
|
$entities = $this->getCollidingEntities($hand->getBoundingBox());
|
||||||
$realCount = 0;
|
|
||||||
foreach($entities as $e){
|
foreach($entities as $e){
|
||||||
if($e instanceof Arrow or $e instanceof DroppedItem){
|
if($e instanceof Arrow or $e instanceof DroppedItem){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
++$realCount;
|
|
||||||
|
return false; //Entity in block
|
||||||
}
|
}
|
||||||
|
|
||||||
if($player !== null){
|
if($player !== null){
|
||||||
if(($diff = $player->getNextPosition()->subtract($player->getPosition())) and $diff->lengthSquared() > 0.00001){
|
if(($diff = $player->getNextPosition()->subtract($player->getPosition())) and $diff->lengthSquared() > 0.00001){
|
||||||
$bb = $player->getBoundingBox()->getOffsetBoundingBox($diff->x, $diff->y, $diff->z);
|
$bb = $player->getBoundingBox()->getOffsetBoundingBox($diff->x, $diff->y, $diff->z);
|
||||||
if($hand->getBoundingBox()->intersectsWith($bb)){
|
if($hand->getBoundingBox()->intersectsWith($bb)){
|
||||||
++$realCount;
|
return false; //Inside player BB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($realCount > 0){
|
|
||||||
return false; //Entity in block
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user