def getEntities(self, selection, **kw): """ Iterate through all entities within the given selection. If any keyword arguments are passed, only yields those entities whose attributes match the given keywords. For example, to iterate through only the zombies in the selection: for entity in dimension.getEntities(selection, id="Zombie"): # do stuff Parameters ---------- selection : SelectionBox kw : Entity attributes to match exactly. Returns ------- entities: Iterator[EntityRef] """ for chunk in self.getChunks(selection.chunkPositions()): for ref in chunk.Entities: if ref.Position in selection: if matchEntityTags(ref, kw): yield ref
def getTileEntity(self, pos, **kw): cx = pos[0] >> 4 cz = pos[2] >> 4 chunk = self.getChunk(cx, cz) for ref in chunk.TileEntities: if ref.Position == pos: if matchEntityTags(ref, kw): return ref
def getEntities(self, selection, **kw): if hasattr(self, 'Entities'): for e in self.Entities: refType = getattr(self, "EntityRefType", GenericEntityRef) ref = refType(e, self) if ref.Position in selection: if matchEntityTags(e, kw): yield ref
def getTileEntities(self, selection, **kw): for chunk in self.getChunks(selection.chunkPositions()): for ref in chunk.TileEntities: if ref.Position in selection: if matchEntityTags(ref, kw): yield ref