From 2bb1e9e4b05258355d1086f5667dacb7917ac88b Mon Sep 17 00:00:00 2001 From: David Vierra Date: Tue, 6 Sep 2016 23:53:55 -1000 Subject: [PATCH] Document `dimension.getEntities` --- src/mceditlib/worldeditor.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/mceditlib/worldeditor.py b/src/mceditlib/worldeditor.py index e2aa269..78d788b 100644 --- a/src/mceditlib/worldeditor.py +++ b/src/mceditlib/worldeditor.py @@ -839,6 +839,25 @@ class WorldEditorDimension(object): # --- Entities and TileEntities --- 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: