create a cylinder of particles

Discussion in 'Plugin Development' started by superjesse07, Apr 30, 2014.

Thread Status:
Not open for further replies.
  1. i want to create a cylinder of particles but i'am having problems with it
    Code:
        private static ArrayList<String> AuraPlayers = new ArrayList<String>();
       
        public static List<Location> circle (Player player, Location loc, Integer r, Integer h, Boolean hollow, Boolean sphere, int plus_y) {
            List<Location> circleblocks = new ArrayList<Location>();
            int cx = loc.getBlockX();
            int cy = loc.getBlockY();
            int cz = loc.getBlockZ();
            for (int x = cx - r; x <= cx +r; x++)
                for (int z = cz - r; z <= cz +r; z++)
                    for (int y = (sphere ? cy - r : cy); y < (sphere ? cy + r : cy + h); y++) {
                        double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0);
                        if (dist < r*r && !(hollow && dist < (r-1)*(r-1))) {
                            Location l = new Location(loc.getWorld(), x, y + plus_y, z);
                            circleblocks.add(l);
                            }
                        }
       
            return circleblocks;
        }
        static Plugin main;
       
        public Aura(Plugin pl) {
            main = pl;
        }
          public void startAura() {
                Bukkit.getScheduler().scheduleSyncRepeatingTask(main, new Runnable()
                {
                  public void run()
                  {
                    for (final Player p : Bukkit.getOnlinePlayers()) {
                      if (!AuraPlayers.contains(p.getName())) return;
                      List<Location> circle1 = circle(p, p.getLocation(), 7, 1, true, false, 3);
                      int time = 0;
                        for(time = 0;time < circle1.size(); time++)
                        {
                            final Location loc = (Location)circle1.get(time);
                           
                          Bukkit.getServer().getScheduler().runTaskLater(main, new Runnable() {
                             
                            @Override
                            public void run() {
                                ParticleEffect.LARGE_SMOKE.display(loc, 0.2f, 0.2f, 0.2f, 0.1f, 35);
                                ParticleEffect.HAPPY_VILLAGER.display(loc, 0.2f, 0.2f, 0.2f, 1, 35);
                                for (LivingEntity en : loc.getWorld()
                                        .getEntitiesByClass(LivingEntity.class)) {
                                    if (en.getLocation().distance(loc) <= 6) {
                                        if(!en.equals(p))
                                        {
     
                                            en.damage(4.0f);
                                            ParticleEffect.LARGE_SMOKE.display(en.getLocation(), 0.2f, 0.4f, 0.2f, 0.1f, 25);
                                            ParticleEffect.HAPPY_VILLAGER.display(en.getLocation(), 0.1f, 0.2f, 0.1f, 0.1f, 25);
                                           
                                    }
                                    }
                                }
                            }
                        }, 5);
                        }
                    }
                  }
                }, 8L, 5L);
              }
    this is the code but i want every particle to happen after the other one now the all go at the same time i want something like this
    and then like the lightning storm
     
  2. Offline

    rfsantos1996

    new BukkitRunnable {
    }.runTimer(main, 8, 5);

    is more efficient than schedule a task.

    Also, nice effects.

    I don't think I can help you, but if you can do something different like jumping block to block checking if its x/z intersects with your invisible circle (at least your list would be in order to make a circle without these 2 growing things [that I still think it is nice]). http://imgur.com/y94lved

    And you could use LinkedList to maintain order of insertion (I think).
     
  3. ok updated the code
    Code:java
    1. private static ArrayList<String> AuraPlayers = new ArrayList<String>();
    2.  
    3. public static List<Location> circle (Player player, Location loc, Integer r, Integer h, Boolean hollow, Boolean sphere, int plus_y) {
    4. List<Location> circleblocks = new ArrayList<Location>();
    5. int cx = loc.getBlockX();
    6. int cy = loc.getBlockY();
    7. int cz = loc.getBlockZ();
    8. for (int x = cx - r; x <= cx +r; x++)
    9. for (int z = cz - r; z <= cz +r; z++)
    10. for (int y = (sphere ? cy - r : cy); y < (sphere ? cy + r : cy + h); y++) {
    11. double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0);
    12. if (dist < r*r && !(hollow && dist < (r-1)*(r-1))) {
    13. Location l = new Location(loc.getWorld(), x, y + plus_y, z);
    14. circleblocks.add(l);
    15. }
    16. }
    17.  
    18. return circleblocks;
    19. }
    20. static Plugin main;
    21.  
    22. public Aura(Plugin pl) {
    23. main = pl;
    24. }
    25. public void startAura() {
    26. new BukkitRunnable() {
    27. public void run()
    28. {
    29. for (final Player p : Bukkit.getOnlinePlayers()) {
    30. if (!AuraPlayers.contains(p.getName())) return;
    31. List<Location> circle1 = circle(p, p.getLocation(), 7, 1, true, false, 3);
    32. int time = 0;
    33. for(time = 0;time < circle1.size(); time++)
    34. {
    35. final Location loc = (Location)circle1.get(time);
    36.  
    37. new BukkitRunnable() {
    38.  
    39. @Override
    40. public void run() {
    41. ParticleEffect.LARGE_SMOKE.display(loc, 0.2f, 0.2f, 0.2f, 0.1f, 35);
    42. ParticleEffect.HAPPY_VILLAGER.display(loc, 0.2f, 0.2f, 0.2f, 1, 35);
    43. for (LivingEntity en : loc.getWorld()
    44. .getEntitiesByClass(LivingEntity.class)) {
    45. if (en.getLocation().distance(loc) <= 6) {
    46. if(!en.equals(p))
    47. {
    48.  
    49. en.damage(4.0f);
    50. ParticleEffect.LARGE_SMOKE.display(en.getLocation(), 0.2f, 0.4f, 0.2f, 0.1f, 25);
    51. ParticleEffect.HAPPY_VILLAGER.display(en.getLocation(), 0.1f, 0.2f, 0.1f, 0.1f, 25);
    52.  
    53. }
    54. }
    55. }
    56. }
    57. }.runTaskLater(main, 10l);
    58. }
    59. }
    60. }
    61. }.runTaskTimer(main, 8L, 5L);
    62. }

    still does not do what i want.
    what i want is one particle circle ling around me

    bumb

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  4. Offline

    Aqua

    Make a variable with the List<Location>, make an int-variable and set it to 0.
    Every x ticks:
    - Check if int-variable is larger than list.size(), if so, cancel scheduler and run lightning storm.
    - run particle effect on list.get(int-variable).
    - increase int-variable with 1;

    superjesse07 Forgot to tahg

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  5. Aqua it is already in there doesn't work
    Code:java
    1. List<Location> circle1 = circle(p, p.getLocation(), 7, 1, true, false, 3);
    2. int time = 0;
    3. for(time = 0;time < circle1.size(); time++)
    4. {
    5. final Location loc = (Location)circle1.get(time);
     
  6. Offline

    Aqua

    superjesse07
    That makes all locations in the list run at once, and not run like the circle in the video you posted.
    Inside the
    for (Player p : Bukkit.getOnlinePlayers()) {}
    Make a new BukkitRunnable for every player.
    Inside the runnable make it as I said above.


    spoonfeed (open)

    I have spoonfeed code for the runnable in this spoiler, try it for yourself first, if you realy can't get it to work after that, use this: (put it inside for(String s : AuraPlayers) {Player p = Bukkit.getPlayer(s);/*Code here*/}
    http://pastebin.com/yAv4Garm
     
  7. Aqua it works but i want just one particle that make a whole circle around the player updated code
    Code:java
    1. private static ArrayList<String> AuraPlayers = new ArrayList<String>();
    2.  
    3. public static List<Location> circle (Player player, Location loc, Integer r, Integer h, Boolean hollow, Boolean sphere, int plus_y) {
    4. List<Location> circleblocks = new ArrayList<Location>();
    5. int cx = loc.getBlockX();
    6. int cy = loc.getBlockY();
    7. int cz = loc.getBlockZ();
    8. for (int x = cx - r; x <= cx +r; x++)
    9. for (int z = cz - r; z <= cz +r; z++)
    10. for (int y = (sphere ? cy - r : cy); y < (sphere ? cy + r : cy + h); y++) {
    11. double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0);
    12. if (dist < r*r && !(hollow && dist < (r-1)*(r-1))) {
    13. Location l = new Location(loc.getWorld(), x, y + plus_y, z);
    14. circleblocks.add(l);
    15. }
    16. }
    17.  
    18. return circleblocks;
    19. }
    20. static Plugin main;
    21.  
    22. public Aura(Plugin pl) {
    23. main = pl;
    24. }
    25. public void startAura() {
    26. new BukkitRunnable() {
    27. int i = 0;
    28. public void run()
    29. {
    30. for (final Player p : Bukkit.getOnlinePlayers()) {
    31. if (!AuraPlayers.contains(p.getName())) return;
    32. List<Location> circle1 = circle(p, p.getLocation(), 7, 1, true, false, 3);
    33. if (i >= circle1.size()) {
    34.  
    35. for (LivingEntity en : p.getWorld()
    36. .getEntitiesByClass(LivingEntity.class)) {
    37. if (en.getLocation().distance(p.getLocation()) <= 6) {
    38. if(!en.equals(p))
    39. {
    40.  
    41. en.damage(4.0f);
    42. ParticleEffect.LARGE_SMOKE.display(en.getLocation(), 0.2f, 0.4f, 0.2f, 0.1f, 25);
    43. ParticleEffect.HAPPY_VILLAGER.display(en.getLocation(), 0.1f, 0.2f, 0.1f, 0.1f, 25);
    44.  
    45. }
    46. }
    47. }
    48. i = 0;
    49. }
    50. ParticleEffect.LARGE_SMOKE.display(circle1.get(i), 0.2f, 0.2f, 0.2f, 0.1f, 35);
    51. ParticleEffect.HAPPY_VILLAGER.display(circle1.get(i), 0.2f, 0.2f, 0.2f, 1, 35);
    52. i++;
    53. }
    54. }
    55. }.runTaskTimer(main, 8L, 5L);
    56. }
     
  8. Offline

    stan110

    @Aqua heva you a code of the mephiaura in this dutch vid:
     
Thread Status:
Not open for further replies.

Share This Page