I think the title explains it all. How would I do this? Code (Text): public void dispenseEvent(BlockDispenseEvent e){ TNTPrimed tnt = //how would I get this? } Could I somehow find out a way to cast the tnt item to the tnt entity (am I saying that the wrong way around? ), because this gets called when tnt is launched from a dispenser. Code (Text): if(e.getItem().getType().equals(Material.TNT)){} Edit 1: I could also get the dispenser from the tnt. I just need to figure out which tnt corresponds to which dispenser. Edit:2 Anyway to have data carry on from the tnt item to the tnt entity? If I could do this if would fix my problem
#1 as stated TNTPrimed is an entity, while BlockDispenseEvent#getBlock() returns a block, therefore => ClassCastException #2 getBlock returns the dispenser, NOT the dispensed item @TO: BlockDispenseEvent only works for dispensed items (ItemStacks). However fireballs, tnt, snowballs(?) etc. are launched entities, you can't get them from the event. Maybe try to use ProjectileLaunchEvent or similar.
ProjectileLaunchEvent only works for entities launching entities, not blocks launching entities :,( Edit: TNT is not considered a projectile.
I thought of ExplosionPrimeEvent, but that's only called if the TNT already exploding... Sorry, no idea.