2

Trying to use command blocks to check if all mobs in an area have been killed.

Tried several commands, apparently my syntax is off, but no where can I find the proper usage.

How do I check to see if all mobs have been killed in a radius?

I've seen some solutions using an inverter, but I'd prefer to use command blocks for space, plus I also wanna learn how to use them.

Commands I've tried:

/testfor @e[type=PigZombie, x=1000, y= 125, z=941, !r=12]
/testfor @e[type=PigZombie, !(x=1000, y= 125, z=941, r=12)]
/testfor !@e[type=PigZombie, x=1000, y= 125, z=941, r=12]
1

The wiki has an explanation of how to implement each command.

For your command, the example is written like this:

To count the number of zombies within a 20-block radius of (0,64,0): testfor @e[0,64,0,20,type=Zombie]

So your command should look like this:

/testfor @e[x=1000, y= 125, z=941, r=12, type=PigZombie]

Note: the use of the ! ("not") doesn't seem to apply in the syntax for the Minecraft commands, therefore, if you want to invert the command (or atleast invert the use of the command), you'll have to use redstone for that.

Eg. (as from the comments) if you want to do something when it doesn't detect any Pigmen, you'll have to invert the redstone signal that is emitted.

  • Hmm not sure where the not is coming from then thought I saw it in some sample examples. Yeah I read that and know how to test for zombie pigmen being in an area and that is working succesfully, but the issue is I have that connected to another command block set to conditional and I want it to only fire if there are no zombie pigmen in the area which is why I need to test for the lack of an enemy not if there are some – kalenpw Apr 11 '16 at 6:12
  • Unfortunately in that case you'll likely have to reverse the input signal for the other command block. I.e. when it does detect the Pigmen, the signal turns off, and when it doesn't detect them, it turns back on again. – Ben Apr 11 '16 at 6:16

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.