testing if PrimedTnt exists in a block

testing if PrimedTnt exists in a block - Woman in Red Shirt Holding Her Face

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?



Best Answer

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.




Pictures about "testing if PrimedTnt exists in a block"

testing if PrimedTnt exists in a block - Brown and White Brick Wall
testing if PrimedTnt exists in a block - White and Brown Brick Wall
testing if PrimedTnt exists in a block - Woman in White Hijab Holding Clear Plastic Container





Fool-Proof Test for Primes - Numberphile




More answers regarding testing if PrimedTnt exists in a block

Answer 2

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:

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Pavel Danilyuk, Alex Tepetidis, Alex Tepetidis, Rizki Koto