Particle Shape

Discussion in 'Plugin Development' started by kangkyuchang, Feb 8, 2021.

Thread Status:
Not open for further replies.
  1. Offline

    kangkyuchang

    I want the particle shape to appear in front of me. However, I calculate x, y, z directly, so if I change the direction, there are no particles in front of me. Please help me.
    Code:
    for(double angle = 0; angle <= Math.PI; angle += 0.1) {
                   
                    double x = (1-t) * Math.sin(angle);
                    double y = (0.6-t)* Math.cos(angle);
                    double z = (1-t) * Math.cos(angle);
                    loc.add(x, y, z);
                    loc.getWorld().spawnParticle(org.bukkit.Particle.SMOKE_NORMAL, loc, 1, 0, 0, 0, 0);
                    loc.subtract(x, y, z);
                }
     
  2. Offline

    davidclue

    Maybe try to use NMS packets instead and if not then put a
    Code:
    Bukkit.getLogger().info(x+" "+y+" "+z);
    below your subtract and read where the particles are being spawned in the console.
     
  3. Offline

    Abstract97

    @davidclue Why on earth should he use NMS when there are appropriate methods in Bukkit to spawn particles?

    @kangkyuchang

    In order to display a particle effect in front of the player or where the player is looking, you will need to write a rotation function to rotate your coordinates about the origin (players location).

    Here is an article to help you get started - https://www.khanacademy.org/computi...ns/programming-3d-shapes/a/rotating-3d-shapes

    If you could explain what type of particle effect or shape you're trying to produce I can help you further on the matter.
     
  4. Offline

    davidclue

    Because bukkit has very few particles available with their method, if you want all of the particles then you use NMS like they literally are missing more than half of the particles in the game with their built-in method.
     
  5. Offline

    Abstract97

    @davidclue

    That depends what version the OP is using. I'm currently using the latest version (1.16.5) and you can access all of the available particles entirely by using the Bukkit API. Have a look in the Particle class (org.bukkit.Particle).

    [​IMG]

    These can be easily spawned by using world#spawnParticle(particle, x, y, z, count, radX, radY, radZ, extra, data);
     
  6. Offline

    davidclue

    I was unaware that they updated it, it seemed like they were never going to.
     
  7. Offline

    Abstract97

    No worries buddy! When I first tried to spawn a particle in 1.16 I was shocked that It's all in the API now and you don't need to use reflection anymore to do it.
     
  8. Offline

    davidclue

    Just a question do you know if player.spawnParticles() means it only shows for the specified player because there is a world.spawnParticles() but I just want to be sure.
     
  9. Offline

    Abstract97

    Yes, the JavaDocs don't tell us much in this case, however It would seem appropriate for Player#spawnParticle to display to the player only, and then World#spawnParticle for all players that are close by.
     
Thread Status:
Not open for further replies.

Share This Page