Python in Minecraft 3 – Placing many blocks at once

The previous example showed that python scripts could quickly become very long if each block had to be set individually. Fortunately there is the setBlocks command which can set many blocks at once. It also has two forms.


The minecraft coordinates (x1,y1,z1) represent one corner of the rectangular prism about to be set. The minecraft coordinates (x2,y2,z2) represent the diagonally opposite corner. The previous example can be rewritten to use the setBlocks command. The glass is set first otherwise it would overwrite the setting of the middle block. In this example the middle block is air which is equivalent to there being no block.


import mcpi.minecraft as minecraft
import mcpi.block as block
mc.setBlock(-219,73,-222, block.AIR)


Categories: CoderDojo