0

This question already has an answer here:

I'm trying to test for a specific item in an item frame and I'm sure I have the correct code.

/testfor @e[type=Item_Frame,x=-1285,y=72,z=788}] {Item:{id:minecraft:leather}}

However I get this error:

[02:46:44] Data tag parsing failed: Expected '}' but got ':' at: {Item:{id:minecraft:<--[HERE]

This is a fairly simple code. I follow the 'mold' everyone else is using for this specific testfor command, but I get an error. There may be a different way to write it 1.12?

Thanks in advance for the help!

marked as duplicate by greg-449, galacticninja, Joachim, Virusbomb, MBraedley Jul 10 at 14:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @Fabian you answered with "pretty sure" and I explained it further. Go ahead and edit your answer then. I don't see a reason to answer this question twice only to describe the behavior. – dly Aug 14 '17 at 14:26
  • Done. But why did you delete your comment? Also my two points were separate from each other: 1. Usually you could write something like that as your own answer. 2. In this case I already wrote it, so I thought you were just repeating yourself. Now that you said that you were sure where I was not, I edited my answer. But in that case it would have been better as a comment to my answer, not to the question. – Fabian Röling Aug 14 '17 at 14:33
  • Was not aware of the quotes! Thank you for pointing that out Fabian! Also, Anvil, good eye with the extra '}' in [type=Item_Frame,x=-1285,y=72,z=788}] . Somehow the code worked despite this extra curly. It was a burning question keeping me up at 2am! – Neap Congo Aug 14 '17 at 18:56
2

You had an obsolete } in the target selector. But probably you didn't have that in the game, because then your error message would have been different.

Your real issue: Since 1.9 you need quotes around the item ID:

/testfor @e[type=Item_Frame,x=-1285,y=72,z=788] {Item:{id:"minecraft:leather"}}

1.13 syntax:

/execute if entity @e[type=item_frame,x=-1285,y=72,z=788,nbt={Item:{id:"minecraft:leather"}} run <command>

You can also leave out run and the command if you just want a chat output.

  • I believe its ItemFrame and without that } after the z coordinate. Also it should work without the count. – dly Aug 14 '17 at 8:36
  • 1. No, since 1.9 it's item_frame and capitalization doesn't matter. 2. You're correct with the }. In that case the error message in the question is wrong. – Fabian Röling Aug 14 '17 at 8:55
0

That error is specifically pointing to the portion the error was flagged for.

Look at this portion:

{Item:{id:minecraft:leather}}

The portion after id: should be in quotes, so: {Item:{id:"minecraft:leather"}}. Without quotes it is trying to parse the : after minecraft as code.

So the error is telling you, it Expected '}' but got ':'


Another problem I see with the command is in the target selector

@e[type=Item_Frame,x=-1285,y=72,z=788}] 

The last two characters, there is an unneeded } after 788.


The command with both problems fixed is:

/testfor @e[type=Item_Frame,x=-1285,y=72,z=788] {Item:{id:"minecraft:leather"}}

I have tested it in a command block with a comparator output and it functions properly.

Not the answer you're looking for? Browse other questions tagged or ask your own question.