Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
def angleToTextDirection(angle):
direction = int(round((angle % 360) / 45))
if direction == 0:
return minecraft.Vec3(-1,0,0)
elif direction == 1:
return minecraft.Vec3(-1,0,-1)
elif direction == 2:
return minecraft.Vec3(0,0,-1)
elif direction == 3:
return minecraft.Vec3(1,0,-1)
elif direction == 4:
return minecraft.Vec3(1,0,0)
elif direction == 5:
return minecraft.Vec3(1,0,1)
elif direction == 6:
return minecraft.Vec3(0,0,1)
else:
return minecraft.Vec3(-1,0,1)
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
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 - using Points
faceVertices = Points()
faceVertices.add(0,0,5)
faceVertices.add(10,0,5)
faceVertices.add(10,10,5)
faceVertices.add(0,10,5)
mcDrawing.drawFace(faceVertices, False, block.DIAMOND_BLOCK.id)
#face - 5 sided shape
faceVertices = []
faceVertices.append(minecraft.Vec3(0,15,0))
faceVertices.append(minecraft.Vec3(5,15,5))
faceVertices.append(minecraft.Vec3(3,15,10))
faceVertices.append(minecraft.Vec3(-3,15,10))
def angleToTextDirection(angle):
direction = int(round((angle % 360) / 45))
if direction == 0:
return minecraft.Vec3(-1,0,0)
elif direction == 1:
return minecraft.Vec3(-1,0,-1)
elif direction == 2:
return minecraft.Vec3(0,0,-1)
elif direction == 3:
return minecraft.Vec3(1,0,-1)
elif direction == 4:
return minecraft.Vec3(1,0,0)
elif direction == 5:
return minecraft.Vec3(1,0,1)
elif direction == 6:
return minecraft.Vec3(0,0,1)
else:
return minecraft.Vec3(-1,0,1)
def __init__(self, x, y, z, blockType, blockData = 0, tag = ""):
#persist data
self.blockType = blockType
self.blockData = blockData
#store the positions
# original pos
self.originalPos = minecraft.Vec3(x, y, z)
# relative pos - block position relatively to other shape blocks
self.relativePos = minecraft.Vec3(x, y, z)
# actual pos - actual block position in the world
self.actualPos = minecraft.Vec3(x, y, z)
#the tag system is used to give a particular block inside a shape meaning
# e.g. for an animal shape you could tag the block which is its head
self.tag = tag
# the mc block object
self.mcBlock = block.Block(blockType, blockData)
def __init__(self, x, y, z, blockType, blockData = 0, tag = ""):
#persist data
self.blockType = blockType
self.blockData = blockData
#store the positions
# original pos
self.originalPos = minecraft.Vec3(x, y, z)
# relative pos - block position relatively to other shape blocks
self.relativePos = minecraft.Vec3(x, y, z)
# actual pos - actual block position in the world
self.actualPos = minecraft.Vec3(x, y, z)
#the tag system is used to give a particular block inside a shape meaning
# e.g. for an animal shape you could tag the block which is its head
self.tag = tag
# the mc block object
self.mcBlock = block.Block(blockType, blockData)
#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 - using Points
faceVertices = Points()
faceVertices.add(0,0,5)
faceVertices.add(10,0,5)
faceVertices.add(10,10,5)
faceVertices.add(0,10,5)
mcDrawing.drawFace(faceVertices, False, block.DIAMOND_BLOCK.id)
#face - 5 sided shape
faceVertices = []
faceVertices.append(minecraft.Vec3(0,15,0))
faceVertices.append(minecraft.Vec3(5,15,5))
# Minecraft Graphics Turtle(End)
# Minecraft Stuff(Start)
elif msg[1] == 'stuff:drawLine':
mcDrawing.drawLine(int(mcpiX1), int(mcpiY1), int(mcpiZ1), int(mcpiX), int(mcpiY), int(mcpiZ), blockTypeId, blockData)
print "mcDrawing.drawLine: (%d, %d, %d, %d, %d, %d, %d, %d)" % (mcpiX1, mcpiY1, mcpiZ1, mcpiX, mcpiY, mcpiZ, blockTypeId, blockData)
elif msg[1] == 'stuff:drawSphere':
mcDrawing.drawSphere(mcpiX, mcpiY, mcpiZ, radius, blockTypeId, blockData)
print "mcDrawing.drawSphere: (%d, %d, %d, %d, %d, %d)" % (mcpiX, mcpiY, mcpiZ, radius, blockTypeId, blockData)
elif msg[1] == 'drawCircle':
mcDrawing.drawCircle(mcpiX, mcpiY, mcpiZ, radius, blockTypeId, blockData)
print "mcDrawing.drawCircle: (%d, %d, %d, %d, %d, %d)" % (mcpiX, mcpiY, mcpiZ, radius, blockTypeId, blockData)
elif msg[1] == 'stuff:resetShapePoints':
shapePoints = []
mcDrawing = stuff.MinecraftDrawing(mc)
elif msg[1] == 'stuff:setShapePoints':
shapePoints.append(minecraft.Vec3(int(x1), int(y1), int(z1)))
print "append.shapePoints:"
print ' '.join(str(p) for p in shapePoints)
elif msg[1] == 'stuff:drawFace':
if (fill == 'True'):
fillFlag = True
elif (fill == 'False'):
fillFlag = False
mcDrawing.drawFace(shapePoints, fillFlag, blockTypeId)
print "mcDrawing.drawFace:"
print ' '.join(str(p) for p in shapePoints)
print(fill)
print(blockTypeId)
# Minecraft Stuff(End)
elif msg[1] == 'setBlocks':
if (is_number(mcpiX0) and is_number(mcpiY0) and is_number(mcpiZ0) and is_number(mcpiX1) and is_number(mcpiY1) and is_number(mcpiZ1) and is_number(blockTypeId) and is_number(blockData)):
faceVertices.append(minecraft.Vec3(10,0,0))
mcDrawing.drawFace(faceVertices, True, block.SNOW_BLOCK.id)
#face - wireframe square - using Points
faceVertices = Points()
faceVertices.add(0,0,5)
faceVertices.add(10,0,5)
faceVertices.add(10,10,5)
faceVertices.add(0,10,5)
mcDrawing.drawFace(faceVertices, False, block.DIAMOND_BLOCK.id)
#face - 5 sided shape
faceVertices = []
faceVertices.append(minecraft.Vec3(0,15,0))
faceVertices.append(minecraft.Vec3(5,15,5))
faceVertices.append(minecraft.Vec3(3,15,10))
faceVertices.append(minecraft.Vec3(-3,15,10))
faceVertices.append(minecraft.Vec3(-5,15,5))
mcDrawing.drawFace(faceVertices, True, block.GOLD_BLOCK.id)