Cricle player with Particles

Discussion in 'Plugin Development' started by Ape101, Apr 25, 2014.

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

    Ape101

    So im using the ParticleEffect library, and i know how to surround the player in particles when it comes to using doubles, but this library uses floats so how do i create a circle now?

    This is how i do it with doubles

    Code:java
    1. for (double x = 0; x <= (Math.PI * 2); x += 0.2) {
    2. ParticleEffect.HAPPY_VILLAGER.display(player.getLocation(), Math.cos(x), 1, Math.sin(x), 1, 1);
    3. }
     
  2. Offline

    BillyGalbreath

    Im not sure you underatand what floats and doubles are...
     
  3. Offline

    Heirteir

    Ape101
    What is this has I do not know? Niether do I know what your asking.
     
  4. Offline

    Wizehh

    Float is another Java data type; just replace 'double' with 'float' and you should be fine.
     
  5. Offline

    Ape101

    Thats the thing, i'm not. I've seen this formula used with a library that uses doubles, and it works fine, but when used with this library, it doesnt, even when i cast the doubles as floats, and when i try to change the method from floats to doubles it just screws everything up
    Wizehh Heirteir BillyGalbreath
     
  6. Offline

    Heirteir

    Ape101
    I can see your using the ParticleEffectAPI from the bukkit resources section so I imagine the method would be more like
    Code:java
    1. for (int x = 0; x < 3; x + 0){
    2. ParticleEffect.HAPPY_VILLAGER.display(player.getLocation, 0, 0, 0, 0.5, 1);
    3. continue;
    4. }


    I don't know why you would even do what you were thinking but this should work if you import the library correctly.
    This will play the effect 3 times when the for loop is called.
    --Heirteir
     
  7. Offline

    Ape101

    Thats not making it into a circle.... Thats just playing the effect
     
  8. Offline

    Heirteir

    Ape101
    o I thought your error was trying to make it play the effect, well I don't know how to make it a circle. (Trial and Error maybe)
     
  9. Offline

    Deleted user

    You can cast double to float.
    Code:java
    1. double valuedouble = 1.0;
    2. float valuefloat = (float)valuedouble;
     
  10. Heirteir There's really no point in ending a loop with continue. It was going to do that anyway.
    Ape101 What goes wrong when you change the word double to float?
     
  11. Offline

    Heirteir

  12. Offline

    Heirteir

    AdamQpzm
    I just look to put continue as it's easier to find the loops if you have a lot of code.
     
  13. Offline

    Ape101

    It want's to change the actual Particle library itself, cant remember exactly but i think it was inside the send packet method, it changed a player into a list of integers
     
  14. Offline

    BillyGalbreath

    I stand by what I said earlier..
     
  15. Offline

    Slikey

    Please do not just copy&paste! Learn from this..
    Code:java
    1. // Where do you want to show the cirlce?
    2. Location location = player.getEyeLocation();
    3. // How many particles should have the circle?
    4. int particles = 20;
    5. // What's the radius?
    6. float radius = 3;
    7. // Iterate over each particle
    8. for (int i = 0; i < particles; i++) {
    9. double angle, x, z;
    10. // Angle for particle 5:
    11. // 360° * 5 / 20 = 360° * 1/4 = 90°
    12. angle = 2 * Math.PI * i / particles;
    13. // Create circle with radius of 1
    14. // Cosinus and sinus reach 1 and -1 on peaks.
    15. // Multiply with radius to apply it.
    16. x = Math.cos(angle) * radius;
    17. z = Math.sin(angle) * radius;
    18. // Apply coords to the location
    19. location.add(x, 0, z);
    20. ParticleEffect.FLAME.display(location, 0, 0, 0, 1, 1);
    21. // Remove the circle coords again.
    22. location.subtract(x, 0, z);
    23. }
     
    leon3001 and McKiller5252 like this.
  16. Offline

    BloodBacker

    Works this code?
     
  17. Offline

    Slikey

  18. Offline

    BloodBacker

    Flames would not work as an circle..
     
Thread Status:
Not open for further replies.

Share This Page