I am working on a map that I want to test if a player breaks a spawner. Then it gives the player a spawner, and maybe some XP. I want to use a scoreboard command, but /scoreboard objectives add SB stat.mineBlock.minecraft.mob_spawner doesn't work even though the spawner ID is mob_spawner. What is the correct way to write this?

(Forgot: I need it to be any spawner, natural or placed :P )

  • Well, I have a solution in mind, but the naive approach requires over 730 (or really (2n+1)^2+x, and in this case, n=4) command blocks, and cutting that down to something manageable might mean the process takes too long. I'll have to give it more thought.
    – MBraedley
    Oct 23 '15 at 0:03

If you have multiple spawners, but every single one is known to you (as opposed to natural world generation), I suggest manually summoning an armor stand with a custom name at the position of every single one, e.g. using

summon ArmorStand x y z {CustomName:"ZombieSpawner",Marker:1b,Invisible:1b,NoGravity:1b} 

Afterwards, use the detect scheme of the execute command to detect an air block.

execute @e[type=ArmorStand,name=ZombieSpawner] ~ ~ ~ detect ~ ~ ~ minecraft:air -1 <command @p>
execute @e[type=ArmorStand,name=ZombieSpawner] ~ ~ ~ detect ~ ~ ~ minecraft:air -1 kill @e[type=ArmorStand,name=ZombieSpawner,c=1,r=1]

Use differently named markers for different spawners if necessary.

Automating the placement of these armorstands is possible, but I can't think of a way to do so quickly and/or lag-free.

  • Thank you, MrLemon, for this, but :P This is needed for natural world generation. I shouldve been more specific, sorry Aug 19 '15 at 21:26
  • I changed the question: 6:03pm central Americia Aug 19 '15 at 23:03
  • @RoyalGaming369 Okay. I'll let this stand since it might be useful to other users. If I can come up with a way to detect spawners automatically, I'll update the answer
    – MrLemon
    Aug 20 '15 at 7:36
  • Thanks, it would be more efficient to mine the spawner and get it then say, having four command blocks on a timer testing for a spawner ~1 ~ ~, ~-1 ~ ~, ~ ~ ~1, ~ ~ ~-1, and then a comparator giving the player a spawner, then clearing the spawner with /setblock. People could walk near, then run away and glitch it out, so I prefer the mining it technique... Aug 20 '15 at 15:27

If it's just a single spawner, not multiple, you can use /testforblock

See here for full reference

  • Well, I want it to be, you find a spawner in the nether, or in a dungeon, and you break it and get a spawner. (It would be a pig spawner, but Im ok with that, infinite food :D ) Would this be possible? Aug 19 '15 at 21:28

If you're OK with using mods, from what I remember Craftable Spawners makes spawners actually drop iron bars. You could check the inventory for them. The problem would be that you could not keep apart spawners and iron bars, but you could use some custom structure worldgen mod that adds a world type where ONLY custom structures are generated, and add each structure as custom structure, but without iron bars. And you could use a mod for crafting recipe blocking, and disallow all iron bar crafting recipes. If such a solution is considerable, you should check out PlanetMinecraft - that forum has an insane amount of different mods, and some combination will surely fit your needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.