The answer is personification.
Personification is a metaphor and a literary device that takes place when a thing, idea, abstract qualities, any aspect of nature, emotions or event is given human characteristics. This is used in the excerpt when the narrator gives the starts the human attribute of throwing spears as if stars had the consciousness and will to perform such action as humans do.