Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Random particles in radius?

Comments in 'Plugin Development' started by PaulchenHD, Oct 22, 2016.

  1. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    I like to know how to spawn random particles in a radius like 1 block and 2 blocks high.
    [​IMG]
    like this ? ;)
  2. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    use
    PHP:
    rand($num1,$num2)
  3. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Is that Riventus?
  4. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    haha yes :D
    HimbeersaftLP likes this.
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    PHP:
    $x 120;
    $z 120;


    $this->getServer()->addParticle(new <name>Particle(new Vector3($x+(mt_rand(0100) / 100), $y+(mt_rand(0100) /100), $z+(mt_rand(0100) / 100))));
    Last edited: Oct 24, 2016
    HimbeersaftLP and PaulchenHD like this.
  6. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    thank you :) but your code was a little bit wrong "$this->getServer()->addParticle" :3
  7. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Use this function.
    PHP:
    public function randomParticlesWithinRadius($player$radius 2$amount 20){
    for(
    $i 0$i <= $amount; ++$i){
    $pos $player->getPosition();
    $pos->mt_rand($pos->$radius$pos->$radius);
    $pos->mt_rand($pos->$radius$pos->$radius);
    $pos->mt_rand($pos->$radius$pos->$radius);
    $player->level->addParticle(new ParticleName(new Vector3($pos->x$pos->y$pos->z));
    }
    }

    //Usage

    $radius 4;//blocks of radius
    $amount 20;//amount of particles to spawn

    $class->randomParticlesWithinRadius($playerObject$radius$amount);

    HimbeersaftLP likes this.
  8. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Oh I see
    HimbeersaftLP likes this.

Share This Page

Advertisement