Minecraft aircraft

 

Minecraft passenger plane.

Passenger plane generated by a Python Program

I was set the challenge of creating a Python program that automatically creates an aircraft at the player’s position. I used the symbol generating routine as a starting position for the fuselage and then added a few loops to create the wings and tail fin. I’d like to play with the textures and various block ids to see what can be achieved, but at the moment I feel that they’d make an interesting addition to many Minecraft scenes.

#Airplane program... IPRoulson 2015
from mcpi import minecraft
mc = minecraft.Minecraft.create()
mc.postToChat("Python is now in control!")

fuselage_mtl = 42
wing_mtl = 57
fin_mtl = 57
tailfin_mtl = 49
seat_mtl=41

startx,starty,startz = mc.player.getPos() #get the player's position

#start in the same place each time:
#startx=0
#starty=2
#startz=0

#create fuselage from pattern
line = "  ###  "," #   # ","#     #","#     #","#     #"," ##### ","  ###  "

for fuselage in range(1,45):
    yplot=starty+10 #lift the starty so that it's not written under your feet!  
    
    for row in line: # one row at a time from list line
        yplot=yplot-1 # work down from the top
        column=0
        for letter in row: # work along each row - check each character. If it's a "#" then print a block else leave it as air
            column = column+1
            if letter =="#":
                mc.setBlock(startx-column,yplot,startz+fuselage,fuselage_mtl)
            else:
                mc.setBlock(startx-column,yplot,startz+fuselage,0)

#create nose cone
xoffset=4

#MAIN SOLID
mc.setBlocks(startx-(xoffset+2),(starty+5),(startz),(startx-xoffset)+2,starty+6,(startz-6),fuselage_mtl)
mc.setBlocks(startx-(xoffset+1),(starty+5),(startz-6),(startx-xoffset)+1,starty+6,(startz-7),fuselage_mtl)

#clear cockpit area
mc.setBlocks(startx-(xoffset+1),(starty+5),(startz),(startx-xoffset)+1,starty+6,(startz-4),0)

#floor cockpit
mc.setBlocks(startx-(xoffset+1),(starty+4),(startz),(startx-xoffset)+1,starty+4,(startz-4),fuselage_mtl)

#MAIN WINDOW BLOCK
mc.setBlocks(startx-(xoffset+1),(starty+7),(startz),(startx-xoffset)+1,starty+8,(startz-4),20)
#FRONT TAPER OF WINDOW
mc.setBlocks(startx-(xoffset+1),(starty+7),(startz-5),(startx-xoffset)+1,starty+7,(startz-5),20)    
#clear cockpit glass
mc.setBlocks(startx-xoffset,starty+7,startz,startx-xoffset,starty+7,startz-4,0)

#punch out windows
for window in range(5,42,3):
    xoffset=4
    mc.setBlock(startx-(xoffset+3),starty+6,startz+window,20)
    mc.setBlock((startx-xoffset)+3,starty+6,startz+window,20)

#fit the seats
for window in range(6,45,3):
    xoffset=4
    mc.setBlock(startx-(xoffset+2),starty+5,startz+window,seat_mtl)
    mc.setBlock((startx-xoffset)+2,starty+5,startz+window,seat_mtl)
    mc.setBlock(startx-(xoffset+1),starty+5,startz+window,seat_mtl)
    mc.setBlock((startx-xoffset)+1,starty+5,startz+window,seat_mtl)

#draw wing
for wing in range(1, 15):
    xoffset=4
    zoffset=11
    length=13
    mc.setBlocks(startx-(xoffset+wing+length),starty+3,startz+zoffset+wing,(startx-xoffset)+wing+length,starty+3,startz+zoffset+wing,wing_mtl)

#draw tailplane
for fin in range(1, 10):
    xoffset=4
    zoffset=35
    length=2
    mc.setBlocks(startx-(xoffset+fin+length),starty+9,startz+zoffset+fin,(startx-xoffset)+fin+length,starty+9,startz+zoffset+fin,fin_mtl)

#draw tailfin
for fin in range(2,10):
    xoffset=4
    zoffset=44
    mc.setBlocks(startx-xoffset,starty+19-fin,startz+zoffset,(startx-xoffset),starty+19-fin,startz+zoffset-fin,tailfin_mtl)
fighter

Eurofighter Typhoon generated by a Python program

 

The second image is loosely based on the Eurofighter Typhoon. There are no air intakes and the engines are not set to afterburner – perhaps someone would like to try adding these.

