def __init__(self, craftBlocks, pos): self.mc = minecraft.Minecraft.create() # create the craft self.craftShape = mcstuff.MinecraftShape(self.mc, pos, craftBlocks) self.flying = False self.turnYawAngle = 0 self.turnPitchAngle = 0 self.turnRowAngle = 0
def theRiver(arenaPos, riverZPos): #create connection to minecraft mc = minecraft.Minecraft.create() #constants RIVERWIDTH = 4 BRIDGEWIDTH = 2 #create the river mc.setBlocks(arenaPos.x, arenaPos.y - 2, arenaPos.z + riverZPos, arenaPos.x + ARENAX, arenaPos.y, arenaPos.z + riverZPos + RIVERWIDTH - 1, block.AIR.id) #fill with water mc.setBlocks(arenaPos.x, arenaPos.y - 2, arenaPos.z + riverZPos, arenaPos.x + ARENAX, arenaPos.y - 2, arenaPos.z + riverZPos + RIVERWIDTH - 1, block.WATER.id) #create the bridge shape bridgePos = minecraft.Vec3(arenaPos.x, arenaPos.y, arenaPos.z + riverZPos + 1) bridgeShape = minecraftstuff.MinecraftShape(mc, bridgePos) bridgeShape.setBlocks( 0, 0, 0, BRIDGEWIDTH - 1, 0, RIVERWIDTH - 3, block.WOOD_PLANKS.id) #move the bridge left and right #how many steps are there between the left and right side of the arena steps = ARENAX - BRIDGEWIDTH + 1 while not gameOver: for left in range(0, steps): bridgeShape.moveBy(1,0,0) time.sleep(1) for right in range(0, steps): bridgeShape.moveBy(-1,0,0) time.sleep(1)
def theWall(arenaPos, wallZPos): #create connection to minecraft mc = minecraft.Minecraft.create() #create the wall shape wallPos = minecraft.Vec3(arenaPos.x, arenaPos.y + 1, arenaPos.z + wallZPos) #create the wall blocks wallBlocks = [] for x in range(0, ARENAX + 1): for y in range(1, ARENAY): wallBlocks.append( minecraftstuff.ShapeBlock(x, y, 0, block.BRICK_BLOCK.id)) wallShape = minecraftstuff.MinecraftShape(mc, wallPos, wallBlocks) #move the wall up and down while not gameOver: wallShape.moveBy(0, 1, 0) time.sleep(1) wallShape.moveBy(0, -1, 0) time.sleep(1)
def theWall(arenaPos, wallZPos): #create connection to minecraft mc = minecraft.Minecraft.create() #create the wall shape wallPos = minecraft.Vec3(arenaPos.x, arenaPos.y + 1, arenaPos.z + wallZPos) wallShape = minecraftstuff.MinecraftShape(mc, wallPos) #create the wall wallShape.setBlocks( 0, 1, 0, ARENAX, ARENAY - 1, 0, block.BRICK_BLOCK.id) #move the wall up and down while not gameOver: wallShape.moveBy(0,1,0) time.sleep(1) wallShape.moveBy(0,-1,0) time.sleep(1)
def the_platform(xz=None): block_id = block.WOOD_PLANKS.id plane = Plane(x=xz[0], z=xz[1]) platform = Platformer(number_blocks=NUMBER_BLOCKS, block_size=PLATFORM_BLOCK_SIZE, plane=plane) #create the platform shapes platform_shapes = [] for pos in platform.get_block_positions(): block_pos = Vec3(pos[0], arenaPos.y, pos[1]) platform_blocks = [] for x in range(PLATFORM_BLOCK_SIZE): for z in range(PLATFORM_BLOCK_SIZE): platform_blocks.append(minecraftstuff.ShapeBlock(x, 0, z, block_id)) platform_shape = minecraftstuff.MinecraftShape(mc, block_pos, platform_blocks) platform_shapes.append(platform_shape) #move the platforms while not levelComplete: platform.move_blocks() directions = platform.get_block_directions() for i in range(len(directions)): platform_shapes[i].moveBy(directions[i][0], 0, directions[i][1]) time.sleep(PLATFORM_SLEEP_TIME)
alienPos.y = alienPos.y + 50 #set the flying saucer's mode mode = "landing" #create the shape for our flying saucer alienBlocks = [ minecraftstuff.ShapeBlock(-1, 0, 0, block.WOOL.id, 5), minecraftstuff.ShapeBlock(0, 0, -1, block.WOOL.id, 5), minecraftstuff.ShapeBlock(1, 0, 0, block.WOOL.id, 5), minecraftstuff.ShapeBlock(0, 0, 1, block.WOOL.id, 5), minecraftstuff.ShapeBlock(0, -1, 0, block.GLOWSTONE_BLOCK.id), minecraftstuff.ShapeBlock(0, 1, 0, block.GLOWSTONE_BLOCK.id) ] alienShape = minecraftstuff.MinecraftShape(mc, alienPos, alienBlocks) #loop while mode != "missionaccomplished": #get the players position playerPos = mc.player.getTilePos() # if its landing, set target to be above players head if mode == "landing": mc.postToChat("<aliens> We dont come in peace - please panic") alienTarget = playerPos.clone() alienTarget.y = alienTarget.y + HOVER_HEIGHT mode = "attack" elif mode == "attack": #check to see if the alien ship is above the player if alienPos.x == playerPos.x and alienPos.z == playerPos.z:
import time #create minecraft and minecraftdrawing objects mc = minecraft.Minecraft.create() #create the shape for our flying saucer horseBlocks = [ minecraftstuff.ShapeBlock(0, 0, 0, block.WOOD_PLANKS.id), minecraftstuff.ShapeBlock(-1, 0, 0, block.WOOD_PLANKS.id), minecraftstuff.ShapeBlock(1, 0, 0, block.WOOD_PLANKS.id), minecraftstuff.ShapeBlock(-1, -1, 0, block.WOOD_PLANKS.id), minecraftstuff.ShapeBlock(1, -1, 0, block.WOOD_PLANKS.id), minecraftstuff.ShapeBlock(1, 1, 0, block.WOOD_PLANKS.id), minecraftstuff.ShapeBlock(2, 1, 0, block.WOOD_PLANKS.id) ] #set the horses position horsePos = mc.player.getTilePos() horsePos.z = horsePos.z + 1 horsePos.y = horsePos.y + 1 #create the horseShape horseShape = minecraftstuff.MinecraftShape(mc, horsePos, horseBlocks) #make the horse move for count in range(1, 10): time.sleep(1) horseShape.moveBy(1, 0, 0) horseShape.clear()
def __init__(self, craftBlocks, pos): self.mc = minecraft.Minecraft.create() #create the craft self.craftShape = mcstuff.MinecraftShape(self.mc, pos, craftBlocks)
"<aliens>You cannot run forever", "<aliens>Resistance is useless", "<aliens>We only want to be friends" ] #create minecraft and minecraftdrawing objects mc = minecraft.Minecraft.create() mcdrawing = minecraftstuff.MinecraftDrawing(mc) #set the aliens position alienPos = mc.player.getTilePos() alienPos.y = alienPos.y + 50 #set the flying saucer's mode mode = "landing" alienShape = minecraftstuff.MinecraftShape(mc, alienPos) alienShape.setBlock(-1, 0, 0, block.WOOL.id, 5) alienShape.setBlock(0, 0, -1, block.WOOL.id, 5) alienShape.setBlock(1, 0, 0, block.WOOL.id, 5) alienShape.setBlock(0, 0, 1, block.WOOL.id, 5) alienShape.setBlock(0, -1, 0, block.GLOWSTONE_BLOCK.id) alienShape.setBlock(0, 1, 0, block.GLOWSTONE_BLOCK.id) #loop while mode != "missionaccomplished": #get the players position playerPos = mc.player.getTilePos() # if its landing, set target to be above players head if mode == "landing":
import mcpi.minecraft as minecraft import mcpi.block as block import mcpi.minecraftstuff as minecraftstuff import time #create minecraft and minecraftdrawing objects mc = minecraft.Minecraft.create() #set the horses position horsePos = mc.player.getTilePos() horsePos.z = horsePos.z + 1 horsePos.y = horsePos.y + 1 #create the horseShape horseShape = minecraftstuff.MinecraftShape(mc, horsePos) #create the wooden horse by setting blocks horseShape.setBlock(0, 0, 0, block.WOOD_PLANKS.id) horseShape.setBlock(-1, 0, 0, block.WOOD_PLANKS.id) horseShape.setBlock(1, 0, 0, block.WOOD_PLANKS.id) horseShape.setBlock(-1, -1, 0, block.WOOD_PLANKS.id) horseShape.setBlock(1, -1, 0, block.WOOD_PLANKS.id) horseShape.setBlock(1, 1, 0, block.WOOD_PLANKS.id) horseShape.setBlock(2, 1, 0, block.WOOD_PLANKS.id) #make the horse move for count in range(0, 10): time.sleep(1) horseShape.moveBy(1, 0, 0)
mx2_blocks = [ minecraftstuff.ShapeBlock(0, 0, 0, cz), minecraftstuff.ShapeBlock(1, 1, 0, cz), minecraftstuff.ShapeBlock(0, 1, -1, cz), minecraftstuff.ShapeBlock(0, 1, 1, cz), minecraftstuff.ShapeBlock(1, 1, 0, cz), minecraftstuff.ShapeBlock(-1, 1, 0, cz), minecraftstuff.ShapeBlock(0, 2, -1, cz), minecraftstuff.ShapeBlock(0, 2, 1, cz), minecraftstuff.ShapeBlock(1, 2, 0, cz), minecraftstuff.ShapeBlock(-1, 2, 0, cz), minecraftstuff.ShapeBlock(0, 3, 0, cz), ] #生成模型 mx1 = minecraftstuff.MinecraftShape(mc, pos, mx1_blocks) mx2 = minecraftstuff.MinecraftShape(mc, pos, mx1_blocks) #模型运动 while True: x1 = random.randint(0, 5) z1 = random.randint(0, 5) y1 = random.randint(5, 10) x2 = random.randint(0, 5) z2 = random.randint(0, 5) y2 = random.randint(5, 10) time.sleep(0.5) mx1.move(x + x1, y1, z + z1) mx2.move(x + x2, y2, z + z2)