This will be my first question here about some work I would do for a world that I'm creating. Let's jump into the question.
I would be able to detect if player is in "range" of a specified block (aka mycelium). If the player has a distance of max 1, I need to spawn some particles around the player. For now, I found a tedious way to do this, but it's not covering all the cases. At the end, I post some images that explain the area mycelium should cover and cases when detection must work. ATTENTION: there is no single block of mycelium. Almost all the world will be covered in mycelium!
How I achieve that now?
For every direction, i have a commandblock checking for player, in a clock. For instance, to detect a player on the top of mycelium I used:
execute as @a at @s if block ~ ~-1 ~ minecraft:mycelium run particle minecraft:happy_villager ~ ~ ~ 1 1 1 1 10 force
This will repeat for every variation. So if I want to detect one step forward or backward, I'll do
~1 ~-1 ~ or
~-1 ~-1 ~, moving the X or the Z coordinate.
Making this for mycelium, it takes for now 5 commandblocks in the clock, and it's not covering, for example, the block above, the corners and the block near, since it will add 6 more commandblocks.
So i started experimenting
I know there is a property of objects, called distance. I tried to put
@s[distance=..3], but the command just stops to work.
And now I'm here
Since I lost many of my time searching, and since is all very confusing because of the 1.13/1.12/1.8 versions, I decided to post an official question.
FINAL OBJECTIVE (put all things I wanted to do toghether)
I want to detect if a mycelium block is 1 block away from the player, in every direction. If yes, I would be able to:
- Play a sound sequence, made with other commandblocks, to that player (only for that player, or in that position)
- Apply particle effect in that position
- Poison and hurt the player
Mycelium will cover almost all the world, so I cannot test for only "specific" positions or make markers. EVERY single mycelium block must be detected, and if detected, must do that sequence of actions at least once.