Last active
December 13, 2015 21:08
-
-
Save gelicia/4975114 to your computer and use it in GitHub Desktop.
Kristina Automator!!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mcpi.minecraft as minecraft | |
import mcpi.block as block | |
mc = minecraft.Minecraft.create() | |
#get this in case the player moves whilst the program is running | |
playerPos = mc.player.getPos() | |
#start everything a bit off so that way you don't get caught in the box while it's building | |
playerPos.x += 2; | |
playerPos.z += 2; | |
def makeRoom(w, l, h): | |
for y in range(0, h): | |
for x in range(0, w): | |
for z in range(0, l): | |
#check the space around the square being removed. if it is empty, add a block so the space will be enclosed | |
#but don't add them every time because I want the locale to be part of my decor | |
if y == 0 and (mc.getBlock(playerPos.x + x, playerPos.y + y - 1, playerPos.z + z) == block.AIR.id): | |
mc.setBlock(playerPos.x + x, playerPos.y + y - 1, playerPos.z + z, block.COBBLESTONE.id) | |
if x == 0 and (mc.getBlock(playerPos.x + x - 1, playerPos.y + y, playerPos.z + z) == block.AIR.id): | |
mc.setBlock(playerPos.x + x - 1, playerPos.y + y, playerPos.z + z, block.COBBLESTONE.id) | |
if z == 0 and (mc.getBlock(playerPos.x + x, playerPos.y + y, playerPos.z + z - 1) == block.AIR.id): | |
mc.setBlock(playerPos.x + x, playerPos.y + y, playerPos.z + z - 1, block.COBBLESTONE.id) | |
if y == h - 1 and (mc.getBlock(playerPos.x + x, playerPos.y + y + 1, playerPos.z + z) == block.AIR.id): | |
mc.setBlock(playerPos.x + x, playerPos.y + y + 1, playerPos.z + z, block.COBBLESTONE.id) | |
if x == w - 1 and (mc.getBlock(playerPos.x + x + 1, playerPos.y + y, playerPos.z + z) == block.AIR.id): | |
mc.setBlock(playerPos.x + x + 1, playerPos.y + y, playerPos.z + z, block.COBBLESTONE.id) | |
if z == l - 1 and (mc.getBlock(playerPos.x + x, playerPos.y + y, playerPos.z + z + 1) == block.AIR.id): | |
mc.setBlock(playerPos.x + x, playerPos.y + y, playerPos.z + z + 1, block.COBBLESTONE.id) | |
mc.setBlock(playerPos.x + x, playerPos.y + y, playerPos.z + z, block.AIR.id) | |
def dig(startX, startY, startZ, w, l): | |
if nextLayerGood(startX, startY, startZ, w, l): | |
for x in range(0, w): | |
for z in range(0, l): | |
mc.setBlock(startX + x, startY - 1, startZ + z, block.AIR.id) | |
dig(startX, startY - 1, startZ + 1, w, l) | |
def nextLayerGood(startX, startY, startZ, w, l): | |
for x in range(0, w): | |
for z in range(0, l): | |
if mc.getBlock(startX + x, startY-1, startZ + z) == block.BEDROCK.id: | |
return False | |
return True | |
makeRoom(8, 8, 3) | |
dig(playerPos.x + 4, playerPos.y, playerPos.z + 4, 3, 4) | |
#TODO: automatic torches, stairs, add wall if digging exposes room |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment