pocketmine\entity\Entity::close PHP Method

close() public method

public close ( )
    public function close()
    {
        if (!$this->closed) {
            $this->server->getPluginManager()->callEvent(new EntityDespawnEvent($this));
            $this->closed = true;
            $this->removeEffect(Effect::HEALTH_BOOST);
            $this->despawnFromAll();
            if ($this->linkedType != 0) {
                $this->linkedEntity->setLinked(0, $this);
            }
            if ($this->chunk !== null) {
                $this->chunk->removeEntity($this);
            }
            if ($this->level !== null) {
                $this->level->removeEntity($this);
            }
        }
        if ($this->getLevel()->getServer()->redstoneEnabled) {
            /** @var \pocketmine\block\PressurePlate $block * */
            foreach ($this->activatedPressurePlates as $key => $block) {
                $block->checkActivation();
            }
        }
        $this->activatedPressurePlates = [];
        if ($this->attributeMap != null) {
            $this->attributeMap = null;
        }
    }

Usage Example

Example #1
0
 public function onRun($currentTick)
 {
     $explosion = new Explosion(new Position($this->entity->getX(), $this->entity->getY(), $this->entity->getZ(), $this->entity->getLevel()), $this->radius);
     if (!$this->entity->isAlive()) {
         return;
     }
     $this->entity->close();
     if ($explosion->explodeA()) {
         $explosion->explodeB();
     }
 }
All Usage Examples Of pocketmine\entity\Entity::close