本文整理汇总了Python中mclevel.fromFile函数的典型用法代码示例。如果您正苦于以下问题:Python fromFile函数的具体用法?Python fromFile怎么用?Python fromFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fromFile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: _reload
def _reload(self, command):
self.level = mclevel.fromFile(self.filename);
开发者ID:ap0ught,项目名称:pymclevel,代码行数:2,代码来源:mce.py
示例17: natural_relight
def natural_relight():
world = mclevel.fromFile("testfiles/AnvilWorld")
t = timeit(lambda: world.generateLights(world.allChunks), number=1)
print "Relight natural terrain: %d chunks in %.02f seconds (%.02fms per chunk)" % (world.chunkCount, t, t / world.chunkCount * 1000)
开发者ID:Aftershock1133,项目名称:minecraft.print,代码行数:4,代码来源:time_relight.py
示例18: bits
def bits(num):
acc = 0
while num:
acc += 1
num = num & (num - 1)
return acc
for x in dedup_table:
# Compare rightside-up and upside-down versions
dedup_table[x] = min(dedup((x&0x00F)<<8 | (x&0x0F0) | (x&0xF00)>>8),
dedup(x&0xFFF)) | x & 0x1000
if bits(x) != bits(dedup_table[x]):
raise ValueError("Whoops!")
if __name__ == '__main__':
world = mclevel.fromFile("../World2.bigger")
locs = get_locs_for_world(world)
cPickle.dump(locs, file("cached_locs", "wb"), 2)
if __name__ == '__main__':
locs = cPickle.load(file("cached_locs", "rb"))
print "Found %d diamond ore" % len(locs)
clusters = []
while len(locs):
clusters.append(remove_cluster(locs))
cluster_sizes = [0]*20
by_slice = [0]*20
maxes = [[0]*20 for x in range(3)]
cluster_shapes = {}
开发者ID:d0sboots,项目名称:Minecraft,代码行数:31,代码来源:diamond.py
示例19: dump_at_height
import mclevel # https://github.com/mcedit/pymclevel.git
import PIL.Image
level = mclevel.fromFile("level.dat")
s = set() # 3, 45, 99
# search for height
# slow!!! QQ
for h in range(128):
for a in range(512):
for b in range(512):
if level.blockAt(a, h, b) == 49:
s.add(h)
def dump_at_height(h, fn):
img = PIL.Image.new('RGB', (512,512))
for x in range(512):
for y in range(512):
if level.blockAt(x, 3, y) != 49: img.putpixel((x, y), (255, 255,255))
img.save(open(fn, 'wb'), 'PNG')
for i, h in enumerate(s):
dump_at_height(h, '%d.png' % (i+1))
开发者ID:Inndy,项目名称:ctf-writeup,代码行数:25,代码来源:stage1.py
示例20: smooth
def smooth(worldDir, edgeFilename, width = 16):
level = mclevel.fromFile(worldDir)
newEdgeFile = open(edgeFilename + ".tmp", "w")
edgeFile = open(edgeFilename, "r")
width = int(width) / 2
erosionTasks = []
for line in edgeFile.readlines():
originalLine = line
line = line.strip()
# Preserve comments
if line.startswith("#"):
newEdgeFile.write(originalLine)
else:
task = ErosionTask.fromString(line)
erosionTasks.append(task)
edgeFile.close()
numTasks = len(erosionTasks)
skipped = 0
smoothed = 0
treeDecayList = []
if erosionTasks:
examined = 0
for erosionTask in erosionTasks:
examined += 1
sys.stdout.write("\rexamining edge %d of %d..." % (examined, numTasks))
# If the task didn't run (because it requires chunks that
# haven't been generated yet), write it back to edges.txt.
if erosionTask.run(level, treeDecayList, width):
smoothed += 1
else:
skipped += 1
newEdgeFile.write("%s\n" % (task))
print("")
print("decaying %d pieces of eroded trees..." % (len(treeDecayList)))
decay_trees(level, treeDecayList)
print("saving changes...")
level.saveInPlace()
newEdgeFile.close()
if smoothed:
print("smoothed %d edge(s)" % (smoothed))
shutil.move(newEdgeFile.name, edgeFilename)
else:
os.remove(newEdgeFile.name)
if skipped:
print("%d edge(s) can't be smoothed yet, since they're not fully explored" % (skipped))
elif smoothed == numTasks:
print("the map is perfectly smoothed -- nothing to do!")
开发者ID:gmcnew,项目名称:pymclevel,代码行数:61,代码来源:bestofboth.py
注:本文中的mclevel.fromFile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论