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

Started by SilphCoding on

Topic category: Help with modding (Java Edition)

Last seen on 06:41, 10. Aug 2023
Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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!