One addition I’m considering is to use the half-steps to create smoother edges. I am sure it’s possible and it would really improve the look of many of these objects. Maybe sometime later…

#Eurofighter Typhoon program... IPRoulson 2015
from mcpi import minecraft
mc = minecraft.Minecraft.create()
mc.postToChat("Python is now in control!")


#block ids used? 42 - iron block, 49 - obsidian, 41 - gold block
fuselage_mtl = 42
wing_mtl = 42
fin_mtl = 42
tailfin_mtl = 42
seat_mtl=41

mc.setBlocks(-30,0,-30,40,30,45,0)

startx,starty,startz = mc.player.getPos() #get the player's position

#start in the same place each time:
#startx=0
#starty=2
#startz=0

#create fuselage from pattern
line = "   #   "," ##### ","#     #","#     #"," ##### ","  ###  "

for fuselage in range(1,25):
    yplot=starty+10 #lift the starty so that it's not written under your feet!  
    
    for row in line: # one row at a time from list line
        yplot=yplot-1 # work down from the top
        column=0
        for letter in row: # work along each row - check each character. If it's a "#" then print a block else leave it as air
            column = column+1
            if letter =="#":
                mc.setBlock(startx-column,yplot,startz+fuselage,fuselage_mtl)
            else:
                mc.setBlock(startx-column,yplot,startz+fuselage,0)
#create engine                
xoffset=4

mc.setBlocks(startx-(xoffset+3),(starty+5),(startz+23),(startx-xoffset)-1,starty+7,(startz+24),49)
mc.setBlocks(startx-(xoffset-1),(starty+5),(startz+23),(startx-xoffset)+3,starty+7,(startz+24),49)
mc.setBlock(startx-(xoffset+2),starty+6,startz+24,35,14)
mc.setBlock(startx-(xoffset-2),starty+6,startz+24,35,14)
#create nose cone
xoffset=4

#MAIN SOLID
mc.setBlocks(startx-(xoffset+2),(starty+5),(startz),(startx-xoffset)+2,starty+6,(startz-6),fuselage_mtl)
mc.setBlocks(startx-(xoffset+1),(starty+5),(startz-6),(startx-xoffset)+1,starty+6,(startz-7),fuselage_mtl)
mc.setBlock(startx-xoffset,starty+6,startz-8,fuselage_mtl)

#draw canard
for fin in range(1, 4):
    xoffset=4
    zoffset=-3
    length=5
    mc.setBlocks(startx-(xoffset+fin+length),starty+6,startz+zoffset+fin,(startx-xoffset)+fin+length,starty+6,startz+zoffset+fin,fin_mtl)

#clear cockpit area
mc.setBlocks(startx-(xoffset+1),(starty+5),(startz),(startx-xoffset)+1,starty+6,(startz-4),0)

#floor cockpit
mc.setBlocks(startx-(xoffset+1),(starty+4),(startz),(startx-xoffset)+1,starty+4,(startz-4),fuselage_mtl)

#MAIN WINDOW BLOCK
mc.setBlocks(startx-(xoffset+1),(starty+7),(startz),(startx-xoffset)+1,starty+8,(startz-4),20)
#FRONT TAPER OF WINDOW
mc.setBlocks(startx-(xoffset+1),(starty+7),(startz-5),(startx-xoffset)+1,starty+7,(startz-5),20)    
#clear cockpit glass
mc.setBlocks(startx-xoffset,starty+7,startz,startx-xoffset,starty+7,startz-4,0)

#draw wing
for wing in range(1, 18):
    xoffset=4
    zoffset=7
    length=3
    mc.setBlocks(startx-(xoffset+wing+length),starty+4,startz+zoffset+wing,(startx-xoffset)+wing+length,starty+4,startz+zoffset+wing,wing_mtl)
#draw wingtips
xoffset=4
zoffset=17
length=6
mc.setBlocks(startx-(xoffset+20),starty+4,startz+zoffset,startx-(xoffset+20),starty+4,startz+zoffset+length,wing_mtl)
mc.setBlocks((startx-xoffset)+20,starty+4,startz+zoffset,(startx-xoffset)+20,starty+4,startz+zoffset+length,wing_mtl)

#draw tailfin
for fin in range(2,10):
    xoffset=4
    zoffset=24
    mc.setBlocks(startx-xoffset,starty+15-fin,startz+zoffset,(startx-xoffset),starty+15-fin,startz+zoffset-fin,tailfin_mtl)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s