/testfor finding item in item frame help?

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?
Best Answer
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]}}
Pictures about "/testfor finding item in item frame help?"



How do you find the item frame of an item?
Detecting item frame position These could have decimal parts and will definitely not work. Instead, use the NBT tags TileX , TileY , and TileZ . These represent a block location and are integers. /execute if entity @e[type=item_frame,nbt={TileX:12,TileY:23,TileZ:34}] run say Item frame in correct position.How do you Testfor entities in Minecraft?
2. Type the CommandDo items Despawn in item frames?
Item frames no longer despawn when the player moves 20 blocks away. Items renamed using an anvil now display their name when looked at up close.How do you get invisible item frames in multiplayer?
Players on Minecraft's Java Edition have a simple command that will enable them to get invisible item frames. All they need to do is open their chat console and type "/give @p item_frame{EntityTag:{Invisible:1b}}" which should place the item within the player's inventory, allowing them to place it wherever they wish.Minecraft Bedrock - Test For Items In Inventory (Mobile/Xbox/PS4/Windows 10/Switch)
More answers regarding /testfor finding item in item frame help?
Answer 2
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
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Max Vakhtbovych, Tara Winstead, Max Vakhtbovych, Max Vakhtbovych