Minecraft – /testfor levels in Minecraft

minecraft-commandsminecraft-java-edition

I'm trying to make an AND (logic) gate in minecraft with command blocks in order to make some vanilla shops in my world. With the first input (A) I'm checking if there is at least one diamond in the inventory of the nearest player, with the second input (B) I'm checking if this player has a minimum of 10 levels. How can I achieve this second result with the B input? I know that I can use /testfor but I can't find a full list of all possible commands inside the game.

Best Answer

You can test whether a player has a Diamond by running the following command block, with a comparator coming out of it.

 /clear @p Diamond 0

Your comparator will be the output of side one of your AND gate.


You can test for a player's level by using the selector modifiers:

 /testfor @p[lm=10]

As usual, a comparator will have to come out of this command block. Its output will be the other side of your AND gate.

From there, you can create an AND gate as per normal.


To test for the conditions, simply run both command blocks at the same time.