当前位置: 首页>>代码示例>>Python>>正文


Python mclevel.fromFile函数代码示例

本文整理汇总了Python中mclevel.fromFile函数的典型用法代码示例。如果您正苦于以下问题:Python fromFile函数的具体用法?Python fromFile怎么用?Python fromFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fromFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testINVEditChests

 def testINVEditChests(self):
     info("INVEdit chest")
     invFile = mclevel.fromFile("schematics/Chests/TinkerersBox.inv")
     info("Blocks: %s", invFile.Blocks)
     info("Data: %s", invFile.Data)
     info("Entities: %s", invFile.Entities)
     info("TileEntities: %s", invFile.TileEntities)
开发者ID:dcoshea,项目名称:pymclevel,代码行数:7,代码来源:tests.py

示例2: _import

    def _import(self, command):
        """
    import <filename> <destPoint> [noair] [nowater]

    Imports a level or schematic into this world, beginning at destPoint.
    Supported formats include
    - Alpha single or multiplayer world folder containing level.dat,
    - Zipfile containing Alpha world folder,
    - Classic single-player .mine,
    - Classic multiplayer server_level.dat,
    - Indev .mclevel
    - Schematic from RedstoneSim, MCEdit, mce
    - .inv from INVEdit (appears as a chest)
    """
        if len(command) == 0:
            self.printUsage("import")
            return

        filename = command.pop(0)
        destPoint = self.readPoint(command)
        blocksToCopy = self.readBlocksToCopy(command)

        importLevel = mclevel.fromFile(filename)

        self.level.copyBlocksFrom(importLevel, importLevel.bounds, destPoint, blocksToCopy, create=True)

        self.needsSave = True
        print "Imported {0} blocks.".format(importLevel.bounds.volume)
开发者ID:1060460048,项目名称:Cura,代码行数:28,代码来源:mce.py

示例3: testCreate

    def testCreate(self):
        # log.info("Schematic from indev")

        size = (64, 64, 64)
        temp = mktemp("testcreate.schematic")
        schematic = MCSchematic(shape=size, filename=temp, mats='Classic')
        level = self.indevLevel.level

        schematic.copyBlocksFrom(level, BoundingBox((0, 0, 0), (64, 64, 64,)), (0, 0, 0))
        assert((schematic.Blocks[0:64, 0:64, 0:64] == level.Blocks[0:64, 0:64, 0:64]).all())

        schematic.copyBlocksFrom(level, BoundingBox((0, 0, 0), (64, 64, 64,)), (-32, -32, -32))
        assert((schematic.Blocks[0:32, 0:32, 0:32] == level.Blocks[32:64, 32:64, 32:64]).all())

        schematic.saveInPlace()

        schem = mclevel.fromFile("schematics/CreativeInABox.schematic")
        tempSchematic = MCSchematic(shape=(1, 1, 3))
        tempSchematic.copyBlocksFrom(schem, BoundingBox((0, 0, 0), (1, 1, 3)), (0, 0, 0))

        level = self.anvilLevel.level
        for cx, cz in itertools.product(xrange(0, 4), xrange(0, 4)):
            try:
                level.createChunk(cx, cz)
            except ValueError:
                pass
        schematic.copyBlocksFrom(level, BoundingBox((0, 0, 0), (64, 64, 64,)), (0, 0, 0))
        schematic.close()
        os.remove(temp)
开发者ID:Aftershock1133,项目名称:minecraft.print,代码行数:29,代码来源:schematic_test.py

示例4: _import

 def _import(self, command):
     """
 import <filename> <destPoint> [noair] [nowater]
 
 Imports a level or schematic into this world, beginning at destPoint.
 Supported formats include 
 - Classic single-player .mine, 
 - Classic multiplayer server_level.dat,
 - Indev .mclevel
 - Schematic from RedstoneSim, MCEdit, mce
 - .inv from INVEdit (appears as a chest)
 """
     if len(command) == 0:
         self.printUsage("import")
         return;
     
     filename = command.pop(0)
     destPoint = self.readPoint(command)
     blocksToCopy = self.readBlocksToCopy(command)
     
     importLevel = mclevel.fromFile(filename)
     
     destBox = BoundingBox(destPoint, importLevel.size)
     self.level.createChunksInBox(destBox);
     
     self.level.copyBlocksFrom(importLevel, importLevel.getWorldBounds(), destPoint, blocksToCopy);
     
     
     self.needsSave = True;
     print "Imported {0} blocks.".format(importLevel.getWorldBounds().volume) 
