Minecraft /testfor item rotated a certain way in an item frame

minecraft-commandsminecraft-java-edition

Is there a way to set a command block to detect if an item frame has a certain item in it rotated to a certain position?

Best Answer

A quick internet search yielded a video by Dragnoz.

The command he uses:

/testfor @e[type=ItemFrame] {TileX:-819,TileY:32,TileZ:-245,Facing:3b,ItemRotation:3b}

You would have to change the numbers to match your situation.


Update: The type has changed to item_frame. Also, you do not have to specify Facing, which will accept an item frame in the specified block facing any direction. Item rotation is a number between 0 and 7. You can also specify the item with the Item tag.

Here is a command which will run in 1.12.2:

/testfor @e[type=item_frame] {TileX:<x>,TileY:<y>,TileZ:<z>,ItemRotation:0b}

Here is the wiki on item frame data values for more information.