[Util] FireworkEffectPlayer v1.0

Discussion in 'Resources' started by codename_B, Dec 30, 2012.

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

    bob7

    Found the packet it uses: Packet38EntityStatus

    Soo i kept looking and found that the normal firework explodes using the same method as we're using: this.world.broadcastEntityEffect(this, (byte)17);

    Now.. My brain is totally fried. Why is it that we see ALL regular fireworks explode fine, but when we force the effect it shows up about 50% of the time. I'm going to try and delay it a bit, see if that does any good.
     
  2. Offline

    bob7

    Alright i found a semi-better method to get these fireworks to play. It still uses reflection of course, and is still codename_b's code, just i modifiy the private integer that designates how long the firework has flown. Soo this method still allows for minecraft to use it's native code to explode the fireworks, but simply "tricks" it into blowing it up instantly.

    http://pastebin.com/NTp0mXtf
     
    ArthurMaker likes this.
  3. Offline

    DarkBladee12

    bob7 I made commands for both variants and tested them a few times and I couldn't experience a difference, the one with the ticksFlown fails as often as the one with the .detonate() method :/
     
  4. Offline

    ArthurMaker


    DarkBladee12
    It is working nice for me '-'
     
  5. Offline

    bob7

    Got a bunch of people together on a server. This appears to be a 1.7 client bug. The strangest thing is some players will see a firework, and some wont. The effect limit isn't cutting off these fireworks, it's like the packet isn't being sent to all the clients within the view radius.
     
  6. Offline

    DevRosemberg

    bob7 And i found an even better one :)
     
  7. Offline

    DarkBladee12

    DevRosemberg Which one did you find that is better than the previously posted ones?
     
  8. Offline

    DevRosemberg

  9. Offline

    DarkBladee12

    DevRosemberg So I'm assuming you mean the second version, because the first version just uses .detonate() and the second one delays it. Did you test the second version a couple times and did it always work for you?
     
  10. Offline

    DevRosemberg

    DarkBladee12 The second version also uses .detonate() which does absoultely everything which codename did here. The second one does not work with the delay and i recommend deleting it which i will do in some minutes. Thanks for making me remember it. And yes without the Delay it works perfeclty.
     
  11. Offline

    Norbu10

    public static void getRandomEffect() {
    return FireworkEffect.builder().withType(Type.BALL).withColor(Color.RED).build();
    }
    Gives me an error!
     
  12. Offline

    DarkBladee12

    Norbu10 Your method is of a void type so you can't return anything...
     
  13. Offline

    DevRosemberg

    Norbu10 By the way, that wouldnt return a random effect,
    1) It wouldnt even return a FireworkEffect
    2) If it would return a FireworkEffect it would return a specified one in this case a Big Ball with Red Color.
    3) Try to do this instead:

    Code:java
    1. public static void spawnFirework(Location location) {
    2. Firework fw = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
    3. FireworkMeta fwm = fw.getFireworkMeta();
    4. Random r = new Random();
    5. int rt = r.nextInt(4) + 1;
    6. Type type = Type.BALL;
    7. if (rt == 1) type = Type.BALL;
    8. if (rt == 2) type = Type.BALL_LARGE;
    9. if (rt == 3) type = Type.BURST;
    10. if (rt == 4) type = Type.CREEPER;
    11. if (rt == 5) type = Type.STAR;
    12. int r1i = r.nextInt(17) + 1;
    13. int r2i = r.nextInt(17) + 1;
    14. Color c1 = getColor(r1i);
    15. Color c2 = getColor(r2i);
    16. FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1).withFade(c2).with(type).trail(r.nextBoolean()).build();
    17. fwm.addEffect(effect);
    18. int rp = r.nextInt(2) + 1;
    19. fwm.setPower(rp);
    20. fw.setFireworkMeta(fwm);
    21. }
    22.  
    23. private static Color getColor(int i) {
    24. Color c = null;
    25. if(i==1){
    26. c=Color.AQUA;
    27. }
    28. if(i==2){
    29. c=Color.BLACK;
    30. }
    31. if(i==3){
    32. c=Color.BLUE;
    33. }
    34. if(i==4){
    35. c=Color.FUCHSIA;
    36. }
    37. if(i==5){
    38. c=Color.GRAY;
    39. }
    40. if(i==6){
    41. c=Color.GREEN;
    42. }
    43. if(i==7){
    44. c=Color.LIME;
    45. }
    46. if(i==8){
    47. c=Color.MAROON;
    48. }
    49. if(i==9){
    50. c=Color.NAVY;
    51. }
    52. if(i==10){
    53. c=Color.OLIVE;
    54. }
    55. if(i==11){
    56. c=Color.ORANGE;
    57. }
    58. if(i==12){
    59. c=Color.PURPLE;
    60. }
    61. if(i==13){
    62. c=Color.RED;
    63. }
    64. if(i==14){
    65. c=Color.SILVER;
    66. }
    67. if(i==15){
    68. c=Color.TEAL;
    69. }
    70. if(i==16){
    71. c=Color.WHITE;
    72. }
    73. if(i==17){
    74. c=Color.YELLOW;
    75. }
    76. return c;
    77. }
     
  14. Offline

    sebasju1234

    You should use a switch statement, it looks better IMO.
    Code:
    private Color getColor(int i) {
            Color c = null;
           
            switch(i) {
                case 1: c = Color.AQUA;
                    break;
                case 2: c = Color.BLACK;
                    break;
                case 3: c = Color.BLUE;
                    break;
                case 4: c = Color.FUCHSIA;
                    break;
                case 5: c = Color.GRAY;
                    break;
                case 6: c = Color.GREEN;
                    break;
                case 7: c = Color.LIME;
                    break;
                case 8: c = Color.MAROON;
                    break;
                case 9: c = Color.NAVY;
                    break;
                case 10: c = Color.OLIVE;
                    break;
                case 11: c = Color.ORANGE;
                    break;
                case 12: c = Color.PURPLE;
                    break;
                case 13: c = Color.RED;
                    break;
                case 14: c = Color.SILVER;
                    break;
                case 15: c = Color.TEAL;
                    break;
                case 16: c = Color.WHITE;
                    break;
                case 17: c = Color.YELLOW;
                    break;
            }
     
            return c;
        }
     
  15. Offline

    bigteddy98

    codename_B why are you simulating all methods, instead of only sending the packet?
     
  16. Offline

    codename_B

    Because YOLO.
     
  17. Offline

    DevRosemberg

    Thats the true meaning of life, we do everything because YOLO.
     
    bigteddy98 likes this.
  18. Offline

    TheLexoPlexx

    There should definetely a PlaySoundEvent or whatever where you can cancel such stuff when you got the event.getHandler() or something

    Sorry, that was offtopic
     
  19. Offline

    coco5843

    Oh cool ... (I'm bad to speak English )
    Codename_B can you share that : ?


    I make a similar effect :




    and that :

    Show Spoiler

    [​IMG]



    Show Spoiler

    [​IMG]
     
  20. Offline

    ShearsSheep

  21. Offline

    coco5843

  22. Offline

    Ultimate_n00b

    How old are you? It's not "that" hard after taking some Trig classes.
     
    ShearsSheep likes this.
  23. Offline

    coco5843

    you ask my age because I did not express myself properly?

    excuse me, I'm doing my best, I'm French

    The trig classes ? what's ? can you give me an exemple ?

    oh trigonometry classes :D

    But how codename_B implement trig classes ?
     
  24. Offline

    xBlazeTECH

    I would like to know this as well. Does anyone know how to do this?
     
  25. Offline

    codename_B

    I don't know how to spawn fireworks without sound either.
     
  26. Offline

    LCastr0

    Maybe spawning the particles in a sphere, but then it could lag and would only be either white or random colored
     
  27. Offline

    Dubehh

    codename_B
    Code:java
    1. FireworkEffectPlayer fplayer = new FireworkEffectPlayer();
    2. fplayer.playFirework(player.getWorld(), player.getLocation(), FireworkEffect.builder().with(Type.BALL_LARGE).build()) ;

    How would I create my 'own' effect. Or did I just went full retard?

    Dubehh
    Stupid me. Didn't read. got it xD

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  28. Offline

    NerdsWBNerds

  29. Offline

    DevRosemberg

    NerdsWBNerds Look mate, getting resources popular isnt easy. It has to be something attractive or something improved about another resource. You going to other FireworkLibs and posting it is spam and in this case bumping an old thread which is not well seen here. Just wait for your resource to get popular if it deserves to be. If not work on a new and improved one. Im telling you this as an advice, not to mock you.
     
  30. Offline

    moo_we_all_do

    To spawn fireworks without sound, look up the source for detonate, and change/delete the playSound.
     
Thread Status:
Not open for further replies.

Share This Page