I need it so that when a player eats an golden apple, the command block sends a redstone signal. Is there a command for that?


This question is pretty similar to this question, in that you want to detect when a player eats a specific food item on the server. @AjaxGb has offered this solution:

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

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

In your case, you want to detect when a player eats a golden apple, so you would do something like:

/scoreboard objectives add eatGoldenApple minecraft.used:minecraft.golden_apple

However, you also said that you'd want to emit a redstone signal. As mentioned in the comments, and in this answer, that's probably not the ideal thing to do. But you could rig up a redstone comparator so that it emits a redstone signal on golden apple eating detection.

I'm not sure what version you are playing on, so I'll offer you some options depending on your Minecraft version.

Java Edition, pre-1.14:

/scoreboard players test @p eatGoldenApple 1

Bedrock Edition:

/testfor @p[scores={eatGoldenApple=..1}]

Java Edition, post-1.14:

/execute if score  (Player)   eatGoldenApple   matches 1

Not the answer you're looking for? Browse other questions tagged or ask your own question.