See the items in a chest
I want to make a command that check how many and what type of items are in a chest and then it will give 12 end portal frames to the nearest player.
I have tried with redstone but it is too big.
The idea is that the player comes to the chest and put in some specific items in a specific order (see image below).
It will then empty the chest give the 12 end portal frames to the player.
This is for a chunk challenge map.
Solution 1:
You can use /testforblock
:
/testforblock X Y Z chest -1 <blockdata>
Is something you'll probably understand, depending on your command block experience. If you don't:
X Y Z should be replaced with the coordinates of the chest. "chest" means the command block only returns a success when it's a chest. -1 means it can be any data value, in a chest's case this means any rotation.
Now for the harder part, you should add the blockdata testing:
/testforblock X Y Z chest -1 {Items:[{Slot:*ID*,id:*ID*,Count:1}]}
The slot IDs are numbered from left to right, top to bottom, starting with 0. This means the top left is 0, top right is 8, bottom right is 26.
Item IDs can be found by pressing F3 and H at the same time (which reveals advanced tooltips) and hovering over the item in your inventory. An emerald, for example, would be "minecraft:emerald".
The count part can be anything you like, although I think you'll want it to stay at 1.
And then there's one last thing to do: add a comparator running out of the command block, into a command block that replaces the chest with an empty one, and one that gives the nearest player the frames.
To make filling in the blockdata easier, I recommend this. Just select the /blockdata
command, fill in all the slots, then copy the part between curly brackets into your /testforblock
command.
Solution 2:
ok first one thanks for the help and second i made the command that will empty the chest but i have problems with the command that will check when the item is in the chest here is 2 pictures with what i did http://prnt.sc/d5vrq7 - http://prnt.sc/d5vryv both the repeating command blocks have this command /testforblock -1402 51 -895 chest -1 {Items:[{Slot:0,id:emerald,Count:1}]} which theoretically it will chek the chest for the emerald and both the chain and impulse command block have this command /blockdata -1402 51 -895 {Items:[{Slot:0,id:air,Count:1}]} which it will replace the chest with air this command works but for some reason the /testforblock command dosn't activate i can't make it work with the comparator so i used a chain command block but nothing and all the command blocks are in always active mode exept impulse command block