Item won't re-render when consumed and gave by gameLoopFunction at the same tick.
test:test.mcfunction
give @a[score_food1_min=1] minecraft:cookie 1 0
scoreboard players set @a[score_food1_min=1] food1 0
initial command
scoreboard objectives add food1 stat.useItem.minecraft.cookie
gamerule gameLoopFunction test:test
When the player ate a cookie, the food1 score would be added to 1, and the give command in the gameLoopFunction would give the player 1 cookie.
However, it appears that no cookie is given to the player. The cookie re-appeared only when the player click on that item, or manually changing the score of food1 to 1 in order to activate the give command again.
If the number of cookie is more than 1, the number would not change either. The gif attachment demonstrates that behavior.
Also, it seems that the issue is related to time, because when i modified the function to add 1 tick delay, it works fine. (The item would render correctly.)
Reminiscent of MC-118841