The idea is that a certain number of random people on the server are identified to have a food allergy - let's pick wheat for an example. Then, when those players eat any item that contains wheat (bread, cake, and cookie in vanilla MC), they will get the poison effect for a certain amount of time.
This seems to be three steps:
/scoreboard teams add wheatAllergyto make a team named wheatAllergy,
/scoreboard teams join wheatAllergy @r[limit=X]to specify X random players and place them on team
- somehow identifying when players on
wheatAllergyeat any food that contains wheat and applying a poison effect to them.
I assume I would need one command block for each bread, cake, and cookie, but I'm unsure on what those commands would be, exactly. Any ideas?
For bonus points: Same as above, but for contact allergies: i.e., when players on, say, team
eggAllergy are hit by a thrown egg, or when players on team
dogAllergy touch wolves, tamed or untamed. I feel like contact should be easier than eating, but I'm still unsure of what the command would be.