开发者ID:ap0ught,项目名称:pymclevel,代码行数:30,代码来源:mce.py

示例5: loadWorld

    def loadWorld(self, world):

        worldpath = os.path.expanduser(world)
        if os.path.exists(worldpath):
            self.level = mclevel.fromFile(worldpath)
        else:
            self.level = mclevel.loadWorld(world)
开发者ID:1060460048,项目名称:Cura,代码行数:7,代码来源:mce.py

示例6: find_edges

def find_edges(worldDir, edgeFilename):
    level = mclevel.fromFile(worldDir)
    edgeFile = open(edgeFilename, "w")
    sys.stdout.write("finding edges...")
    
    chunks = []
    
    for chunk in level.allChunks:
        chunks.append(chunk)
    
    erodeTasks = []
    
    examined = 0
    lastProgress = 0
    numChunks = len(chunks)
    
    for chunk in chunks:
        checkChunk(level, chunk, erodeTasks)
        examined += 1
        progress = examined * 100 / numChunks
        if progress != lastProgress:
            lastProgress = progress
            sys.stdout.write("\rfinding edges (%d%%)..." % (progress))
    print("")
    
    edgeFile.write("# erodeType erodeDirection posX posZ\n")
    
    numEdgeChunks = 0
    for task in erodeTasks:
        edgeFile.write("%s\n" % (task))
        numEdgeChunks += 1
    edgeFile.close()
    print("found %d edge(s)" % (numEdgeChunks))
开发者ID:gmcnew,项目名称:pymclevel,代码行数:33,代码来源:bestofboth.py

示例7: loadWorld

 def loadWorld(self, world):
     try:
         worldNum = int(world)
         if str(worldNum) == world:
             self.level = mclevel.loadWorldNumber(worldNum)
             
     except ValueError:
         self.level = mclevel.fromFile(world)
开发者ID:JYF,项目名称:pymclevel,代码行数:8,代码来源:mce.py

示例8: testImportSchematic

    def testImportSchematic(self):
        level = self.anvilLevel.level
        cx, cz = level.allChunks.next()

        schem = mclevel.fromFile("schematics/CreativeInABox.schematic")
        box = BoundingBox((cx * 16, 64, cz * 16), schem.bounds.size)
        level.copyBlocksFrom(schem, schem.bounds, (0, 64, 0))
        schem = MCSchematic(shape=schem.bounds.size)
        schem.copyBlocksFrom(level, box, (0, 0, 0))
        convertedSourceBlocks, convertedSourceData = block_copy.convertBlocks(schem, level, schem.Blocks, schem.Data)
        assert (level.getChunk(cx, cz).Blocks[0:1, 0:3, 64:65] == convertedSourceBlocks).all()
开发者ID:Aftershock1133,项目名称:minecraft.print,代码行数:11,代码来源:anvil_test.py

示例9: loadWorld

 def loadWorld(self, world, dimension):
     worldpath = os.path.expanduser(world)
     if os.path.exists(worldpath):
         level = mclevel.fromFile(worldpath)
     else:
         level = mclevel.loadWorld(world)
     if dimension is not None:
         if dimension in level.dimensions:
             level = level.dimensions[dimension]
         else:
             raise InvalidDimensionError, "Dimension {0} does not exist".format(dimension)
     return level
开发者ID:kahrl,项目名称:chunknorris,代码行数:12,代码来源:chunknorris.py

示例10: __init__

 def __init__(self, filename, createFunc=None):
     if not os.path.exists(filename):
         filename = join("testfiles", filename)
     tmpname = mktemp(os.path.basename(filename))
     if os.path.exists(filename):
         if os.path.isdir(filename):
             shutil.copytree(filename, tmpname)
         else:
             shutil.copy(filename, tmpname)
     else:
         createFunc(tmpname)
     self.tmpname = tmpname
     self.level = mclevel.fromFile(tmpname)
开发者ID:jocopa3,项目名称:pymclevel,代码行数:13,代码来源:templevel.py

示例11: manmade_relight

