nextSignedFloat() публичный Метод

Returns a float between -1.0 and 1.0 (inclusive)
public nextSignedFloat ( ) : float
Результат float
Пример #1
0
 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     if (count($args) < 7) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return true;
     }
     if ($sender instanceof Player) {
         $level = $sender->getLevel();
     } else {
         $level = $sender->getServer()->getDefaultLevel();
     }
     $name = strtolower($args[0]);
     $pos = new Vector3((double) $args[1], (double) $args[2], (double) $args[3]);
     $xd = (double) $args[4];
     $yd = (double) $args[5];
     $zd = (double) $args[6];
     $count = isset($args[7]) ? max(1, (int) $args[7]) : 1;
     $data = isset($args[8]) ? (int) $args[8] : null;
     $particle = $this->getParticle($name, $pos, $xd, $yd, $zd, $data);
     if ($particle === null) {
         $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.particle.notFound", [$name]));
         return true;
     }
     $sender->sendMessage(new TranslationContainer("commands.particle.success", [$name, $count]));
     $random = new Random((int) (microtime(true) * 1000) + mt_rand());
     for ($i = 0; $i < $count; ++$i) {
         $particle->setComponents($pos->x + $random->nextSignedFloat() * $xd, $pos->y + $random->nextSignedFloat() * $yd, $pos->z + $random->nextSignedFloat() * $zd);
         $level->addParticle($particle);
     }
     return true;
 }
Пример #2
0
 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return \true;
     }
     if (\count($args) < 7) {
         return \true;
     }
     if ($sender instanceof Player) {
         $level = $sender->getLevel();
     } else {
         $level = $sender->getServer()->getDefaultLevel();
     }
     $name = \strtolower($args[0]);
     $pos = new Vector3((double) $args[1], (double) $args[2], (double) $args[3]);
     $xd = (double) $args[4];
     $yd = (double) $args[5];
     $zd = (double) $args[6];
     $count = isset($args[7]) ? \max(1, (int) $args[7]) : 1;
     $data = isset($args[8]) ? (int) $args[8] : \null;
     $particle = $this->getParticle($name, $pos, $xd, $yd, $zd, $data);
     if ($particle === \null) {
         return \true;
     }
     $random = new Random((int) (\microtime(\true) * 1000) + \mt_rand());
     for ($i = 0; $i < $count; ++$i) {
         $particle->setComponents($pos->x + $random->nextSignedFloat() * $xd, $pos->y + $random->nextSignedFloat() * $yd, $pos->z + $random->nextSignedFloat() * $zd);
         $level->addParticle($particle);
     }
     return \true;
 }
Пример #3
0
 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);
     }
 }
Пример #4
0
 public function grantCoins($coins, $ignoreGrind = false, $effects = true)
 {
     if (!$ignoreGrind and $this->isGrinding()) {
         $coins *= Settings::getGrindFactor($this->getRank());
     }
     if ($effects) {
         $this->getPlayer()->getLevel()->addSound(new FizzSound($this->getPlayer()), [$this->getPlayer()]);
         $random = new Random(time() + $coins);
         $player = $this->getPlayer();
         $particle = new TerrainParticle($player, Block::get(Block::GOLD_BLOCK));
         $level = $player->getLevel();
         $recipients = [$player];
         for ($i = 0; $i < 50; $i++) {
             $x = $random->nextSignedFloat();
             $y = $random->nextSignedFloat() * $player->eyeHeight / 2;
             $z = $random->nextSignedFloat();
             $particle->setComponents($player->x + $x, $player->y + $player->eyeHeight / 2 + $y, $player->z + $z);
             $level->addParticle($particle, $recipients);
         }
     }
     $this->setCoins($out = $this->getCoins() + $coins);
     return [$coins, $out];
 }
Пример #5
0
 public static function addParticles(Level $level, $name, Position $pos1, $count = 5)
 {
     // $pos = new Vector3((float) $args[1], (float) $args[2], (float) $args[3]);
     $xd = (double) 380;
     $yd = (double) 360;
     $zd = (double) 380;
     // $count = 8;
     // $data = isset($args[8]) ? (int) $args[8] : \null;
     // $pos = new Vector3((float) $args[1], (float) $args[2], (float) $args[3]);
     $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);
     }
 }
Пример #6
0
 public function grantCoins($coins, $ignoreGrind = false, $effects = true, $bonus = true)
 {
     if (!$ignoreGrind and $this->isGrinding()) {
         $coins *= Settings::getGrindFactor($this->getRank());
     }
     if ($effects) {
         $this->getPlayer()->getLevel()->addSound(new FizzSound($this->getPlayer()), [$this->getPlayer()]);
         $random = new Random(time() + $coins);
         $player = $this->getPlayer();
         $particle = new TerrainParticle($player, Block::get(Block::GOLD_BLOCK));
         $level = $player->getLevel();
         $recipients = [$player];
         for ($i = 0; $i < 500; $i++) {
             $x = $random->nextSignedFloat();
             $y = $random->nextSignedFloat();
             $z = $random->nextSignedFloat();
             $particle->setComponents($player->x + $x, $player->y + $y, $player->z + $z);
             $level->addParticle($particle, $recipients);
         }
     }
     $this->setCoins($out = $this->getCoins() + $coins);
     if ($bonus) {
         if (mt_rand(0, 99) === 0) {
             $add = mt_rand(25, 50);
         } elseif (mt_rand(0, 499) === 0) {
             $add = mt_rand(150, 300);
         } elseif (mt_rand(0, 749) === 0) {
             $add = mt_rand(300, 500);
         }
         if (isset($add)) {
             $this->grantCoins($add, false, true, false);
         }
     }
     return [$coins, $out];
 }
Пример #7
0
 public function displaySmoke(Position $pos)
 {
     //particle smoke 120 71 124 1 1 1 35 200
     $random = new Random((int) (microtime(true) * 1000) + mt_rand());
     $particle = new SmokeParticle(new Vector3($pos->x, $pos->y + 0.7, $pos->z), 200);
     for ($i = 0; $i < 35; ++$i) {
         $particle->setComponents($pos->x + $random->nextSignedFloat(), $pos->y + $random->nextSignedFloat(), $pos->z + $random->nextSignedFloat());
         $pos->getLevel()->addParticle($particle);
     }
 }