Catch new TNTPrimed entity

Discussion in 'Plugin Development' started by Likaos, Oct 5, 2013.

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

    Likaos

    Hi,

    Is there a way to catch a TNTPrimed entity when it spawn ni the world ? (entityspawn event like).

    Its not a creature or an item event...

    Thanks.
     
  2. Offline

    chasechocolate

    You mean when a plugin spawns it (world.spawn(loc, TNTPrimed.class)) or when a player ignites it? For the latter, I think you could use BlockIgniteEvent or PlayerInteractEvent.
     
  3. Offline

    Likaos

    I mean when the server spawn it,

    in CraftBukkit
    Code:java
    1. public void postBreak(World world, int i, int j, int k, int l) {
    2. if (!world.isStatic) {
    3. if ((l & 1) == 1) {
    4. EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F));
    5.  
    6. world.addEntity(entitytntprimed);
    7. world.makeSound(entitytntprimed, "random.fuse", 1.0F, 1.0F);
    8. }
    9. }
    10. }


    In vanilla
    Code:java
    1. /**
    2.   * Called upon the block being destroyed by an explosion
    3.   */
    4. public void onBlockDestroyedByExplosion(World par1World, int par2, int par3, int par4)
    5. {
    6. if (!par1World.isRemote)
    7. {
    8. EntityTNTPrimed var5 = new EntityTNTPrimed(par1World, (double)((float)par2 + 0.5F), (double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F));
    9. var5.fuse = par1World.rand.nextInt(var5.fuse / 4) + var5.fuse / 8;
    10. par1World.spawnEntityInWorld(var5);
    11. }
    12. }
    13.  
    14. /**
    15.   * Called right before the block is destroyed by a player. Args: world, x, y, z, metaData
    16.   */
    17. public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5)
    18. {
    19. if (!par1World.isRemote)
    20. {
    21. if ((par5 & 1) == 1)
    22. {
    23. EntityTNTPrimed var6 = new EntityTNTPrimed(par1World, (double)((float)par2 + 0.5F), (double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F));
    24. par1World.spawnEntityInWorld(var6);
    25. par1World.playSoundAtEntity(var6, "random.fuse", 1.0F, 1.0F);
    26. }
    27. }
    28. }


    See the par1World.spawnEntityInWorld(var6); or the world addEntity from craftbukkit, why that event doesn't fire anything ?

    Catch this event will be enough for me to know when a TNT is activated and where, catch the other events (ignite, flint/steel, fire arrow, tnt, explosion) to get activation will not give me the entity.
     
  4. Offline

    Likaos

    Up, still no idea to how catch that event ?
     
  5. Offline

    Likaos

  6. Offline

    Likaos

    Thanks for your answer,

    There's no way with a custom event to get it ?

    My aim is to create new "super tnt blocks", for that i use item naming + metadata when the player place it, but for the explosion i can only check where entity explose... sometime tnt move is propulsed so i'm nether the block activated is a normal or a super tnt...

    That's strange bukkit doesn't fire anything when an entity is added...
     
Thread Status:
Not open for further replies.

Share This Page