Building a TNT cannon in Minecraft can be used as both an offensive and defensive weapon as it allows you to launch TNT great distances, helping you attack enemy players or defend your base. There are many different ways to design a TNT cannon, but the general concept is to use a piston to push a TNT block into a cannon barrel. When the TNT block reaches the end of the barrel, it will explode, propelling a second TNT block out of the barrel. This second TNT block will then explode, and so on. By chaining together multiple TNT cannons, you can launch TNT incredibly long distances.
TNT cannons are especially useful in attacking enemy bases, as they allow you to destroy structures from a safe distance. They can also be used to defend your base by launching TNT at enemy players who are trying to attack. While TNT cannons can be complex to design and build, they can be a very effective weapon in Minecraft.