def main(): world = pymclevel.fromFile( "/home/kane/projects/miningstatistics/testworld1/world/level.dat", readonly=True) print world print world.bounds startTesting(world)
def __init__(self, path, world_path): self.path = path log.info('loading minecraft world, path: %s' % world_path) self.level = mclevel.fromFile(world_path) log.info('world loaded, title: %s' % self.level.displayName) self.post_title = None self.force_sign = False # replace non-existing signs just by xml definition self.signs = SignList() self.blocks = [] self.root = None
def importPaste(self): """ Hack for paste to import a level. """ clipFilename = mcplatform.askOpenFile(title='Choose a schematic or level...', schematics=True) if clipFilename: try: self.loadLevel(pymclevel.fromFile(clipFilename, readonly=True)) except Exception: alert("Failed to load file %s" % clipFilename) self.brushMode = "Fill" return
def load_world(name): import pymclevel # takes a long time, so only imported after argparse if isinstance(name, pymclevel.MCLevel): return name try: if osp.isfile(name): return pymclevel.fromFile(name) else: return pymclevel.loadWorld(name) except IOError as e: raise PyMCLevelError(e) except pymclevel.mclevel.LoadingError: raise PyMCLevelError("Not a valid Minecraft world: '%s'" % name)
def loadSchematic(self, filename): """ actually loads a schematic or a level """ try: level = pymclevel.fromFile(filename) self.loadLevel(level) except Exception, e: print u"Unable to import file {0} : {1}".format(filename, e) traceback.print_exc() if filename: # self.editor.toolbar.selectTool(-1) alert(u"I don't know how to import this file: {0}.\n\nError: {1!r}".format(os.path.basename(filename), e)) return
def load_world(name): import pymclevel if isinstance(name, pymclevel.MCLevel): return name try: if osp.isfile(name): return pymclevel.fromFile(name) else: return pymclevel.loadWorld(name) except IOError as e: raise MCError(e) except pymclevel.mclevel.LoadingError: raise MCError("Not a valid Minecraft world: '%s'" % name)
def test_command_block(): level = TempLevel("AnvilWorld").level cmdblock = fromFile("testfiles/Commandblock.schematic") point = level.bounds.origin + [p / 2 for p in level.bounds.size] level.copyBlocksFrom(cmdblock, cmdblock.bounds, point) te = level.tileEntityAt(*point) command = te['Command'].value words = command.split(' ') x, y, z = words[2:5] assert x == str(point[0]) assert y == str(point[1] + 10) assert z == str(point[2])
def test_command_block(): level = TempLevel("AnvilWorld").level cmdblock = fromFile("testfiles/Commandblock.schematic") point = level.bounds.origin + [p/2 for p in level.bounds.size] level.copyBlocksFrom(cmdblock, cmdblock.bounds, point) te = level.tileEntityAt(*point) command = te['Command'].value words = command.split(' ') x, y, z = words[2:5] assert x == str(point[0]) assert y == str(point[1] + 10) assert z == str(point[2])
def loadSchematic(self, filename): """ actually loads a schematic or a level """ try: level = pymclevel.fromFile(filename, readonly=True) self.loadLevel(level) except Exception as e: logging.warn("Unable to import file %s : %s", filename, e) traceback.print_exc() if filename: # self.editor.toolbar.selectTool(-1) alert( _("I don't know how to import this file: {0}.\n\nError: {1!r}" ).format(os.path.basename(filename), e)) return
def renderRoomBlock(self,coordX, coordY, coordZ): ''' Let's make the magic happen! Place a full room block from a schematic :param cordX: :param coordY: :param coordZ: :return: 15,14,21,16 ''' fileName = self.generateRoomPath() schema = pymclevel.fromFile(fileName, readonly=True) newX = coordX + self.LENGTH; newZ = coordZ newY = coordY box = pymclevel.BoundingBox((newX, newY, newZ),(16,16,16)) self.level.copyBlocksFrom(schema, schema.bounds, box.origin) colorBlock = self.level.materials.blockWithID(159, self.color) replaceBlock = self.level.materials.blockWithID(Colors.BASE) self.level.fillBlocks(box, colorBlock, [replaceBlock]) # setting coords coordArray = self.roomCoord.getCoordArray() for index, coordinate in enumerate(self.coords): blockData = coordArray[index] coordBlock = self.COORD_BLOCK if blockData > 15: coordBlock = self.COORD_BLOCK_EXTENDED coordBlock = self.level.materials.blockWithID(coordBlock, blockData) replaceId = self.BLOCK_COORDS[index] replaceBlock = self.level.materials.blockWithID(replaceId) self.level.fillBlocks(box, coordBlock, [replaceBlock]) pass
options.verbose = False options.radius = int(options.radius) options.chunksToCleanUpAfter = int(options.chunksToCleanUpAfter) options.chunksToReportAfter = int(options.chunksToReportAfter) options.flatworldHeight = int(options.flatworldHeight) if not options.quiet: print "-- World Cleaner -- by Chrisknyfe" import pymclevel ######## Configuration # Name of the world to open worldname = args[0] world = pymclevel.fromFile(worldname) dim = world.getDimension(options.dimensionNum) mats = world.materials # Level below which abandoned mineshafts will generate mineshaftHeight = 64 # Level of maximum chunk generator height chunkgenHeight = 128 # Chunk width / length. chunksidelength = 16 # Lists of relevant blocks: # blocks that are always relevant relevantBlocks = set(
def main(): world = pymclevel.fromFile("/home/kane/projects/miningstatistics/testworld1/world/level.dat", readonly = True) print world print world.bounds startTesting(world)