How do you detect item count in inventory

Started by IndigoTail on Tue, 12/03/2019 - 14:55

Topic category: Help with MCreator modding

Last seen on 02:24, 8. Dec 2019
Joined Nov 2017
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
How do you detect item count in inventory
Tue, 12/03/2019 - 14:55

I have made a firearm magazine system in my mod, but I want the system to, for example, automatically reset ammo count to 30 (for rifle mags) if the ammo item exceeds 30.

Is there a way to detect the amount of a certain item in a player's inventory?

0Upvote this forum topic
Last seen on 10:15, 12. Dec 2019
Joined Aug 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
No, but you could make an if…
Tue, 12/03/2019 - 19:39

No, but you could make an if statement to test if the player has the item, remove one, test again, and remove another, and repeat this as many times as is necessary. If it is false at any point in it, you just need an else giving the player the appropriate amount of the item. Hopefully this will be added as an actual feature in the future.

0Upvote this forum topic
Last seen on 02:24, 8. Dec 2019
Joined Nov 2017
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Thanks, I'll definitely try…
Wed, 12/04/2019 - 14:30

Thanks, I'll definitely try that out

Screw me sideways I have an ammo type called "LMG Box ammo" which has over 50 rounds

0Upvote this forum topic
Last seen on 02:24, 8. Dec 2019
Joined Nov 2017
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Still need some…
Wed, 12/04/2019 - 14:33

Still need some brainstorming to make it work, but it sounds viable

0Upvote this forum topic