Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-236341

You can feed hay bales to adult donkeys, horses or mules, but hand animation and animal eating animation/sounds are not played

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 23w41a
    • 1.17.1, 21w37a, 21w38a, 21w39a, 21w40a, 21w41a, 21w42a, 21w43a, 21w44a, 1.18 Pre-release 1, 1.18 Pre-release 2, 1.18 Pre-release 4, 1.18 Pre-release 5, 1.18 Pre-release 6, 1.18 Pre-release 8, 1.18 Release Candidate 3, 1.18, 1.18.1 Release Candidate 2, 1.18.1, 22w03a, 22w06a, 1.18.2 Pre-release 1, 22w11a, 22w17a, 22w18a, 1.19 Pre-release 1, 1.19, 1.19.1 Pre-release 5, 1.19.2, 22w42a, 22w46a, 23w06a, 1.20 Release Candidate 1, 1.20, 1.20.1, 1.20.2
    • Confirmed
    • Mob behaviour, Player Animation, Sound
    • Normal
    • Platform

      The bug

      You can feed hay bales to adult donkeys, horses or mules, but hand animation and animal eating animation/sounds are not played.

      The distinction of this issue from MC-93825 is that it is NOT a desync, and it is not MC-233276 as it happens regardless of the animal's temper value, and no other food exhibits this behavior, only hay bales. Also unlike MC-233276, this does not affect llamas.

      To reproduce

      1. Summon a donkey, horse or mule.
      2. Feed the animal hay bales.
      3. The hay bales will be consumed, but no animations or sounds are played.

      Expected result

      Animations and sounds should be played when you feed hay bales to adult donkeys, horses and mules, or adult donkeys, horses and mules should not consume hay bales to begin with, in line with how they used to behave in the past (see this comment).

      Code analysis (tentative)

      If adult donkeys, horses and mules should consume the hay bales:
      There appears to be a missing line in AbstractHorse.java:

      net.minecraft.world.entity.animal.horse.AbstractHorse.java (Mojang mappings, 1.18-pre1)
      ...
      protected boolean handleEating(Player $$0, ItemStack $$1) {
              boolean $$2 = false;
              float $$3 = 0.0f;
              int $$4 = 0;
              int $$5 = 0;
              if ($$1.is(Items.WHEAT)) {
                  $$3 = 2.0f;
                  $$4 = 20;
                  $$5 = 3;
              } 
              ...
              else if ($$1.is(Blocks.HAY_BLOCK.asItem())) {
                  $$3 = 20.0f;
                  $$4 = 180;
                  /** There should be a $$5 here? */ 
              } 
              ...
              else if ($$1.is(Items.GOLDEN_CARROT)) {
                  $$3 = 4.0f;
                  $$4 = 60;
                  $$5 = 5;
                  ...
              } 
              ...
              if ($$5 > 0 && ($$2 || !this.isTamed()) && this.getTemper() < this.getMaxTemper()) {
                  $$2 = true;
                  if (!this.level.isClientSide) {
                      this.modifyTemper($$5);
                  }
              }
             if ($$2) {
                  this.eating();
                  this.gameEvent(GameEvent.EAT, this.eyeBlockPosition());
              }
      

      The variable $$5 appears to control the Temper and the eating event, and it is missing for the hay bale. Llamas override this method in their own class, which would explain why they are not affected.

      If they should not consume the hay bales:
      Code analysis by BugCrusherszz can be found in this comment.

            Unassigned Unassigned
            ampolive [Mod] ampolive
            Votes:
            11 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: