Minecraft command to set item frame content from a chest content

Solution 1:

Root cause: PEBKAC.

  • Make sure that you use the correct coordinates
  • Use NBT tags TileX, TileY, TileZ to select the correct target entity.
  • Use Items[{Slot: 0b}] as source slot selector instead of Items[0]
/data modify entity @e[type=minecraft:item_frame, limit=1, nbt={TileX:-129,TileY:78,TileZ:99}] Item set from block -127 76 105 Items[{Slot: 0b}]

The most likely cause for The target block is not a block entity error is that you did not select the correct source block or target entity. That's what I did wrong:

/data modify entity @e[x=-129,y=79,z=99,type=minecraft:item_frame,limit=1,distance=0..1] Item set from block -127 76 105 Items[0]

should have been:

/data modify entity @e[x=-129,y=79,z=99,type=minecraft:item_frame,limit=1,distance=0..1] Item set from block -121 76 105 Items[0]

Did you spot it? Congrats to you. It took me two hours to see that the x coordinate was off: -127 instead of -121 (If you need me, I'm overthere in the corner feeling stupid)

My suggestion to others who end up here with the same issue is to:

  1. Check that you can read data from the source block:

    /data get block -121 76 105 Items[0]
    
  2. Check that the correct target entity is selected:

    /data get entity @e[type=minecraft:item_frame, limit=1, nbt={TileX:-129,TileY:78,TileZ:99}]
    

Especially for the target entity, note that the coordinates are sometimes off:

  • Use TileX, TileY, TileX (in the nbt data) as entity selector instead of x, y, z.
  • The returned Pos(ition) is slightly different: -128.5, 78.5, 99.03. Consider using @e[x=-128.5,y=78.5,z=99,... as entity selector.
  • For /summon seems to be one-off in Y-coordinates compared to /data. To create the above item_frame entity, I had to specify y=78 instead of y=79: /summon minecraft:item_frame -129 78 99 {Facing:3, Item:{id:"minecraft:filled_map", tag: {map: 48}, Count: 1}}