How to execute if there's a certain block within a radius

I'm trying to figure out how to execute (for example /say hi) when there's Yellow Terracotta in a certain radius or field, however I can't figure out how to do it. Anyone knows?

1 Answer

I provided some thoughts in your thread on stackoverflow, but I came up with (for mc1.16):

execute at @p[distance=..3] if block ~ ~-1 ~ minecraft:yellow_glazed_terracotta run say hi

This sort of achieves what you are looking for. When a button is on the command block, the player must press the button, be within 3 blocks of the command block, and the terracotta must be under the player. Then it shall run "say hi."

2

You Might Also Like