Get Who Caused the TNT Explosion?

Discussion in 'Plugin Development' started by Blockhead7360, Jun 26, 2015.

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

    Blockhead7360

    Hello!

    I am making a minigame plugin for my server, and I was wondering if there was anyway to get who caused the TNT explosion through the EntityExplodeEvent. Can anyone help?
     
  2. I've never done this myself so I'm not sure but try:
    Code:
    if (event.getEntity() instanceof TNTPrimed) {
        Entity causer = ((TNTPrimed) event.getEntity()).getSource();
    }
    
    Reason I'm not sure is because I'm not even sure if the entity is an instance of 'TNTPrimed', but as I said, I've never used EntityExplodeEvent before, and these seems logical so it may work.
     
  3. when you get the nms class of the tnt entity in the event, you can do getSource() to I think get the entity that primed the tnt.
     
  4. Why do you need to use NMS code? Look at my reply above...
     
  5. My bad, I was looking in the Explosive class, because that's what is used in the event. Thank you for saying!
     
  6. Offline

    Blockhead7360

    @KingFaris11 Is there any way I can find a player?

    @KingFaris11 the reason I need this is to check if the player is in the arena when he lights it (so I know that I need to regen that)

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

    MCMatters

  8. You should mention to check 'instanceof'.

    To OP:
    Code:
    if (causer instanceof Player) {
        Player evilGuy = (Player) causer;
    }
    
     
Thread Status:
Not open for further replies.

Share This Page