Simulate eating of a non-edible item?

I recall from the final days of bukkit (the real, legit versions before the dissolve) that there was a particle-effect packet library that indicated it had the ability to particle-ize an item in hand as it would when being eaten.

Using spongevanilla only, not forge, if I were to generate some special item stacks of sugar, reeds, (ultimately in 1.13, coral plants as well etc, calling them lettuce, cabbage, red-cabbage etc) and they had itemstack data / lore on them that was unfakable by players, and identifiable…

What process would I use to simulate eating the item, both visually effect wise (if sponge permits) and event wise?

My guess would be to check for interact block event , secondary … bail out if their food bar is full, otherwise check if the itemstack they hold has the special data/lore and if it does, then add some value to ________________ (is food bar a property, or is it known as something else?) And remove one from the item stack (or empty it)

What about triggering the client animation of eating the object, is that possible within Sponge system, or does that require going off the reservation and doing reflections and packet control or other such things :frowning:

1 Like

You can’t trigger the eating animation. That’s locked to items. However, you can generate particles for any item, since particles are global - ParticleTypes.ITEM_CRACK I believe is the one.

If the stack were replaced in their hand during the interact-block event with something actually edible, would there be a way to trigger the client to eat at that point? Sure, if they were spamming the button down it might catch the next button as an eat, but if just tapping once to interact… can I force the player to eat the item, have client trigger animation?