[Tutorial] Make firework explode instantly (1.7.x)

Discussion in 'Resources' started by Plo124, Apr 23, 2014.

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

    Plo124

    So I made a simple method using a tiny bit of code which is version dependant. Note that the delay is set to 1, because if its set to 0 sometimes the firework wont actually go BOOM.

    Code:java
    1. public static void launch(Location l,Color color){
    2. Firework fw = l.getWorld().spawn(l,Firework.class);
    3. FireworkMeta meta = fw.getFireworkMeta();
    4. meta.addEffect(FireworkEffect.builder().flicker(false).with(Type.BALL).trail(false).withColor(color).build());
    5. fw.setFireworkMeta(meta);
    6. ((CraftFirework)fw).getHandle().expectedLifespan = 1;
    7. }


    Example usage
    Code:java
    1. Fireworks.launch(p.getLocation().add(0,3,0),Color.RED);
     
  2. Offline

    bigteddy98

    This isn't instant, it is one tick slower than my version, where I instantly send the packet. One tick doesn't sound much, but causes you to see and hear the firework (which you probably don't want). Anyway, it's a good alternative for people who are looking for a simple and small method.
     
  3. Offline

    BungeeTheCookie

    Self advertisement much? :p
     
  4. Offline

    bigteddy98

    Nah, just telling people there is a better way of doing this.
     
  5. Offline

    BungeeTheCookie

    I know. Just messing with you. :p
     
    bigteddy98 likes this.
  6. Offline

    ChipDev

    You don't want to see the firework? Whats the reason to spawn it then?
     
  7. Offline

    bigteddy98

    I ment the firework rocket, you probably only want the explosion without an aweful rocket in the middle.
     
  8. Offline

    ChipDev

    Oh.... Yeah. [sheep]
     
Thread Status:
Not open for further replies.

Share This Page