本文整理汇总了Python中terrain.Terrain.place方法的典型用法代码示例。如果您正苦于以下问题:Python Terrain.place方法的具体用法?Python Terrain.place怎么用?Python Terrain.place使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类terrain.Terrain
的用法示例。
在下文中一共展示了Terrain.place方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from terrain import Terrain [as 别名]
# 或者: from terrain.Terrain import place [as 别名]
def __call__(self):
"""Actually build the Minecraft world that corresponds to a tile."""
if self.skip == True:
self.log.log_info("Skipping extant tile %dx%d" % (self.tilex, self.tiley))
self.world = mclevel.MCInfdevOldLevel(self.tiledir)
peak = self.world.playerSpawnPosition()
self.peak = peak[1] - 2
del self.world
return self.peak
# calculate offsets
ox = (self.tilex-self.tiles['xmin'])*self.size
oy = (self.tiley-self.tiles['ymin'])*self.size
sx = self.size
sy = self.size
# load arrays from map file
mapds = gdal.Open(self.mapname, GA_ReadOnly)
lcarray = mapds.GetRasterBand(Region.rasters['landcover']).ReadAsArray(ox, oy, sx, sy)
elarray = mapds.GetRasterBand(Region.rasters['elevation']).ReadAsArray(ox, oy, sx, sy)
bathyarray = mapds.GetRasterBand(Region.rasters['bathy']).ReadAsArray(ox, oy, sx, sy)
crustarray = mapds.GetRasterBand(Region.rasters['crust']).ReadAsArray(ox, oy, sx, sy)
orthor = mapds.GetRasterBand(Region.rasters['orthor']).ReadAsArray(ox, oy, sx, sy)
orthog = mapds.GetRasterBand(Region.rasters['orthog']).ReadAsArray(ox, oy, sx, sy)
orthob = mapds.GetRasterBand(Region.rasters['orthob']).ReadAsArray(ox, oy, sx, sy)
orthoir = mapds.GetRasterBand(Region.rasters['orthoir']).ReadAsArray(ox, oy, sx, sy)
# calculate Minecraft corners
self.mcoffsetx = self.tilex * self.size
self.mcoffsetz = self.tiley * self.size
# build a Minecraft world via pymclevel from blocks and data
self.world = mclevel.MCInfdevOldLevel(self.tiledir, create=True)
tilebox = box.BoundingBox((self.mcoffsetx, 0, self.mcoffsetz), (self.size, self.world.Height, self.size))
self.world.createChunksInBox(tilebox)
# do the terrain thing (no trees, ore or building)
self.peak = [0, 0, 0]
treeobjs = dict([(tree.name, tree) for tree in treeObjs])
self.trees = dict([(name, list()) for name in treeobjs])
for myx, myz in product(xrange(self.size), xrange(self.size)):
mcx = int(self.mcoffsetx+myx)
mcz = int(self.mcoffsetz+myz)
mcy = int(elarray[myz, myx])
lcval = int(lcarray[myz, myx])
bathyval = int(bathyarray[myz, myx])
crustval = int(crustarray[myz, myx])
rval = int(orthor[myz, myx])
gval = int(orthog[myz, myx])
bval = int(orthob[myz, myx])
irval = int(orthoir[myz, myx])
if mcy > self.peak[1]:
self.peak = [mcx, mcy, mcz]
(blocks, datas, tree) = Terrain.place(mcx, mcy, mcz, lcval, crustval, bathyval, self.doSchematics, rval, gval, bval, irval)
[ self.world.setBlockAt(mcx, y, mcz, block) for (y, block) in blocks if block != 0 ]
[ self.world.setBlockDataAt(mcx, y, mcz, data) for (y, data) in datas if data != 0 ]
# if trees are placed, elevation cannot be changed
if tree:
Tree.placetreeintile(self, tree, mcx, mcy, mcz)
# now that terrain and trees are done, place ore
if self.doOre:
Ore.placeoreintile(self)
# replace all 'end stone' with stone
EndStoneID = self.world.materials["End Stone"].ID
StoneID = self.world.materials["Stone"].ID
for xpos, zpos in self.world.allChunks:
chunk = self.world.getChunk(xpos, zpos)
chunk.Blocks[chunk.Blocks == EndStoneID] = StoneID
# stick the player and the spawn at the peak
setspawnandsave(self.world, self.peak)
# write Tile.yaml with relevant data (peak at least)
# NB: world is not dump-friendly. :-)
del self.world
stream = file(os.path.join(self.tiledir, 'Tile.yaml'), 'w')
yaml.dump(self, stream)
stream.close()
# return peak
return self.peak