Ryan (goldfish) has submitted 3 new programs — and he has my many thanks for doing so by pushing his changed to the github repo and making them compatible with the other scripts!!
Here’s what he’s contributed:
gf_helloworld.py
#! /usr/bin/python import mcpi.minecraft as minecraft import server """ hello world test app @author: goldfish""" mc = minecraft.Minecraft.create( server.address ) mc.postToChat("Hello, Minecraft!")
gf_clearZone.py
#! /usr/bin/python import mcpi.minecraft as minecraft import mcpi.block as block import server """ clearZone clears an area and sets a stone floor takes two x,z pairs clears everything above 0y and then sets a stone floor at -1y @author: goldfish""" def clearZone( alocx, alocz, blocx, blocz ): mc.setBlocks( alocx, 0, alocz, blocx, 64, blocz, block.AIR ) mc.setBlocks( alocx, -1, alocz, blocx, -1, blocz, block.STONE ) if __name__ == "__main__": mc = minecraft.Minecraft.create( server.address ) clearZone( -20, -20, 20, 20 )
gf_drawbuilding.py
drawBuilding( locx, locy, locz, floors, width, depth, floorheight, wallmaterial, floormaterial)
#! /usr/bin/python import mcpi.minecraft as minecraft import mcpi.block as block import server import random """ draw a building @author: goldfish""" def drawBuilding( locx, locy, locz, floors, width, depth, floorheight, wallmaterial, floormaterial ): topx = locx+width topy = locy+((floorheight+1)*floors) topz = locz+depth #draw building shell mc.setBlocks( locx, locy, locz, topx, topy, topz, wallmaterial ) mc.setBlocks( locx+1, locy+1, locz+1, topx-1, topy-1, topz-1, block.AIR ) #draw floors if( floors > 1 ): for i in range( floors -1 ): floorYloc = locy+( (floorheight+1)*(i+1) ) mc.setBlocks( locx+1, floorYloc, locz+1, topx-1, floorYloc, topz-1, floormaterial ) #draw door doorloc = random.randint( 1, width-2 ) mc.setBlock( locx, locy+1, locz+doorloc, block.AIR ) mc.setBlock( locx, locy+2, locz+doorloc, block.AIR ) #draw front windows if( floors > 1 ): for i in range( floors-1 ): windowYloc = locy+2+( (floorheight+1)*(i+1) ) for j in range( floorheight-1 ): mc.setBlocks( locx, windowYloc+j , locz+1, locx, windowYloc+j, locz+(width-1), block.GLASS_PANE ) #draw back windows if( floors > 1 ): for i in range( floors-1 ): windowYloc = locy+2+( (floorheight+1)*(i+1) ) for j in range( floorheight-1 ): mc.setBlocks( locx+depth, windowYloc+j , locz+1, locx+depth, windowYloc+j, locz+(width-1), block.GLASS_PANE ) #connect levels with ladder #mc.setBlocks( topx-1, locy+1, topz-1, topx-1, topy-1, topz-1, block.LADDER ) if __name__ == "__main__": mc = minecraft.Minecraft.create( server.address ) drawBuilding( 0, 0, 0, 5, 5, 5, 3, block.STONE, block.WOOD_PLANKS )
hello, cool scripts but know you how to use events with the sword as you right click?
epic
To get the ladders to work you need to add data to the setblocks.
mc.setBlocks(x+2,y,z+1,x+2,y+ht-1,z+1,65,[3])
I have not figured out yet how to determine which number to use. I hardcoded 3 in my example to make sure it worked but not sure in code how to figure out which “side” to use.
Great program. Awesome when you see the building appearing.
Can I point out two bugs? In the front windows you have used width instead of depth for the z-axis, while for the back windows you have used depth instead of width for the x-axis. If you start location is 0,0,0 you don’t see the bug, but you do when you use eg 50, 0, 0 and of course a different width & depth. Front windows then get too long or too short, back windows appear in the middle of your building or outside.
Hope this helps. But perhaps you put this in to get us into debugging Python programs, which is a respectable goal!! 🙂
We do not actually make the programs (TnT snake and minecraft path we made) but we do reblog them so people can find them but you can tell “goldfish” about the bugs.