This is the data pack that I made in a let's code video, where I go through the whole process of making a certain data pack. I showcase the cannon at the beginning of the let's code video.
Make sure to install the resource pack.
If you do not want to watch the video, here are written instruction for use:
1. Craft by throwing 3 iron blocks and 3 oak planks onto the ground.
2. Place the cannon down while facing your target
3. Load the cannon with one iron ingot and one gunpowder
4. Use a torch to light the cannon and fire it off
5. You can destroy the cannon in the same way as an armorstand, it drops two iron blocks and two oak planks.
Here is the video with the showcase and how I made it: