How do I spawn primed tnt?

Discussion in 'Plugin Development' started by wizard7611, Dec 6, 2013.

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


    I'd like to know how to spawn primed tnt when a dispenser is activated by redstone. Please help! Thanks!
  2. Offline


  3. Offline


    Something like this:
        public boolean onCommand(CommandSender sender, Command cmd, String label,
                String[] args) {
            if (sender instanceof Player) {
                Player p = (Player) sender;
                    int loop = Integer.parseInt(args[0]);
                    while (loop > 0)
                        Entity tnt = p.getWorld().spawn(p.getTargetBlock(null, 50).getLocation().add(0, 1, 0), TNTPrimed.class);
                    return true;
            return false;
    This is a snippet from one of my plugins, it spawns primed TNT wherever you're looking at, with 200 ticks as the "fuse".

    The loop is there to spawn more than 1 TNT from the first command argument. So "/somecommand 10" would make it loop 10 times, spawning 10 primed TNT. (Bukkit wouldn't let me edit my last post :/)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 5, 2016
  4. Offline


    1. for(int i = 0; i < HOWMANYTIMES; i++){
    2. System.out.println(">> " + i);
    3. //Spawn the tnt here
    4. }
Thread Status:
Not open for further replies.

Share This Page