How can I control the hunger bar?

Is there anyway that I can use commands to increase, decrease a players hunger when they have a certain amount of hunger bar, and testfor player's hunger bar in vanilla Minecraft?


Solution 1:

You can use the command:

/testfor @a {foodLevel:20}

20 is full hunger points and 0 is no hunger points... as for setting a hunger amount without the ability to change NBT with players yet there isn't an easy way to do this, you would need to give them the effect of hunger for a set amount of time to get them to the correct level and then to increase it give them a saturation effect for the exact amount of time to get them to the correct level....lots of work and a lot of command blocks.

Credit:

http://www.minecraftforum.net/forums/minecraft-discussion/redstone-discussion-and/2182343-how-to-control-a-players-hunger