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?
PHP: $bx = floor($block->x) > 0 ? floor($block->x) + 0.5 : floor($block->x) - 0.5; //Blocks x, y and z already come floored :P$bz = floor($block->z > 0) ? floor($block->z + 0.5) : floor($block->z - 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 (it may also lagg the client is he has bad phone)
Why is a task needed for this? Does the task make the particles repeat themselves? thankyou for the code though !
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
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.
You could add particles unimplemented in PMMP with a LevelEventPacket, but I suggest sticking with those that extend GenericParticle.