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?
-
5Does this answer your question? Is it possible to create food allergies in Minecraft? – Authom Jan 11 at 14:40
-
2Are you playing on Java or bedrock? – Penguin Jan 11 at 15:52
-
1Btw we probably shouldnt close as duplicate until the version has been given – Penguin Jan 11 at 15:53
-
First of all, you shouldn't be using redstone for this. That's a direct path to the land of bugs. – MBraedley Jan 11 at 16:28
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
/testfor @p[scores={eatGoldenApple=..1}]
/execute if score (Player) eatGoldenApple matches 1