def _decode_entity( self, nbt: amulet_nbt.NBTFile, id_type: str, coord_type: str ) -> Optional[Entity]: entity = self._decode_base_entity(nbt, id_type, coord_type) if entity is not None: namespace, base_name, x, y, z, nbt = entity return Entity( namespace=namespace, base_name=base_name, x=x, y=y, z=z, nbt=nbt )
def _parse_entities(entities: amulet_nbt.TAG_List) -> List[Entity]: return [ Entity( entity["namespace"].value, entity["base_name"].value, entity["x"].value, entity["y"].value, entity["z"].value, amulet_nbt.NBTFile(entity["nbt"]), ) for entity in entities ]
""" Create a shallow copy of the entity container. """ return EntityList(self) def __iter__(self) -> Iterable[Entity]: """ An iterable of all the :class:`Entity` objects. """ yield from self.data def __repr__(self) -> str: """Return repr(self).""" return f"EntityList({super().__repr__()})" if __name__ == "__main__": import amulet_nbt entities_ = EntityList() block_ents = [ Entity("minecraft", "creeper", 0.0, 0.0, 0.0, amulet_nbt.NBTFile()), Entity("minecraft", "cow", 0.0, 0.0, 0.0, amulet_nbt.NBTFile()), Entity("minecraft", "pig", 0.0, 0.0, 0.0, amulet_nbt.NBTFile()), Entity("minecraft", "sheep", 0.0, 0.0, 0.0, amulet_nbt.NBTFile()), ] entities_.append( Entity("minecraft", "cow", 0.0, 0.0, 0.0, amulet_nbt.NBTFile())) entities_ += block_ents print(entities_)