Right now, Minecraft commands have two main ways to test for blocks:
if block <position> <block> ...
if blocks <begin> <end> <destination> (all|masked) ...
The first one checks if the block at a certain position is a certain type of block. Makes sense, very useful.
The second one checks if the blocks in a certain area match the blocks in another area. Still somewhat useful, but not nearly as much as the first one.
The main thing that people want to do with an area of blocks is not, in my experience, to check whether it matches another area of blocks. They want to check if any of the blocks are a specific block, or count the number of blocks that are a specific block. I would like to propose an additional subcommand that allows both:
if blocks <begin> <end> <block> all ...
if blocks <begin> <end> <block> <count> ...
where <block> specifies the block type we want, and <count> is a number range. This command counts the number of blocks in the area that match <block>, and succeeds if that count matches <count> (or if it's all of them, in the case of all).
If used with execute store, the command stores the number of matched blocks. When it's used like that, <count> is optional.
Examples:
if blocks ~-5 ~-5 ~-5 ~5 ~5 ~5 #minecraft:wool 1..
Check whether there's at least one wool block near you.
if blocks ~-1 ~-1 ~-1 ~1 ~3 ~1 minecraft:water all
Check that you're surrounded by open water.
if blocks ~-5 ~-5 ~-5 ~5 ~5 ~5 minecraft:gold_block ..3
Make sure there are less than 4 gold blocks nearby.
Please sign in to leave a comment.
4 Comments