I read a blog about retrieving all blocks in a cube in minecraft and writing out a python script that could replicate it. The code is Minescan.py
However, it iterates over the x, y, z co-ordinates one by one so if you have a 10x10x10 cube then it will create 1000 statements; which is not only slow to write, but slow to execute.
The minecraft API lets you set an individual block or a cuboid of blocks of the same type.
I'm looking to improve this program so that creates cuboids where possible instead of individual blocks. However, I am struggling conceptually to come up with the best way to do this.
e.g. If there was only 1 dimension and it looked like this (W for Wood and D for Dirt):
WDDDDDDDDW
You could loop over the x-axis using a simple for loop and write a command each time the block changed.
Pseudo-code
for i in range(0, x):
blockType = getBlock(x,0,0)
if blockType != previousBlock:
writeBlockRange
Would end up with
setBLock(1,0,0,Wood)
setBLocks(2,0,0,9,0,0,Dirt)
setBLock(10,0,0,Wood)
How do I efficiently extend that simple for loop to 2 dimensions and then to 3 dimensions?