是否有任何使用命令方块来检查实体是否大于命令方块的特定范围的东西?

Is there anything using command blocks to check if an entity is greater than certain ranges of a command block?

我想 运行 一个基于玩家离开命令方块范围或他们是否在两个范围内的命令。例如,像 this 一样,当玩家进入红色范围内时,玩家会收到命令 运行。有什么方法可以尽可能简单地做到这一点?

在较新版本的 minecraft 中,您可以使用 /execute as @a[distance=x..y] run <command>

x 是开始定位的距离(以块为单位)

y 是它以方块为单位瞄准玩家的最远距离

两个..很重要

Example: /execute as @a[distance=10..15] run effect @s give minecraft:levitation 1 1 true

/execute as @a[r=your_range] run (your command) r 是命令方块周围的半径