本文整理汇总了Python中entity.TileEntity.pos方法的典型用法代码示例。如果您正苦于以下问题:Python TileEntity.pos方法的具体用法?Python TileEntity.pos怎么用?Python TileEntity.pos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entity.TileEntity
的用法示例。
在下文中一共展示了TileEntity.pos方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tileEntityAt
# 需要导入模块: from entity import TileEntity [as 别名]
# 或者: from entity.TileEntity import pos [as 别名]
def tileEntityAt(self, x, y, z, print_stuff=False):
entities = []
if print_stuff:
print "len(self.TileEntities)", len(self.TileEntities)
for entityTag in self.TileEntities:
if print_stuff:
print entityTag["id"].value, TileEntity.pos(entityTag), x, y, z
if TileEntity.pos(entityTag) == [x, y, z]:
entities.append(entityTag)
if len(entities) > 1:
log.info("Multiple tile entities found: {0}".format(entities))
if len(entities) == 0:
return None
return entities[0]
示例2: copyEntitiesFromInfiniteIter
# 需要导入模块: from entity import TileEntity [as 别名]
# 或者: from entity.TileEntity import pos [as 别名]
def copyEntitiesFromInfiniteIter(self, sourceLevel, sourceBox, destinationPoint, entities):
chunkCount = sourceBox.chunkCount
i = 0
copyOffset = map(lambda x, y: x - y, destinationPoint, sourceBox.origin)
e = t = 0
for (chunk, slices, point) in sourceLevel.getChunkSlices(sourceBox):
yield (i, chunkCount)
i += 1
if entities:
e += len(chunk.Entities)
for entityTag in chunk.Entities:
x, y, z = Entity.pos(entityTag)
if (x, y, z) not in sourceBox:
continue
eTag = Entity.copyWithOffset(entityTag, copyOffset)
self.addEntity(eTag)
t += len(chunk.TileEntities)
for tileEntityTag in chunk.TileEntities:
x, y, z = TileEntity.pos(tileEntityTag)
if (x, y, z) not in sourceBox:
continue
eTag = TileEntity.copyWithOffset(tileEntityTag, copyOffset)
self.addTileEntity(eTag)
info("Copied {0} entities, {1} tile entities".format(e, t))
示例3: tileEntityAt
# 需要导入模块: from entity import TileEntity [as 别名]
# 或者: from entity.TileEntity import pos [as 别名]
def tileEntityAt(self, x, y, z):
entities = []
for entityTag in self.TileEntities:
if TileEntity.pos(entityTag) == [x, y, z]:
entities.append(entityTag)
if len(entities) > 1:
log.info("Multiple tile entities found: {0}".format(entities))
if len(entities) == 0:
return None
return entities[0]
示例4: removeTileEntities
# 需要导入模块: from entity import TileEntity [as 别名]
# 或者: from entity.TileEntity import pos [as 别名]
def removeTileEntities(self, func):
if not hasattr(self, "TileEntities"):
return
newEnts = []
for ent in self.TileEntities:
if func(TileEntity.pos(ent)):
continue
newEnts.append(ent)
entsRemoved = len(self.TileEntities) - len(newEnts)
log.debug("Removed {0} tile entities".format(entsRemoved))
self.TileEntities.value[:] = newEnts
return entsRemoved
示例5: removeTileEntitiesInBox
# 需要导入模块: from entity import TileEntity [as 别名]
# 或者: from entity.TileEntity import pos [as 别名]
def removeTileEntitiesInBox(self, box):
if not hasattr(self, "TileEntities"):
return
newEnts = []
for ent in self.TileEntities:
if TileEntity.pos(ent) in box:
continue
newEnts.append(ent)
entsRemoved = len(self.TileEntities) - len(newEnts)
debug("Removed {0} tile entities".format(entsRemoved))
self.TileEntities.value[:] = newEnts
return entsRemoved
示例6: fillBlocksIter
# 需要导入模块: from entity import TileEntity [as 别名]
# 或者: from entity.TileEntity import pos [as 别名]
def fillBlocksIter(level, box, blockInfo, blocksToReplace=(), noData=False):
if box is None:
chunkIterator = level.getAllChunkSlices()
box = level.bounds
else:
chunkIterator = level.getChunkSlices(box)
log.info("Replacing {0} with {1}".format(blocksToReplace, blockInfo))
changesLighting = True
blocktable = None
if len(blocksToReplace):
blocktable = blockReplaceTable(blocksToReplace)
newAbsorption = level.materials.lightAbsorption[blockInfo.ID]
oldAbsorptions = [level.materials.lightAbsorption[b.ID] for b in blocksToReplace]
changesLighting = False
for a in oldAbsorptions:
if a != newAbsorption:
changesLighting = True
newEmission = level.materials.lightEmission[blockInfo.ID]
oldEmissions = [level.materials.lightEmission[b.ID] for b in blocksToReplace]
for a in oldEmissions:
if a != newEmission:
changesLighting = True
tileEntity = None
if blockInfo.stringID in TileEntity.stringNames.keys():
split_ver = level.gameVersion.split('.')
if 'Unknown' not in split_ver and "PE" not in split_ver and int(split_ver[0]) >= 1 and int(split_ver[1]) >= 11:
tileEntity = "minecraft:{}".format(blockInfo.stringID)
else:
tileEntity = TileEntity.stringNames[blockInfo.stringID]
blocksIdToReplace = [block.ID for block in blocksToReplace]
blocksList = []
append = blocksList.append
defsIds = level.defsIds
if tileEntity and box is not None:
for (boxX, boxY, boxZ) in box.positions:
if blocktable is None or level.blockAt(boxX, boxY, boxZ) in blocksIdToReplace:
tileEntityObject = TileEntity.Create(tileEntity, defsIds=defsIds)
TileEntity.setpos(tileEntityObject, (boxX, boxY, boxZ))
append(tileEntityObject)
i = 0
skipped = 0
replaced = 0
for (chunk, slices, point) in chunkIterator:
i += 1
if i % 100 == 0:
log.info(u"Chunk {0}...".format(i))
yield i, box.chunkCount
blocks = chunk.Blocks[slices]
data = chunk.Data[slices]
mask = slice(None)
needsLighting = changesLighting
if blocktable is not None:
mask = blocktable[blocks, data]
blockCount = mask.sum()
replaced += blockCount
# don't waste time relighting and copying if the mask is empty
if blockCount:
blocks[:][mask] = blockInfo.ID
if not noData:
data[mask] = blockInfo.blockData
else:
skipped += 1
needsLighting = False
def include(tileEntity):
p = TileEntity.pos(tileEntity)
x, y, z = map(lambda a, b, c: (a - b) - c, p, point, box.origin)
return not ((p in box) and mask[x, z, y])
chunk.TileEntities[:] = filter(include, chunk.TileEntities)
else:
blocks[:] = blockInfo.ID
if not noData:
data[:] = blockInfo.blockData
chunk.removeTileEntitiesInBox(box)
chunkBounds = chunk.bounds
smallBoxSize = (1, 1, 1)
tileEntitiesToEdit = [t for t in blocksList if chunkBounds.intersect(BoundingBox(TileEntity.pos(t), smallBoxSize)).volume > 0]
for tileEntityObject in tileEntitiesToEdit:
chunk.addTileEntity(tileEntityObject)
blocksList.remove(tileEntityObject)
chunk.chunkChanged(needsLighting)
#.........这里部分代码省略.........
示例7: include
# 需要导入模块: from entity import TileEntity [as 别名]
# 或者: from entity.TileEntity import pos [as 别名]
def include(tileEntity):
p = TileEntity.pos(tileEntity)
x, y, z = map(lambda a, b, c: (a - b) - c, p, point, box.origin)
return not ((p in box) and mask[x, z, y])
示例8: differentPosition
# 需要导入模块: from entity import TileEntity [as 别名]
# 或者: from entity.TileEntity import pos [as 别名]
def differentPosition(a):
return not ((tileEntityTag is a) or TileEntity.pos(a) == TileEntity.pos(tileEntityTag))
示例9: getTileEntitiesInBox
# 需要导入模块: from entity import TileEntity [as 别名]
# 或者: from entity.TileEntity import pos [as 别名]
def getTileEntitiesInBox(self, box):
"""Returns a list of references to tile entities in this chunk, whose positions are within box"""
return [ent for ent in self.TileEntities if TileEntity.pos(ent) in box]