public function addParticle(Particle $particle, array $players = null) { $pk = $particle->encode(); if ($players === null) { if ($pk !== null) { if (!is_array($pk)) { $this->addChunkPacket($particle->x >> 4, $particle->z >> 4, $pk); } else { foreach ($pk as $e) { $this->addChunkPacket($particle->x >> 4, $particle->z >> 4, $e); } } } } else { if ($pk !== null) { if (!is_array($pk)) { Server::broadcastPacket($players, $pk); } else { $this->server->batchPackets($players, $pk, false); } } } }
public static function addParticles(Level $level, $name, Position $pos1, $count = 5) { $xd = (double) 280; $yd = (double) 260; $zd = (double) 280; $particle1 = self::getParticle($name, $pos1, $xd, $yd, $zd, 0); $random = new Random((int) (\microtime(\true) * 1000) + \mt_rand()); for ($i = 0; $i < $count; ++$i) { $particle1->setComponents($pos1->x + $random->nextSignedFloat() * $xd, $pos1->y + $random->nextSignedFloat() * $yd, $pos1->z + $random->nextSignedFloat() * $zd); $level->addParticle($particle1); } }