Document dimension.getEntities
This commit is contained in:
parent
0175aded79
commit
2bb1e9e4b0
@ -839,6 +839,25 @@ class WorldEditorDimension(object):
|
|||||||
# --- Entities and TileEntities ---
|
# --- Entities and TileEntities ---
|
||||||
|
|
||||||
def getEntities(self, selection, **kw):
|
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 chunk in self.getChunks(selection.chunkPositions()):
|
||||||
for ref in chunk.Entities:
|
for ref in chunk.Entities:
|
||||||
if ref.Position in selection:
|
if ref.Position in selection:
|
||||||
|
Reference in New Issue
Block a user