For a map I'm making, there are skeletons that you have to shoot, kind of like a carnival game. But I want one to spawn only when there are none there, so they all don't pile up. Is there a way I can use /testfor to do this?

  • 1
    Why not use pressure plates? – boxspah Apr 29 '15 at 23:28
  • wow... I feel so stupid for not thinking of that. I guess I just thought of doing it with command blocks rather than anything else so I wasn't considering the options... – xXPikminXx Apr 29 '15 at 23:36

While DominatorX's solution is perfectly valid - the command you are looking for might look something like this:

/testfor @e[type=Mobtype*,x=x,y=y,z=z,r=r**]

*Mobtype would be replaced with the mob you are looking for, like Skeleton will search for skellies, and Zombie will search for zombies. Alternatively, if you don't need to specify the type of mob, you can remove the [type=Mobtype] all together. This will just search for any entity.

**this can be used to specify a specific location, and a radius around that location. Alternatively, you can just use r=r and it will test within the point of origin (the command block)

  • This may or may not be a stupid question, but are the *'s supposed to be in the actual command or was it just being used to explain? – xXPikminXx Apr 30 '15 at 1:10
  • @xXPikminXx yes they were just being used to explain haha. Sorry for the confusion :) – Ben Apr 30 '15 at 1:15
  • 1
    Mob types are Capitalized and Minecraft cares about that. – MrLemon Apr 30 '15 at 11:09


You're really overthinking the problem.

  • Yep. I really was. like I said, I was thinking of using command blocks and not considering the options.. – xXPikminXx Apr 29 '15 at 23:41
  • 1
    Yep, it's a thing among programmers too. Which is why my computer science teacher sorta dislikes <s>me</s> my style cuz I use too many objects :) – boxspah Apr 29 '15 at 23:43
  • 1
    Spot the programmer :P – Ben Apr 30 '15 at 2:10
  • Quote Henry Ford: "If you have a difficult problem, find a l̶a̶z̶y̶ ̶p̶e̶r̶s̶o̶n̶ programmer and they will find an easier way to do it." – boxspah Jan 4 '16 at 1:03

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.