Helix particle effect for projectile

Discussion in 'Plugin Development' started by AKZOBIE74, Nov 2, 2014.

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

    AKZOBIE74

    ChipDev Yes i do

    Skionz I kinda do but how do i implement the code that @ChipDev gave me into a method?

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

    Skionz

    Again, you should learn basic java before attempting this. Nobody is going to write your code for you *cough* ChipDev *cough* :p.
     
    ChipDev and Funergy like this.
  3. Offline

    AKZOBIE74

    ChipDev I dont know what the variable "world" is suppose to be equal to I tried this code but it shows up as an error. Here is the code.

    Code:java
    1. Double timestrand1 = Bukkit.getWorld("world").getBlockAt(loc).getY();
     
  4. Offline

    ChipDev

    What is your error?
     
  5. Offline

    AKZOBIE74

    ChipDev Ok so when i hover over my code it tells me whats wrong and how to fix it but i don't know how to fix it. It also has a red line under it. Here is the message that it gives me when i hover over the code about how to fix it and whats wrong.

    Message: "Incompatible types.

    Required: java.lang.double

    Found: int"
     
  6. Offline

    Skionz

    AKZOBIE74 the getY() method in the Block class returns an Integer not a double.
     
  7. Offline

    ChipDev

    AKZOBIE74 Skionz Do this:
    PHP:
    Double (WhatyourvariableNameIs) = (Y) + 0.0;
    add 0.0
     
  8. Offline

    AKZOBIE74

    ChipDev in the code you gave me it says world is undefined am i suppose to make world equal to the code you just gave me?
     
  9. Offline

    ChipDev

    player.getWorld()
     
  10. Offline

    AKZOBIE74

    ChipDev I dont get what i need to do it says i need java.lan.double but it found an integer instead here is my code
    Code:java
    1. Double timestrand1 = player.getWorld().getBlockAt(loc).getY();
     
  11. Offline

    ChipDev

    Code:java
    1. Double timestrand1 = player.getWorld().getBlockAt(loc).getY() + 0.0;

    AKZOBIE74
     
  12. Offline

    Skionz

    MrShnig likes this.
  13. Offline

    AKZOBIE74

    ChipDev How do i make it static?
     
  14. Offline

    ChipDev

    Int cannot me cast to a double, add 0.0.

    Why? Static isn't for fun, its like NMS. Use it when absolutely needed.

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

    AKZOBIE74

    ChipDev I want to turn it into static because i want it as a method so i can use it in one of my plugins.
     
  16. Offline

    ChipDev

    public/private <static> type:void/object name {
     
  17. Offline

    AKZOBIE74

    ChipDev I know that but it shows on error on "this". Here you try the code you gave me and turn it into static it gives you an error on "this".
     
  18. Offline

    Dudemister1999

    AKZOBIE74 That's because 'static' and 'this' don't like eachother. Try not making it static, that just complicates things. Just store an instance of your class in the main plugin, and use that instance when you want the method access.
     
    ChipDev likes this.
  19. Offline

    AKZOBIE74

    Dudemister1999 now i cant register my listener class

    How do i fix this? Because of this code i cant register my listener class "Stupefy".Here is the code.
    Code:java
    1. public Stupefy(Main instance) {
    2. this.instance = instance;
    3. }


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

    Funergy

    AKZOBIE74 What do you mean "I can't register it" just do
    Bukkit.getPluginManager().registerEvents(new <yourListenerClass>(),this);
    put this ^ in your main class in the onEnable.
     
  21. Offline

    CentrumGuy

    I have the code. Here this will create a helix in a certain location. It took a lot of testing and errors but anyways, hope you appreciate it ;)

    Code:java
    1. public static void runHelix(Location loc, ParticleEffect effect, float Speed) {
    2.  
    3. double radius = 5;
    4.  
    5. for (double y = 5; y >= 0; y -= 0.008) {
    6. radius = y / 3;
    7. double x = (radius * Math.cos(1.6 * y));
    8. double z = (radius * Math.sin(1.6 * y));
    9.  
    10. double y2 = 5 - y;
    11.  
    12. Location loc2 = new Location(loc.getWorld(), loc.getX() + x, loc.getY() + y2, loc.getZ() + z);
    13. effect.display(loc2, 0, 0, 0, Speed, 1);
    14. }
    15.  
    16. for (double y = 5; y >= 0; y -= 0.008) {
    17. radius = y / 3;
    18. double x = (-(radius * Math.cos(1.6 * y)));
    19. double z = (-(radius * Math.sin(1.6 * y)));
    20.  
    21. double y2 = 5 - y;
    22.  
    23. Location loc2 = new Location(loc.getWorld(), loc.getX() + x, loc.getY() + y2, loc.getZ() + z);
    24. effect.display(loc2, 0, 0, 0, Speed, 1);
    25. }
    26.  
    27. }


    This creates a helix of any particle effects. Remember that this uses the particle effect library which can be found here:

    https://forums.bukkit.org/threads/particle-packet-library.138493/
     
    ChipDev likes this.
  22. Offline

    ChipDev

    Wait.. pic?
     
  23. Offline

    CentrumGuy

    Here is a screen shot I took a long time ago. It changed a bit since then but it's the same basic shape. I think it looks cooler now. This uses the Red_Dust particle effect and a speed of 0. I hope you like it :)

    [​IMG]
     

    Attached Files:

  24. Offline

    ChipDev

    I like it! But....
    why is it different than mine? mine is more compact :p
    love the spins!
     
  25. Offline

    CentrumGuy

    I think it's because your radius stays the same but in mine, the radius decreases a little every time it goes up by the y value

    Also you can make mine more compact if you decrease y -= 0.008 to something like y -= 0.004. Although this will result in more particles resulting in more lag

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

    ChipDev

    Oh yeah. raidus subtracting is easy, I did that for a tornado (Went up.. actually)
    Mine also is more like hypixels, still really like the look :3
     
  27. Offline

    CentrumGuy

    thanks :)
     
  28. Offline

    coco5843

  29. Offline

    CentrumGuy

    you would have to set a repeating task and create a new variable that will be y + the rotation of the helix. Then do this instead of radius * Math.[Cos or Sin](1.6 * (the new variable)) although it's pretty complicated so if you just want the helix I wouldn't suggest rotating it
     
    ChipDev likes this.
  30. Offline

    AKZOBIE74

    CentrumGuy the method "display" for effect.display doesn't exist?
     
Thread Status:
Not open for further replies.

Share This Page