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

Adding fire particles on an entity

Discussion in 'Help' started by MalakasPlayzMCPE, May 18, 2018.

  1. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    I am throwing a snowball and I want to spawn flame particles on the entity. My idea is a task that you foreach all the entities of a world and you check if the entity is a snowball. Then you spawn the particle in the position of the snowball entity. My question is: how to get all the entities of a world? Will my idea work?
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    you can just overwrite the entity you fire out
    there's an onupdate function on the entity which you can place particles
    which is way better than a task
     
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Level->getEntities() but why do you want to get all the entities of the world?
     
  4. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    To foreach them and check if there is a snowball so I can spawn the flame particles.
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Well, in that case I'd say you go with @Thunder33345's approach. Register a custom snowball entity that overrides and extends PocketMine's snowball entity class, then extend the onUpdate() method.
     
  6. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Ok, that's what my friend used:
    PHP:
    <?php

    namespace BattleGround\Arena;

    use 
    BattleGround\BattleGround;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\Server;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\level\particle\FlameParticle;
    use 
    pocketmine\entity\Snowball;
    use 
    pocketmine\math\Vector3;

    class 
    FlameParticles extends PluginTask {

        public function 
    __construct(BattleGround $plugin) {
            
    $this->plugin $plugin;
            
    parent::__construct($plugin);
        }

        public function 
    onRun($tick) {
            foreach(
    $this->plugin->getServer()->getLevels() as $level) {
                foreach (
    glob($this->plugin->getDataFolder() . "arenas/*.yml") as $file) {
                    
    $arena = new Config($fileConfig::YAML);
                    
    $fname $arena->get("arena_name");
                    if(
    $level->getFolderName() == $fname) {
                        foreach(
    $this->plugin->getServer()->getEntities() as $entity) {
                            if(
    $entity instanceof Snowball){
                                
    $level->addParticle(new FlameParticle(new Vector3($entity->x$entity->y$entity->z)));
                            }
                        }
                    }
                }
            }
        }
    }
     
  7. Primus

    Primus Zombie Pigman

    Messages:
    749
    Awful
     
    Muqsit, EdwardHamHam and Sandertv like this.
  8. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    That's tedious and unnecessary. Just use @Thunder33345's method
     
    Primus and Thunder33345 like this.
  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.