First of all, treat me as a jNoob with decent C++ Experience: I am making a method that finds all Primed TNT entities and removes them. My method has one parameter, world (Type World). How should i do this? Please, if you are going to give me code, give me a explanation I want to learn so i don't have to ask so often. jNoob JavaNoob = Algo160;
World object has a getEntities() method which gives you a list of entities... you can loop through that and check if entity is instanceof TNTPrimed then do whatever with it. I hope you're using an IDE because it greatly helps, expecially by showing you available methods. Unless you're trying to cleanup primed TNTs on command, using this to prevent TNTs from blowing up is a really bad way, if you want to prevent TNTs from blowing up then just listen to the ExplosionPrimeEvent.
Digi It does remove the tnt and it listens to ExplosionPrimeEvent It only prevents tnt from blowing up..... I need the code to. Cant do loops Err What did i just say? Makes no sense EDIT by Moderator: merged posts, please use the edit button instead of double posting.
So i am working on a plugin (TNT H8R) and 2 methods: HateWrapper(); Calls hate(); on all the worlds. Hate(); Loops and gets entities of the world, if any TNT primed it removes them (before it explodes i hope) Listeners: onPrimed onBlockInteract Both call HateWrapper(); Hellsing Tried the one on the BukkiWikki (BukkitWiki as most call it). Not helpful. What do you think i should look at? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Use the ExplosionPrimeEvent and then the following: Code: if (event.getEntity() instanceof TNTPrimed) event.setCancelled(true);
Nope, this will block all tnt explosions from every world. If you want to block it per world, use if (event.getEntity.getWorld().equals(world)) // Bla bla bla