Advertisement
Skylinerw

@TheBeast0911 - Detecting Item Distribution

Jul 19th, 2014
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. Refer to: https://www.youtube.com/watch?v=QLm6nAyj52o
  2.  
  3.  
  4. PREREQUISITES:
  5.  
  6. /scoreboard objectives add ITEMS dummy
  7.  
  8.  
  9. CLOCK COMMANDS (in order of viewing in video):
  10.  
  11. /stats entity @a set AffectedItems @p ITEMS
  12. /scoreboard players add @a ITEMS 0
  13. /execute @a ~ ~ ~ clear @p minecraft:stone 0 0
  14.  
  15. /scoreboard players set #TOTAL ITEMS 0
  16. /execute @a ~ ~ ~ scoreboard players operation #TOTAL ITEMS += @p ITEMS
  17.  
  18.  
  19. DETECTION COMMANDS:
  20.  
  21. /scoreboard players test #TOTAL ITEMS 20 *
  22.  
  23. /tellraw @a "There are at least 20 stone distributed among players."
  24. /tellraw @a ["(A total of ",{score:{name:"#TOTAL",objective:"ITEMS"}}," stone was found)"]
  25.  
  26. EXPLANATION:
  27.  
  28. The "AffectedItems" CommandStat is applied to all players. When they are affected DIRECTLY by an item-affecting command (such as /give, /clear, /replaceitem), the specified target and objective score will be set to the number of items affected. /execute must be used in order to have the player directly affect their inventory. The /clear command removes 0 of regular stone, but their CommandStat sets their own "ITEM" score to the number of total MATCHING items. In this way, their inventory will not be cleared, but will still have the proper score.
  29.  
  30. While you can use that score itself on a per-player basis, if you want to combine inventories of players, you would have to have their totals condensed into a single players' score. All players are executed a /scoreboard command that will add their "ITEMS" score to the fake player "#TOTAL"'s score. That fake player will be what you test in order to detect a minimum or maximum number of items distributed among players.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement