Advertisement
Skylinerw

@The8BitMonkey

Dec 16th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. PREREQUISITES:
  2.  
  3. Objective to hold the result from AffectedBlocks.
  4.  
  5. /scoreboard objectives add FoundSpawner dummy
  6.  
  7. AffectedBlocks trigger to apply to player. May need to be on a clock if new players can enter. Players running commands will set their own "FoundSpawner" score equal to the number of 'affected blocks', when applicable.
  8.  
  9. /stats entity @a set AffectedBlocks @a[c=1] FoundSpawner
  10.  
  11. In order for CommandStats to modify a target's score, they must be tracked prior. This may also need to run on a clock.
  12.  
  13. /scoreboard players add @a FoundSpawner 0
  14.  
  15. CLOCK:
  16.  
  17. Image reference: http://i.imgur.com/BfPQWpH.png
  18.  
  19. 1. Cause players to run a command that will update their own AffectedBlocks score, being /testforblock. This checks for a specific spawner, setting the player's "FoundSpawner" score to 1 if found.
  20.  
  21. /execute @a ~ ~ ~ testforblock ~ ~-1 ~ minecraft:mob_spawner -1 {SpawnData:{id:"Zombie"}}
  22.  
  23. 2. Conditional. If /execute was successful, the player would logically have a "FoundSpawner" score of 1. You'd then target players with that score, which would only be those that had a zombie spawner beneath them. The benefit of using conditional here is to prevent the selector from being processed unnecessarily, but it doesn't necessarily have to be conditional.
  24.  
  25. /execute @a[score_FoundSpawner_min=1] ~ ~ ~ say Found zombie spawner.
  26.  
  27. 3. Second cycle, checking for a skeleton spawner. Their score is set to 0 if it wasn't found, so works without conflict from the previous set of commands.
  28.  
  29. /execute @a ~ ~ ~ testforblock ~ ~-1 ~ minecraft:mob_spawner -1 {SpawnData:{id:"Skeleton"}}
  30.  
  31. 4. Conditional. Same as #2, the commands to perform based on the success.
  32.  
  33. /execute @a[score_FoundSpawner_min=1] ~ ~ ~ say Found skeleton spawner.
  34.  
  35. 5. Third cycle (spider spawner).
  36.  
  37. /execute @a ~ ~ ~ testforblock ~ ~-1 ~ minecraft:mob_spawner -1 {SpawnData:{id:"Spider"}}
  38.  
  39. 6. Conditional. Success command.
  40.  
  41. /execute @a[score_FoundSpawner_min=1] ~ ~ ~ say Found spider spawner.
  42.  
  43. SPAWNERS:
  44.  
  45. Copy/paste spawners for testing:
  46.  
  47. Zombie: /setblock ~ ~1 ~ minecraft:mob_spawner 0 replace {SpawnData:{id:"Zombie"}}
  48. Skeleton: /setblock ~ ~1 ~ minecraft:mob_spawner 0 replace {SpawnData:{id:"Skeleton"}}
  49. Spider: /setblock ~ ~1 ~ minecraft:mob_spawner 0 replace {SpawnData:{id:"Spider"}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement