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

[Question] Color Particles

Discussion in 'Development' started by InspectorGadget, Mar 11, 2017.

  1. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Hi! I'm sure i'm breaking the rules of this section as i'm asking for a code. Sorry....

    I've attached an image and i want to know or get sample code on how do i do that?

    particle.png

    Any help would be appreciated!

    Thank you very much!
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    You can change the color of DustParticle, so use it :p
     
  3. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Can i have a link to the particles or sample code? I don't have any on my mind and i tried to refer Walking Particles but the plugin doesnt even exist on GitHub.
     
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Link to walking particles: (or UltimateParticles as it got called later) https://github.com/hoyinm14mc/UltimateParticles
    Link to the particle: https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/level/particle/DustParticle.php
    As you can see in the constructor you need a red, blue and green value for dust particles. That is what you're after.
     
  5. xBeastMode

    xBeastMode Shog Chips

    Messages:
    0
    Try this, I am unsure that it will work since I wrote it on my phone. =P
    PHP:
    $colours = [
    [
    255255255],
    [
    255255255]
    ];
    $colourCount count($colours);

    $height 1;//height in blocks
    $length 3;//length in blocks

    $step 0;

    $hpc = ($height count($colours));//height per colour

    for($yy 0yy <= $height$yy +=  $hpc){
      for(
    $zz 0$zz <= $length; ++$zz){
      
    $pos = clone $somePlayer->getPosition ();
      
    $pos->+= $yy;
      
    $pos->+= $zz;
      if(
    $step $colourCount){
         
    $step 0;
      }
      
    $somePlayer->level->addParticle(new \pocketmine\level\particle\DustParticle($pos$colours[$step][0], $colours[$step][1], $colours[$step][2]));
    }
    }
     
  6. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Colour codes from this website.
    Format: new DustParticle(Vector3, r, g, b)

    Probably the worst way, but ye..
    PHP:
    /** @var Level $level */
    /** @var Vector3 $pos */
    $red = new DustParticle($pos->add(02.5), 2521717);
    $orange = new DustParticle($pos->add(02.1), 25213517);
    $yellow = new DustParticle($pos->add(01.7), 25225217);
    $green = new DustParticle($pos->add(01.3), 1725217);
    $lblue = new DustParticle($pos->add(00.9), 9494252);
    $dblue = new DustParticle($pos->add(00.5), 1717252);

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

     
    InspectorGadget likes this.
  7. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    i think you need to add them using a repeated task
    note there a difference between asking for code OR asking for a direction to be pointed toward
     
  8. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    I know only this
    upload_2017-3-12_14-45-4.png
     
  9. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    @Muqsit

    How do i make the particles go higher and become more visible?

    PHP:
    <?php

    /* 
     * Copyright (C) 2017 RTG
     *
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     */

    namespace RTG\SP;

    /* Essentials */
    use pocketmine\plugin\PluginBase;

    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\level\particle\DustParticle;
    use 
    pocketmine\level\particle\FlameParticle;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\event\Listener;

    class 
    Loader extends PluginBase implements Listener {
       
        public 
    $list;
       
        public function 
    onEnable() {
           
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->list = array();
            
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new SPTask($this), 5);
           
        }
       
        public function 
    onParticles(Player $p) {
           
            if(isset(
    $this->list[strtolower($p->getName())])) {
               
           
                
    $x $p->getX();
                
    $y $p->getY();
                
    $z $p->getZ();
                   
                    
    $red = new DustParticle(new Vector3($x$y$z), 2521717);
                    
    $green = new DustParticle(new Vector3($x$y$z), 102153102);
                    
    $flame = new FlameParticle(new Vector3($x$y$z));
                    
    $level $p->getLevel();
                   
                    foreach([
    $red$green$flame] as $particle) {
                       
                        
    $level->addParticle($particle);
                       
                    }
                   
            }
           
        }
       
        public function 
    onCommand(\pocketmine\command\CommandSender $sender, \pocketmine\command\Command $command$label, array $args) {
           
            switch(
    strtolower($command->getName())) {
               
                case 
    "sp":
                   
                    if(
    $sender->hasPermission("sp.spawn")) {
                       
                        if(isset(
    $args[0])) {
                           
                            switch(
    strtolower($args[0])) {
                               
                                case 
    "enable":
                                   
                                    if(isset(
    $this->list[strtolower($sender->getName())])) {
                                       
                                        unset(
    $this->list[strtolower($sender->getName())]);
                                        
    $sender->sendMessage("SP Disabled!");
                                         
                                    }
                                    else {
                                       
                                        
    $this->list[strtolower($sender->getName())] = strtolower($sender->getName());
                                        
    $sender->sendMessage("SP Enabled!");
                                       
                                       
                                    }
                                   
                            }
                             
                        }
                         
                    }
                   
            }
           
        }
       
        public function 
    onDisable() {
        }
       
    }
     
  10. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    PHP:
    $pos $player->getPosition();

    $red = new DustParticle($pos->add(02.5), 2521717);
    $orange = new DustParticle($pos->add(02.1), 25213517);
    $yellow = new DustParticle($pos->add(01.7), 25225217);
    $green = new DustParticle($pos->add(01.3), 1725217);
    $lblue = new DustParticle($pos->add(00.9), 9494252);
    $dblue = new DustParticle($pos->add(00.5), 1717252);

    foreach ([
    $red$orange$yellow$green$lblue$dblue] as $particle) {
        
    $pos->getLevel()->addParticle($particle);
    }
     
    SavionLegendZzz likes this.
  11. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Works,Thanks
     
  12. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
    It doesn't work
    [Server] [11:35:55] [Server thread/CRITICAL]: ParseError: "syntax error, unexpected '.5' (T_DNUMBER), expecting ',' or ')'" (EXCEPTION) in "/Core (1)/src/StuckDexter/Core" at line 3405
    [Server] [11:35:55] [Server thread/EMERGENCY]: An unrecoverable error has occurred and the server has crashed. Creating a crash dump
    [Server] [11:35:55] [Server thread/EMERGENCY]: Please upload the "/storage/emulated/0/PocketMine/crashdumps/Sat_Apr_22-11.35.55-UTC_2017.log" file to the Crash Archive and submit the link to the Bug Reporting page. Give as much info as you can.
     
  13. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    :facepalm: Lear statements on htpp://php.net
     
    RicardoMilos384 likes 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.