Minecraft Forge: Tips On Modding Weapons


Weapons are items. Like other items, when they are wielded in the player's hand they can be used to take action (i.e. attack).

If you want to mod weapons, make sure you are familiar with items including using the Item, ItemStack and EntityItem classes. I'll also assume you know how to register your item, create texture resources, etc.

Extending The Player's Weapon Reach ("Guns")

Check out Jabelar's Extended Weapon Reach Tutorial.

How To Detect If Weapon Is Being Held By Player

If it is your own custom item, you probably are writing code for the onUpdate() method. In that method, the last parameter is a boolean that represents whether the item is in the player's hands.

If you're writing code to detect whether a vanilla item is held, then you can use Player#getCurrentEquippedItem().

Adding NBT Data To Weapons

NBT data allows you to make an ItemStack unique. For example, maybe you want to give a sword a name, or have a weapon that has ammo or charges. NBT is perfect for that. 

See my item modding tips on how to add NBT data to items, including weapons.

Setting Up Weapon Models And Textures

This topic is already well covered by other tutorials. Check out TheGreyGhost's Item Rendering Tutorial.

Making A Custom Weapon Effect

Thanks to coolAlias for this tip.

For a continuous effect there is a built-in method that can be used: onUsingItemTick() (or just onUsingTick(), in 1.7.2), which is called every tick so long as you are using an item (i.e. you are continuing to hold right click and in onItemRightClick() you setItemInUse() for the player and you've been holding right click for a length of time less than the Item's getMaxUseDuration()).

Custom Weapon Actions (EnumAction)

Thanks to Choonster for this info.

EnumAction are used to control animations for items that are used over time. Like the swinging of a sword.

If you want similar behaviour to swords (hold right click to play an EnumAction@Override Item#getitemUseAction to return the appropriate action and call EntityPlayer#setItemInUse in Item#onItemRightClick like ItemSword does.

Choonster has made a working example.


  1. A debt of gratitude is in order for setting aside an ideal opportunity to talk about this, I feel emphatically about it and affection adapting more on this theme. On the off chance that conceivable, as you pick up skill, would you brain overhauling your online journal with additional data? It is to a great degree accommodating for me. Miami Firearms Training

  2. Ayee dude! Are you interested in new Minecraft server that you can play to get money? Checkout play. universemc. us. You can play the server to succeed upto $1, 000 UNITED STATES DOLLAR just for being the best player on the network! The network involves Factions, Prison, Skyblock, Kitmap and many more gamemodes! It includes big youtubers participating in on the network!