I want to make a shop where the player must hold a item and then click a button, and what I want to do is a "test for" like command to check if the item in the players hand matches the item in slot 0 in the chest. Is there a way to do that thanks.

or I could just check if the item is in the players inventory. :)

  • It seems this user found how to testfor the chest and posted a separate question here
    – Judge2020
    Commented Aug 28, 2015 at 21:45
  • @Judge2020 your link is pointing to this question, you might want to look into that.
    – Lars
    Commented Oct 23, 2015 at 13:57

2 Answers 2


You cannot compare the two items in the sense of

Chest == Hand

However you can do something more like

Chest == X and Hand == X therefor Chest == Hand

You can check what is in the hand using {SelectedItem:{Item Tag}} (see more at https://minecraft.wiki/w/Player.dat)


No, you cannot compare items in inventories. You probably want to check for the specific item in the command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .