Skip to content

Range of veinmining

Elemend edited this page Jul 13, 2021 · 2 revisions

Default behaviour

How does it work?

This is important to understand if you want to change it. There is a function and several like it that control this. For Blocks which have only one blockstate, or none for that matter, the function looks like this:

function

I try to visualize what this function does with an arrangement of blocks:

ingame

The position context of the function when it gets called starts at the red block. This block is the one you mined, and is therefor either air or water. An area effect cloud is spawned at that central location. Then commands check for the existence of a matching block at the relative position, highlighted as the green block. This is done 6 times for all directions. The matching of blocks works by comparing the block at that relative position to a hardcoded position in the world that is known to have the block you want to veinmine. This allows to effectively mine blocks without specifying what the are. This is only interesting to know because this function is able to cover most of the mineable blocks. Blocks which have varied blockstates, like stairs, need their own file to specifically check for the block id.

When there is a matching block there, the execution position is shifted down to the lowest northwesteren corner, highlighted by the yellow concrete powder in the corner of the cube. From there the command looks for the entity in the proximity, indicated by the volume selectors: dx,dy,dz being set the 8. These selectors start their "logic" at 0, so them being set to 8 searches for the entity in a 9x9x9 area, which is exactly the range this pack mines: 4 blocks in each direction from the center.

If the entity is found, i.e. the block is in range of those 4 blocks, the command then shifts the execution position 4 blocks diagonally to the green concrete by calling itself. The start of this function has a function which wasn't important until now. The function "vm:fill/xyz" contains the setblock commands which will setblock it to air, or water, and actually get rid of the block, "mine" the block, so to say...

Then it runs the same commands again and again until either there are no more blocks to mine in range or the durability of the tool ran out.

So how does one change the range then? tbd...

Clone this wiki locally