mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 12:04:46 +00:00
Fixed getting Entities by area
This commit is contained in:
@@ -591,37 +591,6 @@ abstract class Entity extends Position implements Metadatable{
|
||||
$this->fallDistance = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the entities near the current one inside the AxisAlignedBB
|
||||
*
|
||||
* @param AxisAlignedBB $bb
|
||||
*
|
||||
* @return Entity[]
|
||||
*/
|
||||
public function getNearbyEntities(AxisAlignedBB $bb){
|
||||
|
||||
$nearby = [];
|
||||
|
||||
$minX = ($bb->minX - 2) >> 4;
|
||||
$maxX = ($bb->maxX + 2) >> 4;
|
||||
$minZ = ($bb->minZ - 2) >> 4;
|
||||
$maxZ = ($bb->maxZ + 2) >> 4;
|
||||
|
||||
for($x = $minX; $x <= $maxX; ++$x){
|
||||
for($z = $minZ; $z <= $maxZ; ++$z){
|
||||
if($this->getLevel()->isChunkLoaded($x, $z)){
|
||||
foreach($this->getLevel()->getChunkEntities($x, $z) as $ent){
|
||||
if($ent !== $this and $ent->boundingBox->intersectsWith($this->boundingBox)){
|
||||
$nearby[] = $ent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $nearby;
|
||||
}
|
||||
|
||||
public function move($dx, $dy, $dz){
|
||||
//$collision = [];
|
||||
//$this->checkBlockCollision($collision);
|
||||
|
Reference in New Issue
Block a user