64cd55cf74
On a server client (single player's server thread, LAN guests, dedicated servers) the window ended a consumable's use on its own timer and never ate the food: its FoodData waited for the server's next ClientboundSetHealth. With the button still held, the next startUseItem found the food bar below 20 and began another bite, so the eating animation went on after the bar was full (#2471). Vanilla's client never completes a use by itself: LivingEntity.updateUsingItem completes it only on the server, and ServerPlayer.completeUsingItem first sends the player entity event 9 (USE_ITEM_COMPLETE). Player.handleEntityEvent(9) then runs completeUsingItem on the client, where Consumable.onConsume calls the FoodProperties listener on both sides: the client's FoodData eats at once. - The server sends event 9 to the acting guest when a consumable, a potion or a spyglass use completes. Like the guest's packets, the events are queued during their turn (kept across nested turns) and sent with their entity id. - The client keeps using until that event, then shows the last crumbs, eats the food (the next ClientboundSetHealth replaces it) and starts the item's use_cooldown, which ItemStack.use only starts at once for an item with no use time. - What vanilla's client checks so that a use can't outlive the server's: MultiPlayerGameMode.useItem passes on an item cooling down (chorus fruit held through its cooldown), LivingEntity.updatingUsingItem stops when the hand no longer holds the item the use began with (ItemStack.isSameItem), a respawn is a new player with no use, and Consumable.startConsuming starts none for a consumable with no use time. - ItemCooldowns tick where Player.tick ticks them: after LivingEntity.tick's use on the server and after Minecraft.handleKeybinds on the client. Both sides ticked them first, so a guest's entry ended a tick later on the server than on their client, whose held retry was refused and never ended. lan_e2e's new eat_full check eats melon slices up to a full bar with the button still held: before, a new bite had started (use ticks 26, 2, 9, 15); now nothing is in use. Held on two chorus fruits, both are eaten across the cooldown. consume-release holds its completed use a little longer, as the use now ends with the server's event. Fixes #2471 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>