1. Store the Items[0].Count data of the chest in a score Var1
2. Substract Var1 by 1 (using operations and dummy player who have a score of 1). Store result in Var1
3.If Var1 matches ..0 then set Items[0].id as "minecraft:air"
5. If there's no item in chest (unless data Items[0]), stop the process
4. Set chest's Items[0].Count as Var1 (which have been reduced by 1
5. Repeat these steps again until step 5 stops it.
Method 2 : count stacks (better)
-Set Var1 to 0 first
1. Unless Items[0] stop the process (if no items in chest)
2. Store Items[0].Count as Var2 score
3. Store Var1 + Var2 as Var1
4. Set Items[0].id as "minecraft:air"
5. Repeat until step1 stops the process
Total items are stored in Var1 in both cases
There's no complete command, but you get the idea...
Rollback Post to RevisionRollBack
I got into chiptune music composition.
You can listen to them on my Youtube channel : https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).
Here's the setup:
I put x items in a chest. I click a button. The chest gets cleared and my score on the say "Money" scoreboard goes up by x.
I need to do this on 1.15 and a lot of answers to do this seem outdated.
Well would be a repeated mcfunction :
Method 1 : count each item one by one :
1. Store the Items[0].Count data of the chest in a score Var1
2. Substract Var1 by 1 (using operations and dummy player who have a score of 1). Store result in Var1
3.If Var1 matches ..0 then set Items[0].id as "minecraft:air"
5. If there's no item in chest (unless data Items[0]), stop the process
4. Set chest's Items[0].Count as Var1 (which have been reduced by 1
5. Repeat these steps again until step 5 stops it.
Method 2 : count stacks (better)
-Set Var1 to 0 first
1. Unless Items[0] stop the process (if no items in chest)
2. Store Items[0].Count as Var2 score
3. Store Var1 + Var2 as Var1
4. Set Items[0].id as "minecraft:air"
5. Repeat until step1 stops the process
Total items are stored in Var1 in both cases
There's no complete command, but you get the idea...
I got into chiptune music composition.
You can listen to them on my Youtube channel :
https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).