First things first:
-I assume you have Java knowledge. I'm not saying you should leave now if you don't know Java very well, but I will use terms in Java, because program in Java for Java game development, with Minecraft being a bonus
-I assume you know the basics of ModLoader, how to add texture overrides to items, etc.
-I assume you know (at least a little) about how Minecraft works in the code so that you know why you're extend from other classes like 'Item' or 'Entity'.
Now, it's hard to make something when you don't know what you're making. Because of this I'm going to briefly go over how the gun will work in the game.
The gun will be crafted (Recipes are completely up to you) as well as a clip of ammo for that gun. When the gun shoots it looses durability. When the gun shoots and only has one durability left then it doesn't do anything unless you have a clip in your inventory. If you do have a clip then the gun will play a countdown timer, and once the gun is done with the reload counter it removes the clip from the inventory, resets the timer, and the guns durability, as well as playing a reload sound. Once a person asked me why the gun looses durability instead of the clip. Well there are two reasons. First of all, I am unsure if I have the correct object access to actually damage the clip. (AKA, I don't think I could even if I wanted to) Second of all, the gun loosing durability creates a sort of 'ammo' bar, that is always visible, even if you need to put your clips in the upper half of your inventory, instead of the hotbar. When the gun shoots it creates an invisible projectile. This projectile is very accurate and doesn't not loose velocity like a bow. Because the projectile is invisible we will be playing a custom sound effect to help the user regonize that he/she just shot a bullet. You can use this link to learn more about using custom sounds without using extra mods like AudioMod. (I'm not saying this is the best way, but I know some people like me would definately prefer it)
I'm also going to (try) and use good Object-Orientated programming practices in this tutorial. For those of you who aren't entirely sure what I mean by this, it basically means we're going to create a gun class that can be used to create an infinate amount of guns, each with their own fire speed, ammo per clip count, damage delt against entities, required item for a clip, fireing sound, and reloading sound.
Ok! Now that we got all that out of the way we can (finally) start coding!
First let's create a new class called EntityBullet. I'm not as farmiliar with the bullet class as I am with the gun class because I'm not very good at projectiles, so I will explain to you guys what you need to know about the bullet class, and if you're any good at Java you could try and figure out how Notchs velocity methods and whatnot work.
Notice that the 4th constructor (the constructors are the ones that say 'public EntityBullet()', and are called whenever we create a bullet) has 4 parameters. This constructor is what we use to create bullets in our gun class. The first parameter will be the current world, the second parameter will be the player, the third parameter is the damage, and the fourth parameter is the accuracy, which hiloser12221 said didn't seem to have any effect so I just set it to '1'.
Now we get to the fun stuff. I highly encourage you to experiment with this gun code, adding modifications to make it your own. You could have no reloading and make it so that it takes away bullets like arrows. You could have multiple bullets come out for a shotgun type thing. You could have an accuracy parameter in the constructor and use position methods for modify the x, y, and z values of the bullet slightly in order to add accuracy or knockback. It's all up to you! First let's learn about making the basic gun, however.
Finally we create the mod_***** file, which is pretty simple stuff provided you haven't just been copy/pasting your way through the whole tutorial...
I hope you guys enjoyed this tutorial, and if you have any questions please feel free to post, I will get to them we I can. Finally, if you have any suggestions for new tutorials, I would like to hear them. Nothing huge like dimensions, but if I get enough requests I could do a grenade tutorial!