Skylinerw

EmptyChest

Oct 17th, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. Intention: cause each relevant shulker to look for an empty shulker box at their location, set their score to 1 if it's empty, and then play particle effects at those shulkers as a testing indicator.
  2.  
  3. Video demonstration: https://www.youtube.com/watch?v=1aPNRYKRIGM
  4.  
  5.  
  6. **Prerequisites:**
  7.  
  8.  
  9. Objective to track the return value of CommandStats in.
  10.  
  11. /scoreboard objectives add EmptyChest dummy
  12.  
  13. Example shulkers to summon. Make sure you summon them in the same blockspace as chests, and have some chests include items and have other chests be empty. The shulkers come pre-loaded with CommandStats, and will target their own "EmptyChest" score. You will not need to use /stats because of this. When the shulker runs a command, their relevant CommandStats are triggered.
  14.  
  15. /summon Shulker ~ ~1 ~ {NoAI:1b,Tags:["chest_marker"],CommandStats:{SuccessCountName:"@e[type=Shulker,c=1]",SuccessCountObjective:"EmptyChest"}}
  16.  
  17. In order for CommandStats to modify the target's score (the target being the selector in "SuccessCountName"), that target must be tracked on the scoreboard prior. If they are not tracked, they have no score, and CommandStats will fail. **This command may need to be on a clock if new shulkers can be introduced into the world at any point.** All this does is adds 0 to their score, which does not change their score but instead forces them to be tracked with a default score (the default being 0, unrelated to the 0 in the command).
  18.  
  19. /scoreboard players add @e[type=Shulker,tag=chest_marker] EmptyChest 0
  20.  
  21.  
  22. **Clock commands:**
  23.  
  24.  
  25. The following must be run in numerical order on a clock. If you do not run them in the correct order, the system is highly likely to break, especially if you are causing the shulkers to run other commands elsewhere. As well, be aware that the score display on the sidebar is **not** a good reference for their current score, which will change as they continue to run other commands during the same tick after this clock finishes. Therefore, you should **only** use this clock for score verification, **not** the sidebar.
  26.  
  27. 1. Cause shulkers to run a `/testforblock` command, looking for chests that have an empty `Items` tag at their location. After they run the command, their CommandStats are triggered, causing them to set their own "EmptyChest" score equal to the number of successful iterations of the command they run (in this case, 0 for failure and 1 for success).
  28.  
  29. /execute @e[type=Shulker,tag=chest_marker] ~ ~ ~ /testforblock ~ ~ ~ minecraft:orange_shulker_box -1 {Items:[{}]}
  30.  
  31. 2. Now any shulkers with an "EmptyChest" score of 1 are those that have an empty chest at their location. You can then target them based on that score to, for example, play particle effects at their location:
  32.  
  33. /execute @e[type=Shulker,tag=chest_marker,score_EmptyChest=0] ~ ~ ~ /particle mobSpell ~ ~ ~ 0.1 0.1 0.1 0
Add Comment
Please, Sign In to add comment