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

Solved Rendering particles

Discussion in 'Development' started by GamakCZ, Jan 22, 2020.

  1. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Hello there, I'm trying to generate objects from particles.

    I've tried this code to generate circle:
    PHP:
    /**
    * @param int|float $radius
    * @param int|float $spacing (%)
    *
    * @return \Generator
    */
    public function generateCircle($radius$spacing 1): \Generator {
        
    $last null;
        for(
    $i 0$i 360$i += (3.6 $spacing)) {
            
    $x $radius sin(deg2rad($i));
            
    $z $radius cos(deg2rad($i));

            yield [
    $x$z];
        }
    }

    generateCircele(1.64);
    Then I put it to repeating task with delay 40 ticks.
    I've got this result.

    [​IMG]

    However when I shorened the delay to 1 tick, I've got incoplete circle.
    [​IMG]

    Is there any way to fix it?
     
    Last edited: Jan 22, 2020
  2. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    It seems as if client allows to spawn just few particles at once..
     
    Fadhel likes this.
  3. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    are you batching the packets or are you sending them individually?
     
  4. DaPigGuy

    DaPigGuy Slime

    Messages:
    86
    GitHub:
    DaPigGuy
    Happened with PiggyCE's forcefield enchant also. Switching to a different particle resolved the issue
     
    GamakCZ likes this.
  5. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Which particles have you used?
     
  6. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    PHP:
    foreach(generateCircle() as $particle) {
       
    Player->getLevel()->addParticle($particle);
    }
    I'm using pmmp api

    PHP:
    public function addParticle(Particle $particle, array $players null){
            
    $pk $particle->encode();
            if(!
    is_array($pk)){
                
    $pk = [$pk];
            }
            if(
    count($pk) > 0){
                if(
    $players === null){
                    foreach(
    $pk as $e){
                        
    $this->broadcastPacketToViewers($particle$e);
                    }
                }else{
                    
    $this->server->batchPackets($players$pkfalse);
                }
            }
        }
     
  7. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    With critical particles it works..
     
  8. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    But I tried both ways
     
  9. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Fixed by using SpawnParticleEffectPacket instead of LevelEventPacket
     
  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.