1

I want to testfor a sheep, by the name of Lamb, in a certain location using coordinates.

I have already tried this:

testfor @e[x=999,y=80,z=-1034,type=Sheep,name=Lamb]

But it doesn't work. I have also tried:

testfor @e[x=999,y=80,z=-1034,type=Sheep]

But it says it found a sheep whether or not there is actually a sheep in that location.

  • 1
    Whatever it is you're doing, you probably don't want to be using testfor. testfor isn't completely useless in 1.9, but there's often better alternatives. – MBraedley Feb 23 '16 at 12:27
4

The x, y, and z parameters only change the origin of the search. To check for targets within a certain range of that origin, you will need to use selection limiters like r (radius, number of blocks in each direction from the origin to find a target):

/testfor @e[x=999,y=80,z=-1034,r=1,type=Sheep,name=Lamb]
  • I tried using that command as well but the output claims that it is an unknown command. – Themadtadder Feb 23 '16 at 23:46
  • @Themadtadder Ensure your command block is being activated correctly. If you're using a comparator clock, the signal closer to the comparator only reduces in signal strength rather than turning off. You'd need to increase the distance between the comparator and command block. – Skylinerw Feb 23 '16 at 23:58
  • Currently I am using a repeater to power the command block. The repeater that is powering the command block is also connected to a repeater clock. The block is activating correctly because I first put in a "say" command, to test if the command is being activated, and it says the message. – Themadtadder Feb 24 '16 at 0:09
  • @Themadtadder I can't currently check, but if I recall correctly, a selector that has the possibility of targeting multiple entities but found none will result in no error message at all (and in pre-1.9, the last output will not change from what it was prior). You'll also have to ensure that there is a sheep named "Lamb" within 1 block of those coordinates. – Skylinerw Feb 24 '16 at 0:19
  • I am terribly sorry Skylinerw, your command worked perfectly. The problem that ran into was that the sheep that i was trying to find did not have the name capitalized. – Themadtadder Feb 24 '16 at 0:21

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.