At the end of the first book, A Princess of Mars, John Carter is unwillingly transported back to Earth. The Gods of Mars begins with his arrival back on Barsoom (Mars) after a ten-year separation from his wife Dejah Thoris, his unborn child, and the Red Martian people of the nation of Helium, whom he has adopted as his own. Unfortunately, Carter materializes in the one place on Barsoom from which nobody is allowed to depart: the Valley Dor, which is the Barsoomian afterlife.After John Carter's arrival, a boat of Green Martians on the River Iss are ambushed by the previously unknown Plant Men. The lone survivor is his friend Tars Tarkas, the Jeddak of Thark, who has taken the pilgrimage to the Valley Dor to find Carter. Having saved their own lives, Carter and Tars Tarkas discover that the Therns, a white-skinned race of self-proclaimed gods, have for eons deceived the Barsoomians elsewhere by disseminating that the pilgrimage to the Valley Dor is a journey to paradise. Most arrivals are killed by the beasts of Valley, and the survivors enslaved or eaten by Therns.
Carter and Tars Tarkas rescue Thuvia, a slave girl, and attempt to escape, capitalizing on the confusion caused by an attack by the Black Pirates of Barsoom upon the Therns. During the attack, Tars Tarkas and Thuvia hijack a Black Pirate flier, while Carter fights his way aboard another, killing all but one of the Pirates, and rescuing a captive Thern princess. From the captured Pirate Xodar, Carter learns that the Black Pirates, called the "First Born", also think of themselves as gods, and accordingly prey upon the Therns; and additionally identifies the captive Thern as Phaidor, daughter of the "Holy Hekkador" (high priest) of the Therns. When their flier is recaptured by the First Born and taken to their underground realm of Omean, Carter is taken before Issus, the self-proclaimed goddess of Barsoom, who dictates the Therns through secret communications which they mistake for divine revelation.
Issus takes Phaidor as a handmaiden for one Martian year; whereas Carter is imprisoned, with Xodar as his slave as punishment for being defeated by Carter. Thereafter Carter treats him with honor, and thus gains his friendship. In prison, they encounter a young man later identified as Carter's son Carthoris, with whom Carter is taken to a series of games wherein the previous year's handmaidens are killed and later eaten by Issus and her nobles. Carter leads a revolt of the prisoners, killing many of the First Born; and upon the suppression of their revolt, he and Carthoris escape via underground tunnels, and give themselves to guards unacquainted with the revolt to be returned to their prison. Upon hearing of the revolt, Xodar rejects Issus  divinity and joins the others in escape. Upon later abandoning their aircraft, they encounter Thuvia, who describes the capture of Tars Tarkas by the green warriors of Warhoon (a clan rival to his own). Carter goes to rescue Tars Tarkas, but is discovered by his enemies. After a chase, Thuvia is sent on alone, mounted, while the men attempt a stand against the Warhoons. They are rescued by the Heliumetic navy but do not find Thuvia. Commanding one of the warships is Carter s friend Kantos Kan but the fleet is commanded by Zat Arras, a Jed (chieftain) of the hostile client state of Zodanga, and Carter is suspected of returning from the Valley of Dor, which is punishable by death. Tardos Mors, the Jeddak of Helium, and Mors Kajak, the Jed of Hastor (the grandfather and father, respectively, of Dejah Thoris, and thus Carter s in-laws) are absent from Helium, having led fleets in search of Carthoris. Later, Carter discovers that Dejah Thoris may have taken the pilgrimage to the Valley Dor to find him.
Upon returning to Helium, Carter is tried for heresy by the Zodangans; but the people of Helium do not tolerate this, and Carter is held prisoner for 365 days until his son frees him. Thereafter he goes to rescue Dejah Thoris but is kidnapped by the Zodangans. Carter refuses Zat Arras  offer of freedom in exchange for endorsing Zat Arras as Jeddak of Helium, and is imprisoned. After half a (Barsoomian) year, Carter escapes, and embarks to Omean, with secretly raised troop levies, ships, and soldiers lent by Tars Tarkas. Near Omean Carter is challenged first by the Therns; secondly by Zat Arras; and lastly by the First Born, whereupon Carter causes the Therns and First Born to fight one another, and the Heliumetic crews of the Zodangan fleet mutiny in support of Carter. Thereafter the Heliumites and Tharks defeat the First Born, and Issus herself is killed. But Dejah Thoris, Thuvia, and Phaidor are imprisoned in the Temple of the Sun, each of whose rooms opens only once per year, by Issus, specifically to spite Carter, as Issus was aware that all three were in love with him. Carter and his men scramble to find the keys to their cell in time, but are unsuccessful. Immediately before their room closes, Phaidor attempts to kill Dejah Thoris, and her success or failure are left unknown. The story is thence continued in the third book of Burroughs  Martian series, The Warlord of Mars.
Output: What happens aboard the pirate ship that John boards?