pocketmine\entity\Entity::canCollideWith PHP Method

canCollideWith() public method

public canCollideWith ( Entity $entity )
$entity Entity
    public function canCollideWith(Entity $entity)
    {
        return !$this->justCreated and $entity !== $this;
    }

Usage Example

Example #1
0
 /**
  * Returns the entities colliding the current one inside the AxisAlignedBB
  *
  * @param AxisAlignedBB $bb
  * @param Entity        $entity
  *
  * @return Entity[]
  */
 public function getCollidingEntities(AxisAlignedBB $bb, Entity $entity = null)
 {
     $nearby = [];
     if ($entity === null or $entity->canCollide) {
         $minX = Math::floorFloat(($bb->minX - 2) / 16);
         $maxX = Math::floorFloat(($bb->maxX + 2) / 16);
         $minZ = Math::floorFloat(($bb->minZ - 2) / 16);
         $maxZ = Math::floorFloat(($bb->maxZ + 2) / 16);
         for ($x = $minX; $x <= $maxX; ++$x) {
             for ($z = $minZ; $z <= $maxZ; ++$z) {
                 foreach (($______chunk = $this->getChunk($x, $z)) !== null ? $______chunk->getEntities() : [] as $ent) {
                     if ($ent !== $entity and ($entity === null or $entity->canCollideWith($ent)) and $ent->boundingBox->intersectsWith($bb)) {
                         $nearby[] = $ent;
                     }
                 }
             }
         }
     }
     return $nearby;
 }
All Usage Examples Of pocketmine\entity\Entity::canCollideWith