1. Setup
Before using the commands, you must create the scoreboard objective mentioned in the script:
/scoreboard objectives add item_count dummy "Item Counter"
/scoreboard objectives setdisplay sidebar item_count
2. How to Count a Chest
Use this command to scan a container (chest, barrel, hopper) at specific coordinates:
/scriptevent my:count <x> <y> <z>
<button class="FTsWP RmjGdc IsqrXb" aria-label="Copy code text to clipboard." data-sfc-cp="" data-wiz-attrbind="disabled=wBBBTb_1i/ggNWmb" data-sfc-root="c" data-sfc-cb="KjsqPd=&wBBBTb_1h:UEmoBd" data-complete="true" data-copy-service-computed-style="font-family: Arial; font-size: 13.3333px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(173, 175, 184);">
</button>
<button id="" class="FTsWP RmjGdc IsqrXb" aria-label="Copy code text to clipboard." data-sfc-cp="" data-wiz-attrbind="disabled=wBBBTb_1i/ggNWmb" data-sfc-root="c" data-sfc-cb="KjsqPd=&wBBBTb_1h:UEmoBd" data-complete="true" data-copy-service-computed-style="font-family: Arial; font-size: 13.3333px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(173, 175, 184);"></button>
- Example:
/scriptevent my:count 10 64 10
- Result: The scoreboard will show entries like
c_10_64_10: iron_ingot with the total amount found in that chest.
3. How to Count a Player's Inventory
Use this command to scan the inventory of the person who runs it (or the person targeted by a command block):
/scriptevent my:count_player
- Example: Run this in chat.
- Result: If your name is "Steve" and you have 5 Apples, the scoreboard will show
Steve: apple 5.
4. Key Features
- Automatic Cleanup: If you remove all diamonds from a chest and run the command again, the
diamond entry will be deleted from the scoreboard automatically.
- Short Names: It automatically removes the
minecraft: prefix to keep the scoreboard tidy (e.g., minecraft:dirt becomes just dirt).
- Persistent Totals: It sums up all stacks. If you have three stacks of 64 cobblestones, it will show a single entry with the value
192.