I am writing a bukkit plugin for Minecraft that reacts on low food level, and then automatically moves a food item from the inventory to the off hand and then eats it. I managed the first parts, but I can’t find a way in the bukkit API (Player
, HumanEntity
, elsewhere) to make the player use an item.
Is that even possible, and if so, how?
You can send packets to make it look like other players are eating but as far as I'm aware; with vanilla clients, you cannot force the client to eat or show the eating animation. The client tells the server that it is eating and then the server sends packets to everyone else that they are eating.
If you can settle for others seeing them as eating, I believe it's the Player Digging packet that you would need to send with a value of 5. You could send this using ProtocolLib for which there's a decent tutorial.