Ranged item, how do I make sure that gun only fires when I have ammo?

Started by SilphCoding on

Topic category: Help with Minecraft modding (Java Edition)

Active 2 years ago
Joined Feb 2023
Points:
305

User statistics:

  • Modifications: 0
  • Forum topics: 3
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 0
Ranged item, how do I make sure that gun only fires when I have ammo?

Also with this how could i make a magazine so it doesnt pull it out of inventory

 

I'm making my first mod and with it adding a pistol. Right now it removes the ammo from my inventory when I shoot but it still shoots even if I have 0 ammo. I also have tried to make a custom magazine but I'm not sure how.  I keep seeing something in a tutorial called provided itemstack but i dont know how it works. thanks!