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:

  1. using /scoreboard teams add wheatAllergy to make a team named wheatAllergy,
  2. using /scoreboard teams join wheatAllergy @r[limit=X] to specify X random players and place them on team wheatAllergy, and
  3. somehow identifying when players on wheatAllergy eat 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.

  • 7
    For the contact you can use something like /execute @e[type=wolf] ~ ~ ~ effect @a[r=2,tag=dogAllergy] minecraft:poison 10 Commented Jul 12, 2017 at 8:07
  • 2
    @Fabian Excellent idea. Why not make it an answer?
    – DonielF
    Commented Jul 12, 2017 at 18:31
  • 3
    Because I don't really want to polish it up and the main part of your question is answered in AjaxGb's answer. Commented Jul 12, 2017 at 18:36
  • This post needs to be protected, there are starting to be spam answers. Commented Jul 14, 2017 at 20:55
  • 1
    (1.13 syntax for first comment: /execute positioned as @e[type=wolf] run effect give @a[distance=..2,tag=dogAllergy] )
    – pppery
    Commented Aug 5, 2018 at 1:05

3 Answers 3


You can make scoreboard objectives of type minecraft.used:minecraft.<food item name>, for example

/scoreboard objectives add eatBread minecraft.used:minecraft.bread

The only food item this doesn't work for is cake, since cake is not eaten in item form. To detect eating cake, use the objective type minecraft.custom:minecraft.eat_slice_cake instead.

As a minor note, it is not necessary, or even a good idea, to determine whether players are allergic using teams. Players can only be on one team at a time; what if you want a player to be allergic to both wheat and fish? Instead, I recommend that you use tags, like so:

/tag @r[limit=X] add wheatAllergy

Then, to detect that a specific player has eaten a food they are allergic to, you can use

effect give @a[tag=wheatAllergy,scores={eatBread=1..}] minecraft:poison 10
scoreboard players reset @a[scores={eatBread=1..}] eatBread

effect give @a[tag=wheatAllergy,scores={eatCake=1..}] minecraft:poison 10
scoreboard players reset @a[scores={eatCake=1..}] eatCake

effect give @a[tag=wheatAllergy,scores={eatCookie=1..}] minecraft:poison 10
scoreboard players reset @a[scores={eatCookie=1..}] eatCookie

# And so on...

There are statistics for using items (consuming a food item counts as using it) that you can use to create scoreboard objectives.

For example:

/scoreboard objectives add bread stat.useItem.minecraft.bread

will detect when players have eaten bread.

You can then use this for what you want to do:

/effect @a[team=wheatAllergy,score_bread_min=1] minecraft:poison
/scoreboard players reset @a[score_bread_min=1] bread

Alternatively you can also use a combination of advancements and functions, but they're more work to set up. If you're interested in this method just let me know.


You could use scoreboard objectives to track when specific items are eaten. If you type /stat.useItem. and press tab, you will get a list of objective types that track when specific items are used.

To handle contact allergies, you could use the execute command:

/execute @e[type=Wolf] ~ ~ ~ effect @a[team=dogAllergy,r=2] 19 10

However, this would be difficult to use with eggs because they move so quickly.

  • 2
    This is the same approach as the current top voted answer. Please refrain from adding answers that provide no new information or don't answer the question better
    – n_plum
    Commented Jul 13, 2017 at 14:53
  • @n_palum Please downvote duplicate answers so they'll show up in the Low Quality Posts review queue. Commented Jul 13, 2017 at 15:44
  • @DanmakuGrazer Done. Wasn't sure if just DVs were the right thing, none of the flags really fit. Thanks.
    – n_plum
    Commented Jul 13, 2017 at 15:51
  • @n_palum Indeed, I was told that downvotes are the best way to deal with them, rather than flags. It also helps that the downvote stays even if the answer doesn't get deleted for some reason. Commented Jul 13, 2017 at 15:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .