Attaching entities to other entities

Discussion in 'Plugin Development' started by Charliebiff05, Jul 7, 2018.

  1. Offline

    Charliebiff05

    Hey there my name is charlie and Im new to coding bukkit plugins, not looking to be spoonfed but if anyone can give me a pointer or two about how I would go about say attaching a firework entity to a snowball.

    Thanks.
     
  2. @Charliebiff05
    Well, what do you mean by 'attaching':
    1. If you want the firework to ride the snowball, you would just need to set the firework as a passager for the snowball.
    2. If you mean attach as in to add a lead the entities, you would just need to set the snowball as the leash holder for the firework.
    3. If you mean you want to store in memory the firework and the snowball, so you can get the firework by getting the snowball, create a HashMap<SnowBall, Firework>. Use the .put() method to initially add them to the hashmap, and the .get(Snowball) method to get the firework.
     
  3. Offline

    Charliebiff05

    I'll be setting the firework as a passenger to the snowball, but if I only wanted the explosion and not the trail of the rocket flying in the air how would that be done?

    thanks
     
  4. Offline

    MightyOne

    @Charliebiff05 well Firework#detonate() will instantly make the firework explode. Do you mean that?
     
  5. Offline

    Charliebiff05

    yes that's what I meant! thanks @MightyOne , how would I spawn the firework as a passenger...?
    cheers guys

    and how would I loop it so that every half second a new detonated firework spawns
     
    Last edited: Jul 11, 2018 at 9:45 PM
  6. Offline

    MightyOne

    That can be done with a BukkiRunnable.
    Just put the spawning of the Firework inside the BukkiRunnable
    Code:
    Firework f = world.spawn...
    snwball.addPassenger(f);
    f.detonate()
    and run it as BukkiRunnable#runTaskTimer(...)
     

Share This Page