3

I am trying to make better looking explosions in minecraft. I use this command to detect PrimedTnt where the explosion happens (x=-272 y=58 z=-1844)

testfor @e[type=PrimedTnt] [x=-272 y=58 z=-1844]

But it gives me this error message:

[20:48:37] Data tag parsing failed: Invalid tag encountered, expected '{' as first char.

Why does this happen? Also, what can I do about it?

5

When using selectors, all of the arguments go between the same pair of square brackets and are separated by commas. What you wanted to do is probably this:

testfor @e[type=PrimedTnt,x=-272,y=58,z=-1844]

You're getting the error message because you've made [x=-272 y=58 z=-1844] an argument of its own, not part of the selector. As it happens, the second argument for testfor is NBT data. The correct syntax to specify NBT data would, as the answer above says, be {x:-272,y:58,z:-1844}.

HOWEVER no entity has an "x" int, a "y" int, and a "z" int in it's data. Although it's the correct syntax and won't cause an error, it will never match an entity. The correct tags for specifying location with the NBT argument would be this:

testfor @e[type=PrimedTnt] {Pos:[-271.5,58.5,-1843.5]}

The chances are you didn't want to do that though, as it'd test only for that very specific point in space and nothing else. The solution is the first command I gave, where all of the arguments are in the square brackets.

5

The error message already gives you a hint to what is wrong:

expected '{' as first char

You only have your syntax a little wrong:

testfor @e[type=PrimedTnt] {x=-272,y=58,z=-1844}

Notice the curly braces and the commas between the coordinates.
But notice, the command above is not very pretty. A more reliable and readable would be as follows:

testfor @e[type=PrimedTnt,x=-272,y=58,z=-1844,r=2]

This gets rid of the data tag, and can use the radius.

  • I will try it tomorrow – codermaster Dec 12 '14 at 21:06
  • It does work as command (syntax is okay) but the comparetor never gets activated, even when i tried with the radius testfor @e[type=PrimedTnt] {x=-272,y=58,z=-1844,r=2} but then it gave me an error: [14:52:01] Data tag parsing failed: Unable to locate name/value separator for string: x=-272,y=58,z=-1844,r=2 – codermaster Dec 13 '14 at 13:54
  • Colorfusion already answered the question, but I still added a solution to your comment ;) – Lars Dec 14 '14 at 16:28
  • thx bro you deserve a 1 up as well – codermaster Dec 14 '14 at 17:42
0

SirBenet's answer is correct in a sense, but not entirely. You must use tnt rather than PrimedTnt. Also, instead of having the coordinates in curly brackets {} they should still be in the brackets next to the item name, separated by a comma. So, what you want to do now is this:

@e[type=tnt,x=-272,y=58,z=-1844].

Also note, the command will not function without a specified radius, be it 1 or more. So, if you want that block, use r=1. For any area specified around that one block (up, down, left, right, diagonally, etc.) use r=2 or any other number (keep it below 1,000 as it will get very laggy). So, the final command would be this:

/testfor @e[type=tnt,x=-272,y=58,z=-1844,r=1].

For a full list of the entity names and data values including tnt, visit The Minecraft Wiki:

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.