/testfor levels in Minecraft

/testfor levels in Minecraft - Free stock photo of agriculture, countryside, cropland

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.




Pictures about "/testfor levels in Minecraft"

/testfor levels in Minecraft - Idyllic View of a Man Carrying Plants on Rice Terraces and Reflecting in a Mud
/testfor levels in Minecraft - Green and White Grass Field
/testfor levels in Minecraft - Free stock photo of agriculture, countryside, crop



How do you check XP level in Minecraft?

You can test for player's levels using the l= or lm= arguments in the target selector. as 8 will be true for both lm and l but 7 will become false for lm and 9 would be false for l because a selector will only select players IF all the arguments are true.

What does the Testfor command do in Minecraft?

The /testfor command became obsolete in Minecraft 1.13, and has been replaced by the /execute command*. It will do the same as typing /testfor @e {SelectedItem:{id:"<item>"}} and then putting a comparator to the command block with the command, and then running the command which you wanna run.



Minecraft Redstone Tutorial | How to use testfor commands in MCPE!




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

Images: Quang Nguyen Vinh, Quang Nguyen Vinh, Quang Nguyen Vinh, Quang Nguyen Vinh