def manmade_relight():
    t = templevel.TempLevel("TimeRelight", createFunc=lambda f:MCInfdevOldLevel(f, create=True))

    world = t.level
    station = mclevel.fromFile("testfiles/station.schematic")

    times = 2

    for x in range(times):
        for z in range(times):
            world.copyBlocksFrom(station, station.bounds, (x * station.Width, 63, z * station.Length), create=True)

    t = timeit(lambda: world.generateLights(world.allChunks), number=1)
    print "Relight manmade building: %d chunks in %.02f seconds (%.02fms per chunk)" % (world.chunkCount, t, t / world.chunkCount * 1000)
开发者ID:Aftershock1133,项目名称:minecraft.print,代码行数:14,代码来源:time_relight.py

示例12: loadWorld

 def loadWorld(self, world):
     try:
         worldNum = int(world)
     except ValueError:
         self.level = mclevel.fromFile(world)
         
         self.filename = self.level.filename
         
         
         
     else:
         if str(worldNum) == world:
             if worldNum > 0 and worldNum <= 5:
                 self.level = mclevel.loadWorldNumber(worldNum)
                 self.filename = self.level.filename
开发者ID:ap0ught,项目名称:pymclevel,代码行数:15,代码来源:mce.py

示例13: __init__

    def __init__(self, filename, createFunc=None):
        if not os.path.exists(filename):
            filename = join("testfiles", filename)
        tmpname = mktemp(os.path.basename(filename))
        if os.path.exists(filename):
            if os.path.isdir(filename):
                shutil.copytree(filename, tmpname)
            else:
                shutil.copy(filename, tmpname)
        elif createFunc:
            createFunc(tmpname)
        else:
            raise IOError, "File %s not found." % filename

        self.tmpname = tmpname
        self.level = mclevel.fromFile(tmpname)
        atexit.register(self.removeTemp)
开发者ID:Aftershock1133,项目名称:minecraft.print,代码行数:17,代码来源:templevel.py

示例14: loadWorld

 def loadWorld(self, world):
     try:
         worldNum = int(world)
     except ValueError:
         self.level = mclevel.fromFile(world)
         
         self.filename = self.level.filename
         
         self.shortWorld = os.path.split(self.level.filename)[1];
         if self.shortWorld == "level.dat":
             self.shortWorld = os.path.split(os.path.split(self.level.filename)[0])[1];
     
     else:
         if str(worldNum) == world:
             if worldNum > 0 and worldNum <= 5:
                 self.level = mclevel.loadWorldNumber(worldNum)
                 self.filename = self.level.filename
                 
                 self.shortWorld = "World{0}".format(worldNum)
开发者ID:dgilman,项目名称:pymclevel,代码行数:19,代码来源:mce.py

示例15: extractZipSchematicFromIter

def extractZipSchematicFromIter(sourceLevel, box, zipfilename=None, entities=True):
    # converts classic blocks to alpha
    # probably should only apply to alpha levels

    if zipfilename is None:
        zipfilename = tempfile.mktemp("zipschematic")

    p = sourceLevel.adjustExtractionParameters(box)
    if p is None:
        return
    sourceBox, destPoint = p

    destPoint = (0, 0, 0)

    tempfolder = tempfile.mktemp("schematic")
    try:
        tempSchematic = MCInfdevOldLevel(tempfolder, create=True)
        tempSchematic.materials = sourceLevel.materials

        for i in tempSchematic.copyBlocksFromIter(sourceLevel, sourceBox, destPoint, entities=entities, create=True):
            yield i
        tempSchematic.saveInPlace()  # lights not needed for this format - crashes minecraft though

        schematicDat = nbt.TAG_Compound()
        schematicDat.name = "Mega Schematic"

        schematicDat["Width"] = nbt.TAG_Int(sourceBox.size[0])
        schematicDat["Height"] = nbt.TAG_Int(sourceBox.size[1])
        schematicDat["Length"] = nbt.TAG_Int(sourceBox.size[2])
        schematicDat["Materials"] = nbt.TAG_String(tempSchematic.materials.name)
        schematicDat.save(os.path.join(tempfolder, "schematic.dat"))

        zipdir(tempfolder, zipfilename)

        import mclevel

        yield mclevel.fromFile(zipfilename)
    finally:
        # We get here if the generator is GCed also
        if os.path.exists(tempfolder):
            shutil.rmtree(tempfolder, False)
开发者ID:nickodell,项目名称:pymclevel,代码行数:41,代码来源:schematic.py


注:本文中的mclevel.fromFile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。