Items on the ground clump together in stacks, so getting the number of entities doesn't give me the number of items there are. Is there a way to count the number of items instead of the number of item entities?
Minecraft Java Edition, Commands – How to Count Total Items on the Ground
minecraft-commandsminecraft-java-edition
Related Topic
- Minecraft Java Edition – How to Stop Items from Despawning
- Minecraft – Why does /execute store refuse to update an NBT number when provided with a scoreboard value
- Minecraft count entities
- Minecraft – How to detect an item on ground
- Minecraft Commands – How to Use /give Multiple Items Command in Minecraft?
Best Answer
First you need a scoreboard to store the amount of items per entity into:
Then you can easily transfer the stack size of every item entity into their "count" scoreboard like this:
If you want to do this only for a certain type of item, you can filter that as well:
Then you just need to add all those scores up to a shared score, for example yours:
Of course if you want to do this multiple times, you have to reset your score before the next repetition: