Check for an amount of blocks of a certain type within a region



  • Is there any way I can check for how many blocks of a certain type are in a region?



  • There is only one way that I know of. You can replace all blocks of the type in the area with auto-activating command blocks that increment a counter and then self replace with the original block. For example:

    fill 0 0 0 10 10 10 command_block{powered:1b,Command:"function yourfunc"} replace myblock
    

    where the yourfunc function is:

    increment counter
    setblock ~ ~ ~ myblock
    

    You can do a variety of easy things to increment the counter. Note: you may have to replace the powered tag with the auto tag if it does not work. Note 2: You can also use special methods to avoid having to have a datapack function.

    Edit: oops sorry, I didnt see bedrock edition. you can easily change the commands to the versions that work there.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2