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

Solved Walking particles using PlayerMoveEvent

Discussion in 'Development' started by Saxavlax001, Nov 15, 2019.

  1. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    Guys,I saw many issues about particles don't work and owner (dktapps) said that its client side bug, but I see that on other events or tasks, particles work fine. Anyway, I tried to use three particles like AngryVillagerParticle (more examples on my codes) but when I walk on the world I want, I don't see any particle and I have passed all the checks I added like if I have permission or not. Can someone help and tell me what is wrong in my codes?I have registered the Particles Event and I have tried many things to make them work but no luck.
     
    Last edited: Nov 15, 2019
  2. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    PHP:
    <?php

    namespace gofightcore\cosmeticsthings;

    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerMoveEvent;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\level\particle\AngryVillagerParticle;
    use 
    pocketmine\level\particle\DustParticle;
    use 
    gofightcore\tasks\RainbowParticlesTask;
    use 
    pocketmine\level\particle\FloatingTextParticle;
    use 
    gofightcore\Main;

    Class 
    Particles implements Listener {

        
    /** @var Main */
        
    private $plugin;

        public function 
    __construct(Main $plugin)
        {
            
    $this->plugin $plugin;
        }
        public function 
    onPlayerMove(PlayerMoveEvent $ev){
        
    /**if($ev->getPlayer()->hasPermission("particles.walk.rainbow") == true){
           if($ev->getPlayer()->getLevel()->getName() == "GoSpawn"){
    $from = $ev->getFrom();
    $to = $ev->getTo();
    //$speed = $from->distance($to);
    $speed = abs($ev->getPlayer()->getMotion()->x) + abs($ev->getPlayer()->getMotion()->z);
    //$speed = $ev->getPlayer()->getMotion();
            if($speed->x > 0){
        $rainbowparticlestask = new RainbowParticlesTask($this->plugin, $ev->getPlayer());
        $rainbowparticleshandler = $this->plugin->getScheduler()->scheduleRepeatingTask($rainbowparticlestask, 5);
          } else {

              }
            }
         }*/
        
    if($ev->getPlayer()->hasPermission("particles.walk.floatingtext") == true){
        if(
    $ev->getPlayer()->getLevel()->getName() === "hypixel1"){
    $from $ev->getFrom();
    $to $ev->getTo();
    /**$speed = $from->distance($to);
    $speed = abs($ev->getPlayer()->getMotion()->x) + abs($ev->getPlayer()->getMotion()->z);*/
    $speed $ev->getPlayer()->getMotion();
           if(
    $speed->0){
    $x $ev->getPlayer()->getX();
    $y $ev->getPlayer()->getY();
    $z $ev->getPlayer()->getZ();

    $red = new FloatingTextParticle(new Vector3($x$y 2.5), "§c+");
    $orange = new FloatingTextParticle(new Vector3($x$y 2.1), "§6+");
    $yellow = new FloatingTextParticle(new Vector3($x$y 1.7), "§e+");
    $green = new FloatingTextParticle(new Vector3($x$y 1.3), "§a+");
    $lblue = new FloatingTextParticle(new Vector3($x$y 0.9), "§b+");
    $dblue = new FloatingTextParticle(new Vector3($x$y 0.5), "§1+");

    foreach ([
    $red$orange$yellow$green$lblue$dblue] as $particle) {
           
    $ev->getPlayer()->getLevel()->addParticle($particle);
                 }
          } else {

              }
            }
         }

        if(
    $ev->getPlayer()->hasPermission("particles.walk.angryvillager") == true){
        if(
    $ev->getPlayer()->getLevel()->getName() === "hypixel1"){
    $from $ev->getFrom();
    $to $ev->getTo();
    /**$speed = $from->distance($to);
    $speed = abs($ev->getPlayer()->getMotion()->x) + abs($ev->getPlayer()->getMotion()->z);*/
    $speed $ev->getPlayer()->getMotion();
           if(
    $speed->0){
    $x $ev->getPlayer()->getX();
    $y $ev->getPlayer()->getY();
    $z $ev->getPlayer()->getZ();

    $particle = new AngryVillagerParticle(new Vector3($x$y 2.5));
           
    $ev->getPlayer()->getLevel()->addParticle($particle);
          } else {

              }
            }
         }
       }
     
    //end
     
    }
     
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    getMotion()->x can never be anything besides 0 as Player's getMotion() is not really implemented.
     
  4. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    Ok but even if I use the $speed = $from->distance($to); as $speed, particles won't work and there aren't any errors on my codes.
     
  5. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    In your code
    PHP:
    $particle = new AngryVillagerParticle(new Vector3($x$y 2.5));
    you are missing the z of the Vector3
    PHP:
    $particle = new AngryVillagerParticle(new Vector3($x$y 2.5,$z));
     
  6. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    Ok I did that now,but I still don't see any particles when I walk.
     
  7. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    Ah wait I'll change speed check again..
     
  8. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
  9. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    Ok nice it worked now thanks.
     
  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.