Minecraft – How to detect certain block types anywhere in a certain area

minecraft-commandsminecraft-java-edition

I want to make a command block that detects water blocks anywhere in my world, and then replace it with ice, but I don't know how to detect blocks without testing specific coordinates one by one. For example, this won't work because I have to repeat for every single coordinate I want to test:

/execute if block 12 23 34 water run setblock 12 23 34 ice

I also want it to detect blocks everywhere without being restricted by distance from the player or other entities.

Best Answer

The command syntax is

/fill <from> <to> <block> replace [<filter>]

So in your case it is something like

/fill ~-25 ~-10 ~-25 ~25 ~10 ~25 minecraft:ice replace minecraft:water

which would be execute off of the player every few seconds to get it all. This wouldn't get it all at once but wherever the player moves.


Note this may work slower if a lot of people are in the same world.