BlockIgniteEvent

Discussion in 'Plugin Development' started by DoggyCode™, Oct 26, 2015.

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

    DoggyCode™

    Hey, I'm using BlockIgniteEvent to later on cancel if the ignited block is TNT, but for some reason it doesn't work. It works if I ignite any other block (such as dirt, sand, grass, etc...), but not SOLID TNT. Why? Here's my code:
    Code:
    @EventHandler
    public void onBlockIgnite(BlockIgniteEvent event) {
    if (event.getCause() == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) {
    Player p = event.getPlayer();
    p.sendMessage("DEBUG: 1");
    }
    thanks!
     
  2. I think you need the ExplosionPrimeEvent but I'm not sure
     
  3. Offline

    Zombie_Striker

    @DoggyCode™
    I think lighting TNT does not trigger blockIgniteEvent. These are some following events that you could use
    • ExplosionPrimeEvent
    • PlayerInteractEvent
    • CreatureSpawnEvent / EntitySpawnEvent
     
    DoggyCode™ likes this.
  4. Offline

    rbrick

    N/A (open)
    @DoggyCode™
    From JavaDocs:


    EDIT: Misread that sentences.
     
    Last edited: Oct 26, 2015
  5. Offline

    DoggyCode™

    Aha ok. Thanks
     
  6. Offline

    Scimiguy

    @DoggyCode™
    Like Striker said, TNT with Flint and Steel works a little different to other blocks.
    Note that it doesn't actually light the block, it just activates it.
    It's the same kind of effect you'd get if you used a flint and steel on Creepers.
     
    DoggyCode™ likes this.
  7. Offline

    DoggyCode™

    So I should use another event for my case?

    Case: cancel if a player lights a TNT
     
  8. Offline

    Scimiguy

    @DoggyCode™
    It's actually quite a long-debated topic.

    You have two options:
    1. Use EntityExplodeEvent and cancel it -- This won't stop the blinking of the tnt block, just stop the explosion damage
    2. Use PlayerInteractEvent and check for the flint/tnt combination. Cancelling this will produce your intended effect.

    For reference:
    The ExplosionPrimeEvent is actually badly named. This Event occurs right before the explosion (I.E. After the blinking cycle is done on your TNT.)
    EntityExplodeEvent is pretty similar. It occurs when the Entity actually explodes.
     
Thread Status:
Not open for further replies.

Share This Page