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

Tamed mules show heart particles after being fed, even though they cant breed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 20w13b, 1.16.4 Release Candidate 1, 1.16.4, 1.20.2, 23w40a, 23w42a, 1.20.3, 1.20.4, 1.20.5
    • Confirmed
    • Mob behaviour
    • Low
    • Gameplay

      Tamed mules will show heart particles after being fed, despite the fact that they are not able to breed.

      Steps to Reproduce:

      1. Run this command twice to summon two tamed mules
        /summon mule ~ ~ ~ {Tame:1b}
        
      2. Feed both mules an item they like
        /give @p golden_carrot
        

      Observed Results:

      The mules will both display heart particles.

      Expected Results:

      The mules would not show heart particles, as they are not in love and will not breed.

      Screenshots/Videos:

      MC-176758 Current Behavior.mp4

      Code Analysis / MCP-Reborn 1.20.2

      Here in the handleEntityEvent() method of Animal.java, the game first checks to see if the event id is equal to 18 (18 is the "IN_LOVE_HEARTS" event) and if that is true, then the heart particles are displayed around the entity. However, it never checks to see if that entity is capable of breeding.

       Class: net\minecraft\world\entity\animal\Animal.java - Method: handleEntityEvent()
         public void handleEntityEvent(byte eventId) {
            if (eventId == 18) {
               for(int i = 0; i < 7; ++i) {
                  double z1 = this.random.nextGaussian() * 0.02D;
                  double z2 = this.random.nextGaussian() * 0.02D;
                  double z3 = this.random.nextGaussian() * 0.02D;
                  this.level().addParticle(ParticleTypes.HEART, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), z1, z2, z3);
               }
            } else {
               super.handleEntityEvent(eventId);
            }
         }
      

      Possible Fix

      A possible fix for this issue, is to do the following two things:

      1. Add an extra check inside of the handleEntityEvent() method to see if the entity is capable of falling in love before displaying the particles
         public void handleEntityEvent(byte eventId) {
      Fix Start
            if (eventId == 18 && this.canFallInLove()) {
      Fix End
               for(int i = 0; i < 7; ++i) {
                  double d0 = this.random.nextGaussian() * 0.02D;
                  double d1 = this.random.nextGaussian() * 0.02D;double d2 = this.random.nextGaussian() * 0.02D;
                  this.level().addParticle(ParticleTypes.HEART, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), d0, d1, d2);
               }
            } else {
               super.handleEntityEvent(eventId);
            }
         }
      
      1. Inside the Mule.java class, override the "canFallInLove()" method, and return false.
         public boolean canFallInLove() {
            return false;
         }
      

      This fix provides the following behavior:
      MC-176758 Fix.mp4

            Unassigned Unassigned
            Jingy [Helper] Jiingy
            Votes:
            6 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              CHK: