Python in Minecraft 2 – Placing many blocks individually
In the last exercise we placed a wool block with variation 1. If you want to know which blocks you can place, check out the reference material at
http://www.stuffaboutcode.com/p/minecraft-api-reference.html
In the next example, the same wool block is placed and glass is placed all around it. Glass doesn’t have any variations so we are using the first form of the setBlock command
nano placeglassaroundwool.py
import mcpi.minecraft as minecraft import mcpi.block as block mc=minecraft.Minecraft.create() mc.setBlock(-219,73,-222, block.WOOL.id, 1) mc.setBlock(-220,72,-223, block.GLASS) mc.setBlock(-220,72,-222, block.GLASS) mc.setBlock(-220,72,-221, block.GLASS) mc.setBlock(-220,73,-223, block.GLASS) mc.setBlock(-220,73,-222, block.GLASS) mc.setBlock(-220,73,-221, block.GLASS) mc.setBlock(-220,74,-223, block.GLASS) mc.setBlock(-220,74,-222, block.GLASS) mc.setBlock(-220,74,-221, block.GLASS) mc.setBlock(-219,72,-223, block.GLASS) mc.setBlock(-219,72,-222, block.GLASS) mc.setBlock(-219,72,-221, block.GLASS) mc.setBlock(-219,73,-223, block.GLASS) mc.setBlock(-219,73,-221, block.GLASS) mc.setBlock(-219,74,-223, block.GLASS) mc.setBlock(-219,74,-222, block.GLASS) mc.setBlock(-219,74,-221, block.GLASS) mc.setBlock(-218,72,-223, block.GLASS) mc.setBlock(-218,72,-222, block.GLASS) mc.setBlock(-218,72,-221, block.GLASS) mc.setBlock(-218,73,-223, block.GLASS) mc.setBlock(-218,73,-222, block.GLASS) mc.setBlock(-218,73,-221, block.GLASS) mc.setBlock(-218,74,-223, block.GLASS) mc.setBlock(-218,74,-222, block.GLASS) mc.setBlock(-218,74,-221, block.GLASS)
Run this python script to see it build in minecraft
python3 placeglassaroundwool.py