What command can I use to check a chest's contents?



  • Technically, I want to check a shulker box's contents for a map I'm making. I want the player to put a Disk 11 into the shulker box and then it will be replaced with Stal. What command would I use to do this, if there even is one?

    I used /data get and got this:

    {CustomName: '{         
        "text":"Disk Repairer"  
      }', 
      x: -42, 
      y: 23, 
      z: 23,    
      Items: [{         
        Slot: 13b, 
        id: "minecraft:music_disc_11", 
        Count:1b, 
        tag: {          
          display: {
            Lore: ['{
              "text":"Please return to",
              "color":"gray",
              "italic":false
            },], ['{
              "text":"a Disk Repairer.",
              "color":"gray",
              "italic":false
            }'], 
            Name: ['{
              "text":"Broken Music Disk",
              "italic":false
            }']             
          }         
        }   
      }],   
    id: "minecraft:shulker_box" 
    }
    

    Would I use this for the path? Or what would I use?



  • 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 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"
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2