Solved Creating a circle around a location without packets/libs?

Discussion in 'Spigot Plugin Development' started by danablend, May 14, 2016.

  1. I have tried doing following thing but I think im messing with the offsets because when i play the effect it splatters everywhere around the location instead of in the circle i want. This is my current code:
    Code (Text):
        public void createCircle(Location loc) {
            int radius = 1;
            for (double y = 0; y <= 50; y += 0.5) {
                double x = radius * Math.cos(y);
                double z = radius * Math.sin(y);
                Location circle = new Location(loc.getWorld(), (float) (loc.getX() + x) + 0.5f, (float) loc.getY() + 0.3f, (float) (loc.getZ() + z) + 0.5f);
                loc.getWorld().spigot().playEffect(circle, Effect.FLAME, 1, 1, 0f, 0f, 0f, 1, 50, 1);
            }
        }
    Note that I have done this with packets and it worked, so the formular is working and all. Reason for me not sticking to packets is because its causing massive lags on servers.
     
  2. Bump, still not resolved.
     
  3. try World#spawnParticle() instead.

    EDIT: Also, to create a full circle, don't use your current for-loop. Use
    Code (Java):

    /* increase 10 for a smaller space between the particles */
    for (double a = 0; a < Math.PI * 2; a += Math.PI / 10) {
       // ...
    }
     
     
  4. @finnbon Thanks, but the particles still jump all over the location. Also I can't use world.spawnParticles() as this plugin is for 1.8.8 and World.spawnParticle is 1.9+
     
    #5 danablend, May 16, 2016
    Last edited: May 16, 2016
  5. Make sure you set all the offsets to 0, as well as the speed.
     
  6. Thank you allot! I had speed set to 0.75, I actually thought that speed was the speed for the particles to dissapear, but apparently not, thanks bro it works now!
     
    • Friendly Friendly x 1
  7. Can I use this too? :D
     
  8. Of course, it's not mine :p