Python in Minecraft 5 – hollow tunnel

Creating a hollow tunnel with walls at each end

To create an air space in the tunnel we can use another loop. However, the second loop should not go all the way to the ends because we want walls at each end. This is to stop water and lava flowing into our tunnel should the ends of the tunnel meet these liquids.

nano hollowglasstunnel.py

import mcpi.minecraft as minecraft
import mcpi.block as block
mc=minecraft.Minecraft.create()
xmin = -224
xmax = -200
y = 72
z = -222
for x in range(xmin,xmax+1):
    mc.setBlocks(x,y,z-2,x,y+6,z+2,block.GLASS)
for x in range(xmin+1,xmax):
    mc.setBlocks(x,y+1,z-1,x,y+5,z+1,block.AIR)

python3 hollowglasstunnel.py

Categories: CoderDojo