Here's the code that sees if there's a book called Keys in the item frame.

/testfor @e[type=ItemFrame,r=10] {Item:{id:minecraft:writable_book,tag:{display:{Name:"Keys"}}}}

When I put this in I get the error:

[18:09:28] entity.ItemFrame.name did not match the required data structure

Can someone help fix my command?

  • Works fine for me. I copied the command you provided verbatim and, when in range, I get the message Found entity.ItemFrame.name (because the item frame itself doesn't have a name). Do you have other item frames nearby? – MBraedley Jul 11 '15 at 0:15
  • @MBraedley Having just a nearby item frame shouldn't matter. Only having a nearby on with the writable book in it, and there are non of those nearby. – Chickenator Jul 11 '15 at 8:42
  • It does matter, at least for /testfor (and some other commands) because you're trying to match data tags. I see the same error you're seeing when I have a second item frame with something else in it. – MBraedley Jul 11 '15 at 13:05
  • @MBraedley yeah I have 2 item frames, one with nothing in it. Maybe that's the problem then :/ – Chickenator Jul 11 '15 at 18:23
  • 1
    @MBraedley It should still give a success output with stats or a comparator, but the command block's output window (which only stores 1 output line) may be overwritten if the one that doesn't match is tested second. – SirBenet Aug 23 '15 at 11:42

You used the wrong entity name. A hanging itemframe is not called ItemFrame but item_frame.

So, the following command would work:

/testfor @e[type=item_frame,r=10] {Item:{id:minecraft:writable_book,tag:{display:{Name:"Keys"}}}}

Please note: this command checks the name given to an item. You are essentially looking for a writable book that has been renamed using an anvil. If your goal is however to check for a closed book with a title you should use the following command:

/testfor @e[type=item_frame,r=10] {Item:{id:minecraft:written_book,tag:[{title:Keys}][2]}}
  • 1
    This is NBT, not JSON. The : character is not a special character and does not break syntax. Strings do not require quotation marks unless the value breaks syntax or declares a different datatype, which isn't the case here. Adding quotes will not fix the command at all. – Skylinerw Jan 22 '17 at 19:44
  • @Skylinerw Weird, I could of sworn I tested it. But I might of done it on a server, could of possibly been a plugin...I'll update my answer. – user254948 Feb 12 '17 at 16:05

This is actually a command that troubled me for a long time too! But this command worked for me: /testfor @e[type=ItemFrame] {TileX:0,TileY:5,TileZ:1,Direction:2b,Item:{id:276s},ItemRotation:0b} Give it a try. It should work! And you should be able to recognise the ID, as the command you put in above is fairly complex. You seem to be a redstone geek like me. xD

  • 2
    This is a rather bad answer. You suggest a command that suddenly is location-bound rather than radius. In addition to that, your command adds extra checks for direction and rotation yet removes the check that the question asker had in it, the check of the title. Also not sure where you got the 276s but it does not match the item specified in the original question (Curiously enough, your command can be found using google. ) – user254948 Jun 9 '16 at 19:04

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.