Take a look at this, it might help you understand how coordinates work (in minecraft): http://minecraft.gamepedia.com/Coordinates
wtf? if the player is looking north his right side is a different direction, so you can't just assume it's x +1
You need to take into account that a player can turn around. This code only uses the position of a player, you need to use some trig to get a position that will always be right of the player.
I think something like this could do: PHP: public function spawnParticleAtRightSide(Player $player) { $radius = 2; // Set radius to 2 $x = sin(deg2rad($player->yaw + 90) * $radius) + $player->x; // Get yaw in degrees and add a quarter of 360 degrees to it and turn them to radians in order to use sin on it, multiply it with the radius and add it to the player X. $z = cos(deg2rad($player->yaw + 90) * $radius) + $player->z; // Same counts for $z, but use cos here instead $player->getLevel()->addParticle(new FlameParticle(new Vector3($x, $player->y + 1, $z))); // Add the particle on that location.} I haven't actually tried this code, but I think it works. Feel free to tell me if it doesn't.
The long post in this thread by @SOFe might help you understand what you need to do in order to achieve what you want.
What if I told you that my code works? Code: PHP: $p = $event->getPlayer();$yaw = $p->yaw;$right = $yaw + 180;$x = cos($right * M_PI / 180) * 2 + $p->x;$z = sin($right * M_PI / 180) * 2 + $p->z;$p->getLevel()->addParticle(new FlameParticle(new Vector3($x, $p->y, $z))); * 2 is for your requested range of 2.
I don't know if this is the best way. But this could work: PHP: $arr = array(1, 2, 3, 4, 5);foreach ($arr as $nr) {$level->addParticle(new FlameParticle(new Vector3($x, $y+$nr, $z)));}
You can use a for loop. PHP: for ($i = 1; $i <= 5; $i++) { $level->addParticle (new FlameParticle(new Vector3($x, $y + $i, $z)));}