In Minecraft Java 1.16, I can use the /data get block
command to get the contents of a chest:
/data get block -121 76 105 Items[0]
Which tells me that the chest has one map#48 in the upper-left slot:
-121, 76, 105 has the following block data: {Slot: 0b, id: "minecraft:filled_map", tag: {map: 48}, count: 1b}
Also, I can use /data modify entity .. set value
command to set the contents of an existing item frame:
/data modify entity @e[x=-129,y=79,z=99,type=minecraft:item_frame,limit=1,distance=0..1] Item set value {id:"minecraft:filled_map", tag: {map: 48}, Count: 1}
Voila, the item_frame now contains a filled_map!
What's more, it also works if I add the spurious NBT data, like a Slot tag:
/data modify entity @e[x=-129,y=79,z=99,type=minecraft:item_frame,limit=1,distance=0..1] Item set value {Slot: 0b, id:"minecraft:filled_map", tag: {map: 48}, Count: 1}
So I was hoping to combine these commands, and set the item frame based on the chest contents using the /data modify entity ... set from block
command:
/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]
Unfortunately, this gives an error: The target block is not a block entity
.
I tried a few modification, by only setting the Item tags:
/data modify entity @e[x=-129,y=79,z=99,type=minecraft:item_frame,limit=1,distance=0..1] Item set value {Slot: 0b, id:"minecraft:filled_map", Count: 1}
/data modify entity @e[x=-129,y=79,z=99,type=minecraft:item_frame,limit=1,distance=0..1] Item.tag set from block -127 76 105 Items[0].tag
But again, I get the error The target block is not a block entity
.
Is there a way to set an item frame content based on a chest slot?