What command can I use to check a chest's contents?
Solution 1:
To check the NBT-data of a shulker box (or any other block) at the coordinates -42 23 23
, you can use this command:
/data get block -42 23 23
To only get information about the contents of the shulker box, which is stored in the Items
tag, you can use this command:
/data get block -42 23 23 Items
To check if the shulker box contains a disc 11, you would use one of these command, they fail if there is no item with the id "minecraft:music_disc_11"
present within the Items
tag, the first command also fails if there is more than one music disc 11 within the shulker box. The second command can imidiately run a command by adding run <command>
at the end of it:
/data get block -42 23 23 Items[{id:"minecraft:music_disc_11"}]
/execute if data block -42 23 23 Items[{id:"minecraft:music_disc_11"}]
To change the id of all items with the id "minecraft:music_disc_11"
to the id "minecraft:music_disc_stal"
you can use this command:
/data modify block -42 23 23 Items[{id:"minecraft:music_disc_11"}].id set value "minecraft:music_disc_stal"