mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
World: avoid code duplication between getCollidingEntities() and getNearbyEntities()
these two methods are very misleadingly named, but they do almost exactly the same thing - the only difference is that getCollidingEntities() does a couple of additional checks.
This commit is contained in:
parent
d4d00a9b80
commit
19513c65f0
@ -1882,22 +1882,9 @@ class World implements ChunkManager{
|
||||
$nearby = [];
|
||||
|
||||
if($entity === null or $entity->canCollide){
|
||||
$minX = ((int) floor($bb->minX - 2)) >> 4;
|
||||
$maxX = ((int) floor($bb->maxX + 2)) >> 4;
|
||||
$minZ = ((int) floor($bb->minZ - 2)) >> 4;
|
||||
$maxZ = ((int) floor($bb->maxZ + 2)) >> 4;
|
||||
|
||||
for($x = $minX; $x <= $maxX; ++$x){
|
||||
for($z = $minZ; $z <= $maxZ; ++$z){
|
||||
if(!$this->isChunkLoaded($x, $z)){
|
||||
continue;
|
||||
}
|
||||
foreach($this->getChunk($x, $z)->getEntities() as $ent){
|
||||
/** @var Entity|null $entity */
|
||||
if($ent->canBeCollidedWith() and ($entity === null or ($ent !== $entity and $entity->canCollideWith($ent))) and $ent->boundingBox->intersectsWith($bb)){
|
||||
$nearby[] = $ent;
|
||||
}
|
||||
}
|
||||
foreach($this->getNearbyEntities($bb, $entity) as $ent){
|
||||
if($ent->canBeCollidedWith() and ($entity === null or $entity->canCollideWith($ent))){
|
||||
$nearby[] = $ent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user