How can I get count of spesific item in players inventory?

Started by alparda112 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How can I get count of spesific item in players inventory?

Hello,

So I made a "weight" item and the amount of this item in a players inventory is important for me. But I can't find a way to count the number of  item:weight in  players inventory...  I searched a lot but couldn't find anything about this topic. Help is appreciated a lot. 

Use for each item in entity…
Fri, 02/12/2021 - 10:03

Use for each item in entity inventory and check if item is of desired type, and if it is, increment local variable storing count for the stack size of the itemstack iterator

Joined Jul 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@Klemen Can You Send A Photo…
Sun, 05/08/2022 - 09:55

@Klemen Can You Send A Photo Of Procedure ?

Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This code looks for any…
Thu, 11/27/2025 - 14:17

This code looks for any items in any entity's inventory and replaces it. In my case, it takes a modded turkey item and replaces it with my own custom turkey item. i have tested with vanilla items, this does garauteed work.

I will try to make a block entity version.

Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
nevermind the block entity…
Thu, 11/27/2025 - 14:18

nevermind the block entity thing isnt related to the original, im going to make a forum post about these