Minecraft – How to execute a command after eating an item with custom NBT

minecraft-commandsminecraft-java-edition

I'm looking for a way to execute a command for any player on my server who eats this specific enchanted beetroot which gives them this effect that makes them feel like they are on drugs (screenshots attached)

The Beetroot

The Command

Best Answer

You can use a repeating command block with testfor to detect if someone is holding the beetroot. If it passes true, it can detect if a command linked to stat.eat.beetroot (?) increases to one, reset it to 0, and execute whatever commands you would like. I'll post redstone and commands later when I can get on Minecraft.