How do I give custom food items an eating animation?

Discussion in 'Spigot Discussion' started by Majong7, Oct 11, 2019.

  1. I'm new to Java (however I do have experience with JavaScript and C++). For the past few days I have been trying to give custom food items an eating animation but nothing worked. I have tried:, but nothing happened.

    Code (Java):
    if (p.getInventory().getItemInMainHand().getItemMeta().getDisplayName() != null && p.getInventory().getItemInMainHand().getType() != Material.AIR) {
                if((e.getAction() == Action.RIGHT_CLICK_AIR) || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                    for (int i = 0;i < arr.length; i++) {
                        if (p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().contains(ChatColor.WHITE + arr[i])){
                            CraftPlayer cPlayer = ((CraftPlayer) p);
                            PacketPlayOutEntityStatus eat = new PacketPlayOutEntityStatus(cPlayer.getHandle(), (byte) 9);
                        } else {
                            //The item that the player has in his main hand isn't a custom item from the config.yml
                } else {
                    //The player is either left clicking or clicking on an NPC
            } else {
                //The material is AIR or the item's name is NULL
    Does anyone know what I should try next (or point me in the right direction)?
  2. The eating animation is managed client-side. You have to create a client mod for your custom items, or alternatively create a resource pack altering existing food items' textures..
  3. You have two solutions:

    - If you are using minecraft 1.14+, you can create a custom item from a food item (like a steak) and change its textures -> that's really easy because it'll keep the animation from the vanilla steak, if you want I'll try to make an example on
    - If you are using minecraft 1.9 to 1.13, then you can try to simulate this animation by cancelling interact with this item when you do a right click (so the item will move) and sends particle + sound of eating.
  4. Not OP, but how would you make a custom item anyways? Like do you. just store it in a map and just use events, or do you create a whole new Item instance and register it?
    • Like Like x 1
  5. I would like to point out that I'm dealing with SKULL_ITEMS and I would prefer to do it in Java instead of making resource packs.
  6. I thought you were talking about that kind of custom items: