TNT Dispenser HashMap

Discussion in 'Plugin Development' started by opd02, May 26, 2020.

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

    opd02

    Hello!
    I am looking to use an event of when TNT is dispensed from a dispenser, add the TNT to a hashmap of <Entity, Location>. (Location being the location of the TNT spawning). This sounds easy, use ExplosionPrimeEvent, or BlockDispenseEvent, or something along those lines. ExplosionPrimeEvent is not called right when TNT is dispensed and BlockDispenseEvent is only good for dispensing items from dispensers. I can use BlockDispenseEvent and check if the item is TNT, but I then can't get that TNT Entity and do anything with it, I can only use e.getItem(), which returns an ItemStack. Any thoughts?
     
  2. Offline

    Wick

    I would instinctively think ExplosionPrimeEvent, what do you mean its not called right when TNT is dispensed? How long after..? I would have thought its called as soon as it's dispensed as TNT primes right after being shot out.
     
  3. Offline

    opd02

    The ExplosionPrimeEvent is called the instant before the TNT explodes for some reason. In my opinion it is falsely named.
     
  4. Offline

    Wick

    How about EntitySpawnEvent? There is a separate CreatureSpawnEvent, so potentially ESE will fire when TNT is primed as an entity in such case is created.
     
  5. Offline

    opd02

    Just checked, CreatureSpawnEvent and EntitySpawnEvent do not get tiggered when TNT is dispensed or ignited.
     
  6. Offline

    Wick

    Damn, I'm out of ideas then haha. Hopefully someone else can help
     
  7. Offline

    opd02

  8. Offline

    bowlerguy66

    @opd02 If you couldn't find anything better, you could check for all of the entities around the dispenser, cast the entity as TNTPrimed (after checking of course) and see how long it's lifetime has been and then add it to your hashmap

    Edit: Here's TNTPrimed, getFuseTicks() looks useful
     
Thread Status:
Not open for further replies.

Share This Page