I can use if i want player die? PHP: if($player->asPosition()->equals($particle->asPosition()));$player->setHealt(0);
It is very unlikely Position->equals(Position) will return true, as it has to be precisely the same position (float precisely). You could first round the Vector3 to even make it possible for this to work.
PHP: public function onIneract(PlayerInteractEvent $ev) { $player = $ev->getPlayer(); if ($ev->getItem()->getId() === 369) { $directonVector = $player->getDirectionVector(); for ($i = 3; $i < 20; $i++) { $pos = $directonVector->multiply($i)->add($player); if ($player->getLevel()->getBlockIdAt($pos->x, $pos->y, $pos->z) !== 0) { return; } $particle = new DustParticle($pos, 0, 0, 0); $player->getLevel()->addParticle($particle); foreach ($player->getLevel()->getEntities() as $ent) { if ($ent === $player) { continue; } if (!isset($temp)) { $temp = $ent; }else{ if ($ent->distance($pos) < $temp->distance($pos)) { $temp = $ent; } } } if (!isset($temp)){ }elseif ($temp->distance($pos) < 2) { for ($a=4; $a<5; $a++) { $par = new FlameParticle($pos); $par->setComponents( $pos->x + (self::random() * 2 - 1) * 3, $pos->y + 0.3, $pos->z + (self::random() * 2 - 1) * 3 ); $player->getLevel()->addParticle($par); if($player->asPosition()->equals($particle->asPosition())){ $player->kill(); } } return; } } } } }
You can't move a particle in Bedrock Edition, nor can you listen to any packets that hold particles' position. But you can do assumption physics and figure out the position of a moving particle. Particle->asVector3() or Particle->asPosition() will return the initial position of the particle. The position doesn't update like it does in entities. Because unlike entities, position of particles cannot be found through packets.
As I previously mentioned, checking for equality without rounding the 2 vectors is not going to work out for you.