1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Launching objects on count of blocks

Discussion in 'Development' started by Yexeed, Jan 19, 2018.

  1. Yexeed

    Yexeed Slime

    Messages:
    76
    Is there any way to use multiply() method on count of blocks?
    Sample code:
    PHP:
    //$p instanceof Player
    $nbt ExamplePlugin::getNBT($p);
    $level $p->getLevel();
    $bullet Entity::createEntity("Snowball"$level$nbt$p);
    $fdefault 0.5;
    $bullet->setMotion($bullet->getMotion()->multiply($fdefault));
    $bullet->spawnToAll();
    $p->getLevel()->addSound(new BlazeShootSound(new Vector3($p->x$p->y$p->z)));
    $p->getLevel()->addParticle(new FlameParticle(new Vector3($p->0.4$p->y$p->z)));
    So $fdefault should be count of blocks
     
    Last edited: Jan 19, 2018
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    so are you trying to aim a snowball so it lands on a planned location?
     
  3. Yexeed

    Yexeed Slime

    Messages:
    76
    no, i am trying that the snow flew e.g. 15 blocks
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Are you looking for the Vector3::normalize() method? It scales the vector to one block long, so multiplying it after normalizing will result in a vector of your desired length.
     
  5. Yexeed

    Yexeed Slime

    Messages:
    76
    Thanks alot!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.