What event does igniting TNT pull up?

Discussion in 'Plugin Development' started by OstlerDev, Jun 21, 2012.

  1. Offline

    OstlerDev

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Hey so I am trying to create a plugin that instantly sets off tnt, the only part I am stuck at is how to detect when TNT is set off by redstone! I have tried RedstoneBlockEvent, but that does not pull up anything! What event should I be using to detect this?
  2. Offline

    Malikk

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    ExplosionPrimeEvent
  3. Offline

    OstlerDev

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    How would I set the ticks left on the TNT to be 0?
  4. Offline

    Malikk

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I would think you would get the entity, cast it to TNTPrimed, and then set it from there.

    Have a look at the Apidocs, tho, that will save you a LOT of these really simple questions...
  5. Offline

    EnvisionRed

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  6. Offline

    OstlerDev

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I have been looking at the APIdocs... I am not stupid I could just not find the event that would call up when tnt gets set off...

    Also an ExplosionPrimeEvent only gets called when the TNT explodes... Is there any other events?

    This post has been edited 1 time. It was last edited by OstlerDev Jun 21, 2012.
  7. Offline

    Malikk

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    ...no, its called when any entity is primed to explode. Get the entity from that event, and set its ticks.
  8. Offline

    OstlerDev

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    That is called right before the entity explodes, the java doc even says "Called when an entity has made a decision to explode." That is called the tick before it explodes.

    If your logic was correct then this should have worked.
    Code:
    public void ExplosionPrimeEvent(ExplosionPrimeEvent event) {
            log.info("[iTNT] There was a ExplosionPrimeEvent!");
            if (event.getClass() == TNTPrimed.class){
                TNTPrimed tnt = (TNTPrimed)event.getEntity();
                tnt.setFuseTicks(0);
            }
    }
    That does not work though, is there anyway to detect when redstone current interacts a TNT block?
  9. Offline

    tips48

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Nonono, your checking if the event's class is equal to TNT. You want to check if event.getEntity().getClass() == TNTPrimed.class
    Firefly likes this.
  10. Offline

    OstlerDev

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Thanks for letting me know of that, but the issue is that the ExplosionPrimeEvent is getting called up the tick before the explosion, not after it is primed via redstone.
  11. Offline

    OstlerDev

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Does anybody know how to detect this?
  12. Offline

    JxAxVxAx

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    This Might Help You .


    This post has been edited 1 time. It was last edited by JxAxVxAx Jun 22, 2012.

Share This Page