Solved Detecting What Ignited Primed TNT

Discussion in 'Plugin Development' started by BungeeTheCookie, Jun 21, 2014.

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

    BungeeTheCookie

    Hello Bukkiteers! How do you detect what ignited primed tnt, whether a projectile, a player, or some other entity, how do you detect the source that ignited or primed a TNT?
     
  2. Offline

    MineCrashKoen

    jthort likes this.
  3. Offline

    BungeeTheCookie

    Wow. Thank chu so much!!!

    Alright, I have another question. When a player is damaged by this explosion? How would I get the entity that set the explosion?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  4. An over-complicated way to do it would be to store the location + player that ignited the tnt and compare the location of the explosion with the saved data. Something like a hashmap of players and locations would work I reckon.

    EDIT:
    I say over-complicated because there's probably an easier way to do this, I just don't see it right now!
     
  5. Offline

    BungeeTheCookie

    I was thinking on doing that.... but... :| If there are no other answers, I will probably do that
     
  6. Offline

    MineCrashKoen

    BungeeTheCookie

    I haven't tested it but I suggest a EntityDamageByEntityEvent will trigger because you get hit by a TNTPrimed.

    Then you can check if the getDamager() is an instance of a TNTPrimed.

    Then you could cast the damager to a TNTPrimed.

    Then check if getSource() of the TNTPrimed is what you want it to be.

    And then you'd have what you want to have :)

    Again, this is just a suggestion. I really don't know if it'll work but I don't have the time to check if.

    Hope it helps :)
     
  7. Offline

    BungeeTheCookie

    getSource() returns EntityLiving. What if the entity that set off the tnt was a projectile?
     
  8. Then track the projectile back to its shooter I guess.
     
  9. Offline

    MineCrashKoen

    BungeeTheCookie

    Returns an Entity for me! If it is an EntityLiving it would return false at the "instanceof"check
     
  10. Offline

    BungeeTheCookie

    RAFA_GATO_FOFO
    How..?
    MineCrashKoen
    It returns EntityLiving, which extends Entity. Projectile extends Entity, not EntityLiving. The TNT Primed does not store any instance of the projectile unless it already does the instanceof check when the entity is primed.

    RAFA_GATO_FOFO MineCrashKoen
    God dammit. I was refering to EntityTNTPrimed instead of TNTPrimed. Thanks!!!

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

    MineCrashKoen

Thread Status:
Not open for further replies.

Share This Page