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

create particles around a Block

Discussion in 'Development' started by WreckagePE / ZAYD, Apr 27, 2017.

  1. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    I want to create a plugin which adds particles around a block.

    for example the player executes /blockparticles add

    a message is sent to the player saying the next block they touch will have particles around it.

    how can I create the particle bit?
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    using a task probably your best bet
     
  3. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    i am asking how to create the particles around the block though xd
     
  4. Aviv

    Aviv Baby Zombie

    Messages:
    156
    PHP:
    $bx floor($block->x) > floor($block->x) + 0.5 floor($block->x) - 0.5//Blocks x, y and z already come floored :P
    $bz floor($block->0) ? floor($block->0.5) : floor($block->0.5);
    for(
    $y floor($block->y);$y <= floor($block->y) + 1;$y += 0.1){
      for(
    $x $bx 0.5;$x $bx 0.5;$x += 0.1){
        
    $block->getLevel()->addParticle(new FlameParticle(new Vector3($x$y$bz 0.5)), $this->getServer()->getOnlinePlayers());
        
    $block->getLevel()->addParticle(new FlameParticle(new Vector3($x$y$bz 0.5)), $this->getServer()->getOnlinePlayers());
      }
      for(
    $z $bz 0.5;$z $bz 0.5;$z += 0.1){
        
    $block->getLevel()->addParticle(new FlameParticle(new Vector3($bx 0.5$y$z)), $this->getServer()->getOnlinePlayers());
        
    $block->getLevel()->addParticle(new FlameParticle(new Vector3($bx 0.5$y$z)), $this->getServer()->getOnlinePlayers());
      }
      if(
    $y === floor($block->y) or $y === floor($block->y) + 1){
        for(
    $x $bx 0.5;$x $bx 0.5;$x += 0.1){
          for(
    $z $bz 0.5;$z $bz 0.5;$z += 0.1){
            
    $block->getLevel()->addParticle(new FlameParticle(new Vector3($x$y$z)), $this->getServer()->getOnlinePlayers());
          }
        }
      }
    }
    Its a bad and kinda slow code, i know
    Dont use this code if you dont have to :p
    (it may also lagg the client is he has bad phone)
     
  5. Aviv

    Aviv Baby Zombie

    Messages:
    156
    PS: if you are using a task, set it to at least 20 ticks
     
    WreckagePE / ZAYD likes this.
  6. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    Why is a task needed for this? Does the task make the particles repeat themselves?

    thankyou for the code though !
     
  7. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Unless you want the particles to despawn quickly, you can use a task to make them respawn as needed.
     
  8. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    Ahh. Thanks. However he put in his code new FlameParticle.. so does this mean I have to create a class with the flame particle ?
    if so , how
     
  9. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    No, pocketmine\level\particle\FlameParticle is an existing class in PocketMine. You never specified what type of particle you wanted to spawn around the block.
     
  10. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    ok. I can only spawn particles implemented in PMMP anyway, right?
     
  11. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    You could add particles unimplemented in PMMP with a LevelEventPacket, but I suggest sticking with those that extend GenericParticle.
     
    OnTheVerge and WreckagePE / ZAYD 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.