I need help with my mincraft commands
Solution 1:
Here is a solution which has three steps. Use the testforblock command to test for the nether stars, then the tp command to teleport the player, then the setblock command to reset the chest contents.
A nice thing about this system, it doesn't care if there are other items in the chest. They will be eliminated whenever the chest has 4 nether stars placed into it.
Command blocks:
The first is a Repeat Unconditional Always Active block with command:
testforblock <x1> <y1> <z1> minecraft:chest -1 {Items:[{id:"minecraft:nether_star",Count:4b}]}
The second is a Chain Conditional Always Active block with command:
tp @p[x=x1,y=y1,z=z1] <x2> <y2> <z2>
The third is a Chain Conditional Always Active block with command:
setblock <x1> <y1> <z1> minecraft:chest
Replace <x1> <y1> <z1>
with the coordinates of the chest. In the second command, replace x1, y1, and z1 with the coordinates of the chest and replace <x2> <y2> <z2>
with the coordinates that the player is to be teleported to.
The command blocks have to be loaded in order to function. They can either be placed near the chest, preferably in the same chunk, or they can be placed in the spawn chunks where they will always be loaded.
System weaknesses:
The player has to put a stack of exactly 4 nether stars into the chest for this to work. If the 4 stars are split into multiple stacks or the player places a stack larger then 4, it will not function.
If a player places 4 stars into the chest while there is another player closer to the chest, the player closest to the chest will be teleported instead of the player who put the stars into the chest.