Detect Minecraft entities nearby

St
4

Is there a command with which one can recognize whether an entity (mob) or several are in the vicinity of the player (with a definable block range)?

Ti

Execute as @p [distance = .10] at @s if entity @e [type = zombie] run…

St

Thank you! It all worked out as expected!

St

As I playd with this command i noticed something, the commands activates if a zombie is in ANY loaded area. The command only activates when the player has the distance 10 or below to the command block, not to the entity.

Ti

Because I easily made a mistake.

It should fit like this:

execute as @p at @s if entity @e [type = zombie, distance = .10] run…