Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
 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
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
 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