Get entity tnt switches to when primed

Discussion in 'Spigot Plugin Development' started by Delano2000, May 13, 2017.

  1. I have been testing out different events and googling around for a few hours now and can't find a solution to my problem. I am trying to make a custom tnt plugin (different tnt types do different effects, like bigger explosions and such) and I set metadata to the tnt block when i place it if it is the custom tnt, so if i could get the entity when the tnt becomes primed i could also set the metadata of the entity then check the blockexplosionevent or whatever its called to apply the effects. I need an event or way to determine when it switches immediately when it's primed.

    I've tried:

      • PlayerInteractEvent (doing this is going to require me to do more to get the entity, and detect if other tnt ignites the tnt or if redstone ignites it)
      • ExplosionPrimeEvent (this occurs when the tnt is about to explode[like a tick away], not when its actually primed)
      • CreatureSpawnEvent (i saw something on here from googling this issue that this would work, but it doesnt
      • BlockPhysicsEvent (fires about 6 times when you prime a TNT)
      • EntityBlockFormEvent (tried it then realized it wasn't for this)
    Once again to clarify I have been googling this issue all day and still have not come to a conclusion. I have tried out different events and still have not found one most suitable for this.

    If someone could please help me resolve this issue asap I would really appreciate it, thanks!
    #1 Delano2000, May 13, 2017
    Last edited: May 13, 2017
  2. I think there's a blockplaceevent, just check if the name is like 'Custom Tnt' and if it is, cancel the event, remove the item, and summon tnt there.
  3. Wow, I have no idea how I didn't think of that, lmao. Thank you for that, I've been up all night so coding and sleepiness don't go well together for me.
  4. Actually, I reopened this because I thought about it and that wouldn't really work for me. I need it to be able to be lit like regular TNT, not just ignited when it is placed.
  5. Why not do something like this?
    Entity tnt = Bukkit.getWorld(p.getWorld().getName()).spawn(LOCATION, TNTPrimed.class);
    #5 Fluddershy, May 13, 2017
    Last edited: May 13, 2017
  6. Didn't know you could do that, I'll try it out
  7. That just brings me back to square one, I need a way to determine the entity tnt turns into when it is ignited, a way i can get the primedtnt entity and tnt block. i set metadata on the block and when i light it i want to get the metadata and set it to the entity
  8. Okay so you will need to check a bunch of events that will ignite tnt, like PlayerInteractEvent, BlockDispenseEvent, Redstone event (don't know the name), then you need check the block inside that event and if it's that block is stored inside the hashmap that you set on BlockPlaceEvent remove the block and spawn a primed tnt showed by @Fluddershy.

    So on BlockPlaceEvent check if the item is custom tnt, save the location inside a hashmap, on an ignite event check if the blocks location is inside that hashmap, set the block to air and spawn primed tnt. Hopefully this helps.