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

I cannot find my error O.o

Discussion in 'Development' started by WreckagePE / ZAYD, Mar 29, 2017.

  1. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    Help me... when I try add particles there is no console error so what is wrong here?
    PHP:
    <?php

    namespace Particle\effects;

    use 
    pocketmine\level\particle\RedstoneParticle;

    /**
     * The redstone particle effect
     */
    class RedstoneParticleEffect implements ParticleEffect {

        
    /**
         * Run the particle effect
         *
         * @param  integer $currentTick The current tick
         * @param  Player $player       The player to fix the effect for
         * @param  array $showTo        The players to show the particle to
         * @return null
         */
        
    public function tick($currentTick$player$showTo) {
            if (
    $player->lastUpdate $currentTick 5) {

                
    $v M_PI 120 * ($n 120);
                
    $i M_PI 70 * ($n 70);
                
    $x cos($i);
                
    $y cos($v);
                
    $z sin($i);

                
    $player->getLevel()->addParticle(new RedstoneParticle($player->add($x$y, -$z)), $showTo);
                
    $player->getLevel()->addParticle(new RedstoneParticle($player->add(-$x$y$z)), $showTo);
            } else {
                
    $distance = -0.5 lcg_value();
                
    $yaw $player->yaw M_PI 180;
                
    $x $distance cos($yaw);
                
    $z $distance sin($yaw);
                
    $y lcg_value() * 0.4;
                
    $player->getLevel()->addParticle(new RedstoneParticle($player->add($x$y$z)), $showTo);
            }
        }

    }
     
  2. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    What happens in game when you try use them?
     
  3. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    It simply says 'Cannot give particles to <name>!'
     
  4. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    Or, when I configure someone to have that specific particles in config.yml they only get Portal ones, which is the ones that work... the lava, redstone + rainbow don't work for some reason?
     
  5. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    Some of them might not work, because they may not entirely implemented yet (although I'm not 100% sure). For instance, Redstone isn't implemented in PocketMine yet. Also, there is no "Rainbow" particle.
     
  6. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    Can you link the docs where it lists particles? I cant seem to find them on docs.pocketmine.net
     
  7. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
  8. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    @Sandertv are they all implemented? Because redstoneparticle.php is there... and thats what my issue is about lol
     
  9. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    The Cannot give particles to <player>, could I see your code that outputs that? I can only assume your code does that, as I've never seen that error before.
     
  10. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    PHP:
         Give a user particles
         
    *
         * @
    param  string $user     The username of the person to give particles
         
    * @param  string $particle The particle effect to give (The class name)
         * @return 
    boolean          Whether or not giving the particles was successful
         
    */
        public function 
    giveParticle($user ''$particle '') {
            if((
    $player $this->getServer()->getPlayerExact($user)) instanceof Player) {
                if(!isset(
    $this->particles[$player->getDisplayName()])) {
                    
    $name $this->getParticleClass($particle);
                    
    $this->particles[$player->getDisplayName()] = $this->manager->setPlayerParticleEffect($player$this->manager::$$name);
                    
    $this->players[$player->getDisplayName()] = get_class($this->particles[$player->getDisplayName()]);
                    return 
    true;
                }
            }
            return 
    false;
        }
    @Sandertv
     
  11. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    This code works... it doesn't put dust on the player, but it puts the portal particle;
    PHP:
    <?php

    namespace Particle\effects;

    use 
    pocketmine\level\particle\DustParticle;
    use 
    pocketmine\level\particle\PortalParticle;

    /**
     * The effect for the portal
     */
    class PortalParticleEffect implements ParticleEffect {

        
    /**
         * Run the particle effect
         *
         * @param  integer $currentTick The current tick
         * @param  Player $player       The player to fix the effect for
         * @param  array $showTo        The players to show the particle to
         * @return null
         */
        
    public function tick($currentTick$player$showTo) {
            
    $player->getLevel()->addParticle(new DustParticle($player->add(-0.5 lcg_value(), 1.5 lcg_value() / 2, -0.5 lcg_value()), 2550255), $showTo);
            
    $player->getLevel()->addParticle(new PortalParticle($player->add(-0.5 lcg_value(), 0.5 lcg_value(), -0.5 lcg_value())), $showTo);
        }

    }
     
  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.