Walk down the lantern-hung streets of Hoi An, Vietnam and you’ll come upon the Tan Ky House. Though now it’s a tourist attraction, the timber home has been the seat of a Vietnamese merchant family since the town’s 18th century heyday, when it was at the center of Asia’s ceramics trade. Back then, Hoi An was home to both Japanese and Chinese merchant firms. Portuguese Jesuits mingled with Indonesian traders. Local Vietnamese shipped products as far away as Egypt.

And those trade links, they say, brought the Cup of Confucius to Tan Ky House. The museum claims it was gifted to the house’s original owner around two centuries ago. They’re unsure how old it is, or how many hands it passed through before coming to them, but the style of the porcelain and quality of the blue dye indicates Chinese manufacture. Outwardly it’s a normal vessel, little different from any fine teacup of the period apart from the figurine standing inside.

But this cup has a mystical feature: you can’t fill it all the way to the top. If you try, it all drains away. Every drop runs out the bottom.

It’s an incredibly poor design for a drinking vessel—but an incredibly smart one for a magic trick used to teach Confucian principles.

If it’s been awhile since your last world history course, Confucius (a latinization of Kong Fuzi, or “Grand Master Kong”) was born in 551 BCE in Lu state, Kingdom of Zhou. He spent decades as a talented administrator, but when his reforms met resistance, he went into self-imposed exile to travel and refine his philosophies. Fourteen years later he returned to Lu in order to teach all he had learned. There, he gathered disciples and laid the groundwork for numerous books. These works, the Analects, lay out how to create a humane society, instill government ethics, and cultivate a virtuous populace. These were largely collections of Confucius’ lectures and proverbs, which often conveyed meaning via inference and innuendo—meaning not all of them were clear.

One confusing passage in the Analects referred to a principle called the “Doctrine of the Mean,” but failed to define the doctrine itself. Students found this so perplexing that Confucius’ grandson later authored a book explaining that the Doctrine of the Mean was a call for self-moderation. A superior man, it argued, was temperate, objective, self-reflective, and sincere. In other words, practicing constant self-control in order to avoid extremes.

And according to legend, that’s where the cup comes in.

During his year of travel, the story goes, Confucius became lost in a desert. Dehydrated and starving, he came upon a man who led him to a spring and loaned him a drinking bowl. But when Confucius raised the bowl to his lips, he found it empty. He scooped another bowlful of water but, again, found the cup dry—the water was running out a hidden hole in the bottom. Yet the man who saved him drank from it without trouble.

After experimenting, Confucius realized that the mystical cup could only be filled three-quarters full, or the contents would drain out through the secret hole. This, the story goes, planted the idea for the Doctrine of the Mean—that a man who wants everything will end up with nothing. Thus, a village trickster and his magic cup changed the world.

The Cup of Confucius isn’t a common item, but you occasionally come across them in Asia. According to the Tan Ky House, scholars used it as a visual way to teach students ephemeral concepts like the doctrine of the Mean. It was especially instructive when teaching the responsible use of alcohol, since it would literally drain someone’s glass if they were prone to overfilling it. However, it’s just as likely that the item was symbolic—meant to sit on a scholar’s desk or family table as a reminder not to go to extremes.

But the cup’s abilities aren’t mystical, they’re physics. Every Cup of Confucius contains a protrusion or bump in the middle of the vessel—in the Tan Ky cup, it’s the figurine—that conceals an internal siphon. A small hole at the base of the protrusion is actually a pipe that rises up inside the protrusion before turning downward in a U-bend and exiting out the cup’s base. Liquid will stay in the cup provided it doesn’t rise above the highest point of that U-bend, but any more than that and it spills over into the downward section, reducing pressure at the top of the tube and allowing the weight of the water to force the rest of the liquid through.

What makes the vessel seem so mystical is that the cup empties entirely. In fact, the siphoning action is so perfect it even works with dense liquids like mercury.

These trick cups, it should be noted, are not unique to China. Visit the Greek island of Samos and you’ll see them being sold to tourists under the name Pythagoras Cups or Pythagorean Cups, along with a different origin. According to this version, the famous mathematician Pythagoras of Samos invented it as a wine cup to frustrate drunken laborers and greedy students.

It’s unclear where the cup originated. It could’ve spread across the Silk Road, or it may have been a case of simultaneous invention. Either way, it’s interesting that both Greek and Chinese folklore interpreted it as a lesson in moderation.

Apart from its Greek clone though, the Cup of Confucius is largely obscure in the west. In fact, the only reference to it comes from an unlikely source: the 1937 mystery novella The Cup of Confucius, published in The Shadow Magazine. In it, The Shadow breaks up a plot to steal the cup from a private collector, who bought the artifact from anti-Japanese guerillas in China. But the cup described in the novel is more like a Chinese holy grail—a jade vessel covered in precious stones, with no hidden siphon or connection to Confucian philosophy.

Though he knew What Evil Lurks in the Hearts of Men, The Shadow apparently didn’t know much about Chinese folklore.

Today, the Cup of Confucius is a novelty item, mostly used by science teachers and educational channels on YouTube. It’s an ideal visual tool for explaining the difficult-to-grasp physics of siphons.

And that makes it part of an odd category. It’s a magic trick that exists in order to be exposed and explained, thereby enlightening the audience. It’s an illusion that imparts knowledge.

Which is, ironically, the same role it played for centuries in China—and still plays in the Tan Ky House today.