Command block check chest

Command block check chest - Close-up of a Solid Concrete Block

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. :)



Best Answer

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 http://minecraft.gamepedia.com/Player.dat)




Pictures about "Command block check chest"

Command block check chest - White and Black Concrete Building
Command block check chest - Tower Block of Flats Surrounded by Trees
Command block check chest - Top View of a Circular Building in City



How can you tell if a chest is empty in Minecraft?

You can test whether there is a certain block at a specific location in the game using the /testforblock command in Minecraft. TIP: Starting in Minecraft Java Edition (PC/Mac) 1.13, the /testforblock command was removed from the Java Edition version of the game.

How do you check blocks with command blocks?

By holding \u21e7 Shift and double-clicking while holding an item, all items of a type clicked on will be moved into or out of the chest.



how to detect item in a chest! I minecraft chest detection tutorial 1.16.5!




More answers regarding command block check chest

Answer 2

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

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Lucas Vinícius Pontes, Erickson Balderama, Mike B, Ollie Craig