Counting a specific type of items in the inventory and adding it as a variable.

Started by LiteralGamingDev on

Topic category: Help with Minecraft modding (Java Edition)

Joined Nov 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Counting a specific type of items in the inventory and adding it as a variable.
Tue, 11/23/2021 - 00:21 (edited)

Hello, I am new to modding on MCreator, and modding in general.

I need help counting an amount of a specific item in the inventory and setting it as a variable. For example Gems. Lets say I'm making Gems and adding a tracker on the screen, I know how to add it to the screen, but not how to get the tracker working and properly displaying how many you have within your inventory.

Also maybe how to delete them from your inventory after you pick them up while still tracking how much, but if not that's completely fine. Or maybe a work around all of this if possible.

Thank you.

Edited by LiteralGamingDev on Tue, 11/23/2021 - 00:21
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can iterate through an…
Tue, 11/23/2021 - 13:44

You can iterate through an inventory, 
first set the variable to 0
and when the item iteration is equal to that item increase the variable by the amount of that item.

I recommend using player variables and iterate through each player using the world tick, however if you are just trying to learn something, i recommend using the player tick update.
 

Joined Nov 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay thank you very much!
Wed, 11/24/2021 - 02:04

Okay thank you very much!