How to test for blocks within a certain radius of a player?

How to test for blocks within a certain radius of a player? - Student Getting A+ Mark in Her Exam

I'm trying to make a custom crafting system, but I'm not sure how to test for blocks within a radius of players, not command blocks. Specifically, I'm attempting to test if there is a dropper within ten blocks of a player at any given time and any given place in the world. Is there a way to do this?



Best Answer

Here's another idea:

If the droppers are not crafted by the player himself, you could simply spawn an armor stand at every dropper and then use /execute @p[...] ~ ~ ~ /testfor @e[type=ArmorStand,...]

If the player can craft the droppers, you could replace every dropper in the player's inventory with an armor stand named "Dropper" and all the attributes you want. When it is placed, it automatically executes the setblock command to spawn the dropper. The armor stands should be invisible of course.

You can also do nested execute commands to avoid the problem with the command block's radius.




Pictures about "How to test for blocks within a certain radius of a player?"

How to test for blocks within a certain radius of a player? - Student Cheating During an Exam
How to test for blocks within a certain radius of a player? - Blood Sugar Meter and Sweets on the Blue Background
How to test for blocks within a certain radius of a player? - Student Cheating During an Exam



How do you Testfor a player in a radius?

2. Type the Command
  • Test if Players are within 10 blocks. In this example, we will test to see if there are any players within a 10 block radius with the following command: /testfor @a[r=10] ...
  • Test if Mooshrooms are within 50 blocks. ...
  • Test if Nearest Player is at Level 20 experience.




  • Detect When A Player Is At A Block/Blocks Minecraft




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

    Images: RODNAE Productions, RODNAE Productions, Nataliya Vaitkevich, RODNAE Productions