def main(): mc = minecraft.Minecraft() # To run the script, we need the width, height, length and material of the maze. if (5 == len(sys.argv)): width = int(sys.argv[1]) height = int(sys.argv[2]) length = int(sys.argv[3]) material = block.Block.byName(sys.argv[4]) # Make sure, that width and length are odd numbers. if ((not(width%2)) or (not(length%2))): print "Width and length must be odd numbers!" return # Get position of the player. Shift it a little, so the entrance is going to be in front of the player. mc_x, mc_y, mc_z = mc.player.getPos() mc_x -= 1 mc_z += 2 # Init and do the algorithm. maze = Maze_Init(mc, mc_x, mc_y, mc_z, width, height, length, material) # Randomly select the starting point. x = (random.randint(0, width-2))//2*2+1 z = (random.randint(0, length-2))//2*2+1 Maze_CravePassage(mc, maze, mc_x, mc_y, mc_z, x, z, height) mc.postToChat("Maze generation done!") else: # If we did not get enought parameters, then send a warning. mc.postToChat("The following parameters are needed: width, height, length, material") mc.postToChat("For example: 11 2 11 stone")
def __init__(self, mc=None): if mc is not None: self.mc = mc else: self.mc = minecraft.Minecraft() self.width = 1 self.nib = [(0, 0, 0)]
def go(filename, args=[], defaultBlock=STONE): mc = minecraft.Minecraft() playerPos = mc.player.getPos() opts = "" if args and (args[0] == '-' or re.match("^-?[a-zA-Z]", args[0])): opts = args.pop(0) meshArguments = {} if 'y' in opts: meshArguments['swapYZ'] = False elif 'Y' in opts: meshArguments['swapYZ'] = True mc.postToChat("Preparing") mesh = Mesh(filename, minecraft=mc, defaultBlock=defaultBlock, **meshArguments) mc.postToChat("Reading") mesh.read() mc.postToChat("Scaling") if args: s = args.pop(0) if s and int(s): mesh.size = int(s) matrix = None if args: yaw = float(args.pop(0)) pitch = 0 roll = 0 if args: pitch = float(args.pop(0)) if args: roll = float(args.pop(0)) matrix = makeMatrix(yaw, pitch, roll) mesh.scale(playerPos, matrix) if 'n' not in opts: mc.postToChat("Clearing") mc.setBlocks(mesh.corner1, mesh.corner2, AIR) mc.postToChat("Rendering") mesh.render() mc.postToChat("Done!")
def __init__(self, mc=None): if mc: self.mc = mc else: self.mc = minecraft.Minecraft() self.block = GOLD_BLOCK self.width = 1 self.pen = True self.directionIn() self.positionIn() self.delayTime = 0.05 self.nib = [(0, 0, 0)] self.turtleType = PLAYER self.turtleId = None self.fan = None self.stack = [] self.setEntityCommands()
# coding: utf-8 import mcpi.minecraft as minecraft import mcpi.block as block import numpy as np import sys from time import sleep NPY_DIR = "/Users/sakai/Desktop" NPY_FILE = "npydata-{0:04d}-{1:02d}.npy" mc = minecraft.Minecraft() mc.postToChat("Loadnpy2.py Start!") if len(sys.argv) < 3: print("loadnpy2.py mesh1 mesh2") exit(-1) mesh1 = int(sys.argv[1]) mesh2 = int(sys.argv[2]) array = np.load(NPY_DIR+"/"+NPY_FILE.format(mesh1, mesh2)) (zshape, xshape) = array.shape for z in range(zshape): sleep(0.01) for x in range(xshape): hval = array[z][x] mc.setBlocks(x, hval-1, z, x, hval-7, z, block.DIRT) mc.setBlock(x, hval, z, block.GRASS) sleep(0.001)
import mcpi.minecraft as minecraft import time import code import sys #--------------------- ''' Descripcion: Pide una contrasena al jugador. Cuando el jugador entra la contrasena correcta, teleporta a un sitio especifico. Cada contrasena es un funcion. Mirar abajo como adicionar / cambiar contrasenas. ''' #--------------------- mc = minecraft.Minecraft() #Crear conneccino con minecraft playerId = mc.getPlayerId() def inputLine(prompt): mc.events.clearAll() while True: chats = mc.events.pollChatPosts() for c in chats: if c.entityId == playerId: print(c.message) if c.message == 'quit': return 'quit()' elif c.message == ' ': return ''
import mcpi.minecraft as minecraft import mcpi.block as block import time import sys mc = minecraft.Minecraft() #Crear conneccion con minecraft #!!!!!!!!!!!!!!IMPORTANTE!!!!!!!!!!!!!!!!!! #Antes de usar el script, usa el comando: /setworldspawn 0 0 0. #Si no, las coordenadas no funcionan correctamente. #!!!!!!!!!!!!!!IMPORTANTE!!!!!!!!!!!!!!!!!! #Crea una pared desde x1, y1, z1 hasta x2, y2, z2, con un boque especifico: #mc.setBlocks(x1, y1, z1, x2, y2, z2, material) #Ejemplo: crea una casa simple desde el bloque 100, 4, 34 """ ESQUEMA de COORDENADAS: las coordenadas de los cantos son necessárias para crear las paredes: b: 0, 0 + z -------- c: 0 + x, 0 + z / / / / / / / / / / a: 0, 0 ---------- d: 0 + x, 0