def __init__(self, mc, position=minecraft.Vec3(0, 0, 0)): #set defaults self.mc = mc #start position self.startposition = position #set turtle position self.position = position #set turtle angles self.heading = 0 self.verticalheading = 0 #set pen down self._pendown = True #set pen block to black wool self._penblock = block.Block(block.WOOL.id, 15) #flying to true self.flying = True #set speed self.turtlespeed = 6 #create turtle self.showturtle = True # create drawing object self.mcDrawing = MinecraftDrawing(self.mc) # set turtle block self.turtleblock = block.Block(block.DIAMOND_BLOCK.id) # draw turtle self._drawTurtle(int(self.position.x), int(self.position.y), int(self.position.y))
def setRandomGoldBlock(): #Initialise our position with 0,0,0 goldBlock = minecraft.Vec3(0, 0, 0) #Randomise the x axis within 100 blocks from the player goldBlock.x = random.randrange(-100, 100) #Initialise the y axis between -5 and 20 as we dont want it to be too low or high in the world goldBlock.y = random.randrange(-5, 20) #Randomise the z axis within 100 blocks from the player like the x axis goldBlock.z = random.randrange(-100, 100) #Place the block in the world mc.setBlock(goldBlock.x, goldBlock.y, goldBlock.z, block.GOLD_BLOCK) #Return the coordinates so we know where our gold block is return goldBlock
def getLine(self, x1, y1, z1, x2, y2, z2): # return maximum of 2 values def MAX(a,b): if a > b: return a else: return b # return step def ZSGN(a): if a < 0: return -1 elif a > 0: return 1 elif a == 0: return 0 # list for vertices vertices = [] # if the 2 points are the same, return single vertice if (x1 == x2 and y1 == y2 and z1 == z2): vertices.append(minecraft.Vec3(x1, y1, z1)) # else get all points in edge else: dx = x2 - x1 dy = y2 - y1 dz = z2 - z1 ax = abs(dx) << 1 ay = abs(dy) << 1 az = abs(dz) << 1 sx = ZSGN(dx) sy = ZSGN(dy) sz = ZSGN(dz) x = x1 y = y1 z = z1 # x dominant if (ax >= MAX(ay, az)): yd = ay - (ax >> 1) zd = az - (ax >> 1) loop = True while(loop): vertices.append(minecraft.Vec3(x, y, z)) if (x == x2): loop = False if (yd >= 0): y += sy yd -= ax if (zd >= 0): z += sz zd -= ax x += sx yd += ay zd += az # y dominant elif (ay >= MAX(ax, az)): xd = ax - (ay >> 1) zd = az - (ay >> 1) loop = True while(loop): vertices.append(minecraft.Vec3(x, y, z)) if (y == y2): loop=False if (xd >= 0): x += sx xd -= ay if (zd >= 0): z += sz zd -= ay y += sy xd += ax zd += az # z dominant elif(az >= MAX(ax, ay)): xd = ax - (az >> 1) yd = ay - (az >> 1) loop = True while(loop): vertices.append(minecraft.Vec3(x, y, z)) if (z == z2): loop=False if (xd >= 0): x += sx xd -= az if (yd >= 0): y += sy yd -= az z += sz xd += ax yd += ay return vertices
#create drawing object mcDrawing = MinecraftDrawing(mc) #line mcDrawing.drawLine(0,0,-10,-10,10,-5,block.STONE.id) #circle mcDrawing.drawCircle(-15,15,-15,10,block.WOOD.id) #sphere mcDrawing.drawSphere(-15,15,-15,5,block.OBSIDIAN.id) #face - solid triangle faceVertices = [] faceVertices.append(minecraft.Vec3(0,0,0)) faceVertices.append(minecraft.Vec3(5,10,0)) faceVertices.append(minecraft.Vec3(10,0,0)) mcDrawing.drawFace(faceVertices, True, block.SNOW_BLOCK.id) #face - wireframe square faceVertices = [] faceVertices.append(minecraft.Vec3(0,0,5)) faceVertices.append(minecraft.Vec3(10,0,5)) faceVertices.append(minecraft.Vec3(10,10,5)) faceVertices.append(minecraft.Vec3(0,10,5)) mcDrawing.drawFace(faceVertices, False, block.DIAMOND_BLOCK.id) #face - 5 sided shape faceVertices = [] faceVertices.append(minecraft.Vec3(0,15,0))
def _drawTurtle(self, x, y, z): #draw turtle self.mcDrawing.drawPoint3d(x, y, z, self.turtleblock.id, self.turtleblock.data) lastDrawnTurtle = minecraft.Vec3(x, y, z)