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

Help please :c

Comments in 'Plugin Development' started by KekerFamily, Jan 10, 2016.

  1. KekerFamily
    Offline

    KekerFamily New Member

    Joined:
    Nov 12, 2015
    Posts:
    12
    Minecraft User:
    Keker
    Code is not work, help please

    public function onMove(EntityMoveEvent $event){
    $entity = $event->getEntity();
    if($entity instanceof Snowball){
    $x = $entity->getX();
    $y = $entity->getY();
    $z = $entity->getZ();
    $level = $entity->getLevel();
    $level->addParticle
    (new FlameParticle(new Vector3($x, $y, $z)));
  2. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Use ProjectileLaunchEvent.
    And PlayerMoveEvent does not have a getEntity() function.
  3. KekerFamily
    Offline

    KekerFamily New Member

    Joined:
    Nov 12, 2015
    Posts:
    12
    Minecraft User:
    Keker
    You do not understand, I want to do when flying Particle
    ProjectileLaunch spawn 1 particle
  4. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Then schedule a repeating task to keep the particles spawning. Or use EntityMoveEvent.
    You cannot do this with the PlayerMoveEvent. Snowball is an entity not a player.
  5. KekerFamily
    Offline

    KekerFamily New Member

    Joined:
    Nov 12, 2015
    Posts:
    12
    Minecraft User:
    Keker
    :/, i
    I'm use EntityMoveEvent, but code don't work
  6. KubixQ
    Offline

    KubixQ Active Member

    Joined:
    Sep 13, 2015
    Posts:
    85
    Minecraft User:
    KubixQ
    Use
    Code:
    [PHP]#YourCode [/PHP]
    EvolSoft and AndrewBit like this.
  7. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Use ProjectileLaunchEvent and a repeating task to spawn the particles. Also, post your code.
  8. KekerFamily
    Offline

    KekerFamily New Member

    Joined:
    Nov 12, 2015
    Posts:
    12
    Minecraft User:
    Keker
    Can you give an example please?
    I can't... ;
    public function onHit(ProjectileLaunchEvent $event){
    $entity = $event->getEntity();
    if($entity instanceof Snowball){
    $x = $entity->getX();
    $y = $entity->getY();
    $z = $entity->getZ();
    $level = $entity->getLevel();
    $level->addParticle(new FlameParticle(new Vector3($x, $y, $z)));
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new CallbackTask(array($this, "Repeat")), 10);
    $this->timer = 0;
    }
    }
    public function Repeat(){
    $entity = $event->getEntity();
    if($entity instanceof Snowball){
    $x = $entity->getX();
    $y = $entity->getY();
    $z = $entity->getZ();
    $level = $entity->getLevel();
    $level->addParticle(new FlameParticle(new Vector3($x, $y, $z)));
    }
    }
    }
  9. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Learn how to use tasks here:
    http://forums.pocketmine.net/threads/how-to-use-schedules-in-a-plugin.4796/


    Btw, if I remember correctly, CallBackTask is deprecated.
    iDirtPlayzMC and Vaivez66 like this.

Share This Page

Advertisement